On 08/03/2010 03:37 AM, [email protected] wrote:
> addition_operator: ADDITION_OPERATOR
> ;
>
> ADDITION_OPERATOR
> : '+'|'-'
> ;
Why the 2 rules? Why not just:
ADDITION_OPERATOR
: '+' | '-'
;
> UNSIGNED_INTEGER
> : DIGIT+
> ;
>
> simple_factor
> : addition_operator simple_factor
: ADDITION_OPERATOR simple_factor
> | NEGATION_BOOLEAN_OPERATOR simple_factor
> | constant
> | '('expression ')'
> | function
> | object_property_request
> | OBJECT_TYPE partial_path
> | 'ask user' '(' expression ('default' expression)? ')'
> ('expect' predefined_type)?
> ;
>
> constant: BOOLEAN_CONSTANT
> | UNSIGNED_INTEGER ( numeric_constant|
> RELATIVE_TIME_CONSTANT)
> | RELATIVE_TIME_CONSTANT
> | string_constant
> | HEXADECIMAL_CONSTANT
> ;
> real_constant
> : ('.' UNSIGNED_INTEGER)? ('e' addition_operator?
> UNSIGNED_INTEGER)?
> ;
Unless it is legal for your real constants to contain whitespace:
REAL_CONSTANT
: ('.' UNSIGNED_INTEGER)? ('e' ADDITION_OPERATOR?
UNSIGNED_INTEGER)?
;
In fact, your real_constant could in fact be empty! This *must* be
creating headaches for you, yes?
> numeric_constant
> : real_constant engineering_units?
> ;
numeric_constant
: REAL_CONSTANT engineering_units?
;
I don't see a definition of engineering_units. Could this too be
changed to a LEXER rule and somehow change your:
UNSIGNED_INTEGER ( numeric_constant | RELATIVE_TIME_CONSTANT )
into another LEXER rule (this would eliminate the possibility of you
being able to lex the string "123 . 567" as a single real_constant....)
Do these changes help you?
--
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)
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.