Juan Hernandez has posted comments on this change.

Change subject: cli: No regular expression for IP, UUID or number
......................................................................


Patch Set 1:

It isn't possible to detect the type of an argument at the moment either, as 
everything is an string. So in that regards the patch is good.

If in the future it is necessary to know the type of a parameter then it can be 
converted in the same way it is in the patch:

  t_WORD(self, t):
    r'[^ \n\t"\'<>|!\\#;]+'
    if is_number(t.value):
      t.value = convert_to_number(t.value)
    elif is_ipaddr(t.value):
      t.value = convert_to_ipaddr(t.value)
    elif is_uuid(t.value):
      t.value = convert_to_uuid(t.value)
    elif is_whatever(t.value):
      t.value = convert_to_whatever(t.value)
    ...
    return t

So this patch doesn't block adding different types or type conversions in the 
future. All what it does is simplify the grammar.

In addition take into account that it isn't possible/easy to change the lexer 
to do greedy match of the regular expressions (that would solve the problem) 
because internally python-ply builds a single regular expression, joining the 
expressions you give for each token with the "|" operator. For example, if you 
have regular expressions "A" and "B" for tokens it will build an expression 
like "(A|B)". In the regular expressions in Python the "|" is never greedy, so 
it the input matches both A and B then it will always select A, regardless of 
lenght. It isn't possible to tell the lexer to be greedy and select the longest 
match.

All in all, I believe that this patch doesn't break anything, and doesn't 
preclude using types in the future.

-- 
To view, visit http://gerrit.ovirt.org/29722
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If670144751fdb9564380a12fb73596ecbaa47ee9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-cli
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Barak Azulay <[email protected]>
Gerrit-Reviewer: Ilia Meerovich <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Michael Pasternak <[email protected]>
Gerrit-Reviewer: Ravi Nori <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-HasComments: No
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to