[antlr-interest] Define "function" as numerical and alphanumerical expression

Thomas Dill thomas.dill at teleport.ch
Wed Nov 4 08:33:01 PST 2009


Hi!

 

I need help for the following problem:

 

I think the best way to describe it, is to show you what I tried. This
produces a bunch of errors. 

 

expression                     :    conditional_expression |
numerical_expression | alphanumerical_expression | function | data_field ;

conditional_expression         :    'IF' arguments 'THEN' value ('ELSE'
(conditional_expression | value))? ;

arguments                      :    argument  (('OR' | 'AND') argument)* |

'(' arguments ')' ;

Argument                      :    value relational_operator value |

                                    (NOT? value IN) ('('
(SingleStringLiteral | NumericLiteral) (COMMA (SingleStringLiteral |
NumericLiteral))* ')' | FILE OBJNAME)  ;

relational_operator            :    RelOp | alphanumerical_relational_op |
numerical_relational_op ;

alphanumerical_relational_op   :    ARelOp ;

numerical_relational_op        :    NRelOp numerical_expression  'TO' ;

value                          :    numerical_expression  |
alphanumerical_expression | function | data_field;

function                       :    FUNCTION function_argument ')';

function_argument              :    (numerical_expression  |
alphanumerical_expression | function | data_field) (COLON
numerical_expression  | alphanumerical_expression | function | data_field)*;

alphanumerical_expression      :    (SingleStringLiteral) (chrOp
(SingleStringLiteral))+;

numerical_expression           :    (numExprA) (NumOp (numExprA))+ |

'('numerical_expression  ')' ;

numExprA                       :    NumericLiteral; 

data_field                     :    PREOP? PREFIX? OBJNAME

 

PREOP                          :
('AVE'|'MAX'|'MIN'|'FST'|'TOT'|'CNT'|'SUM'|'ALL'|'ST'|'CT'|'ASQ'|'PCT'|'RPCT
'|'SEG'|'DST')'.';     

PREFIX                         :    OBJNAME '.';    

FUNCTION                       :    OBJNAME '(';

OBJNAME                        :    ('A'..'Z') ('A'..'Z'|'0'..'9'|'_')*;

NumOp                          :    '**' | '*' | '+' | '-' | '/' | 'AND' |
'OR';     

ChrOp                          :    '|' | '||' ;

RelOp                         :
'EQ'|'IS'|'ISNOT'|'ISFROM'|'EXCEEDS'|'NE'|'GE'|'GT'|'LT'|'LE'|'IS
MISSING'|'ISNOT MISSING'  ;

NRelOp                         :    'FROM'|'ISFROM'|'NOTFROM';

ARelOp                         :
'CONTAINS'|'OMITS'|'INCLUDES'|'EXCLUDES'|'NOT LIKE'|'LIKE';

fragment StringLiteral         :    '"' ~('"')* '"' | SingleStringLiteral ;

SingleStringLiteral            :    '\'' ~('\'')* '\''   ;

NumericLiteral                 :    DecimalLiteral | IntegerLiteral ;

fragment IntegerLiteral        :    DecimalDigit+;

fragment DecimalLiteral        :    DecimalDigit+ '.' DecimalDigit* | '.'
DecimalDigit+ ;

fragment DecimalDigit          :    ('0'..'9') ;

 

I really don't know how to describe the problem but I urgently need some
help.

 

Best regards,

Tom

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091104/e25f8a77/attachment.html 


More information about the antlr-interest mailing list