On Apr 24, 2010, at 22:58:35, Ron Burk wrote:

> I'm wondering if you meant to disallow spaces in your
> "interval"s. If not, then if you allow (as it appears you intend):
> 
> + 15/  7
> 
> Should that "7" be interpreted as the hours part of the
> interval that starts with "15/" (meaning there's an error
> because the user forgot to supply a second interval operand
> to the '+') or should the "7" be interpreted as a second
> interval (7 seconds)?
> 
> The grammar appears to be ambiguous.

Thanks for the response, and you bring up another question I had: how do I 
disallow spaces in certain places?

In fact, I do wish to allow whitespace around the slash, but not around the 
colons. This is because sometimes the expression is copied from a source that 
puts a space between the slash and the leading hour.

My grammar rewrites something of the form a/b:c:d to (/ a b c d). This much 
appears to be working fine (output from my test rig):

> 15/ + 1/ + 3.1
The tree:
(+ (+ (/ 15) (/ 1)) 3.1)

But this illustrates the problem, I think. The second sum has three children, 
an interval, and two INTs, which should form an intRTL.

> 1/ 2:3:4.5 + 6:7 + 8.9
The tree:
(+ (+ (/ 1 2 3 4.5) 6 7) 8.9)

You can see the rewrite rules on line 60-61:

        http://pastie.org/private/k9holwmls7emhfpgzo1oxw

I wanted to rewrite the rule on line 62 to insert a token to give the tree 
walker a clue as to what was coming next, but I don't know how to insert a fake 
token (or even if it's possible).

BTW, the error points to one line, but ANTLRWorks colors the intRTL rule red 
when I add that sum rule on line 15. Is that a clue?

-- 
Rick


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to