I posted a couple related questions earlier, but now I'm down to a more
fundamental question.
I'm trying to use a complete lexer/parser/tree parser. I'd like to support two
types of expressions representing time intervals. In the end, they evaluate to
a value representing seconds. The two types look like this:
1) 15/
2) 15/ 23
3) 15/ 23:12
4) 15/ 23:12:07
5) 15/ 23:12:07.2
and
6) 7.2
7) 12:07.2
8) 23:12:07.2
The main difference is that if the expression starts with INT '/', then it's
built up left-to-right with each value representing days, hours, minutes, and
seconds, respectively. If there is no '/' in the expression, it's built up
right-to-left, with seconds in the right-most position.
I'm having trouble conceptualizing what the grammar really should look like,
and how the tree parser would look. When I try to write stuff out in the form
of INT '/'! (INT (':'! INT)?)?, I get lots of "matches more than one
alternative" warnings.
OTOH, one can think of these as arithmetic expressions. Considering example 5
above, it would be:
24 * 3600 * 15
+ 3600 * 23
+ 60 * 12
+ 7.2
------------------
1379527.2
But I can't figure out how to build the tree that accounts for the position of
each element to allow all the alternatives 1 - 5.
Thanks for any guidance.
--
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.