[il-antlr-interest: 26651] [antlr-interest] Define function as numerical and alphanumerical expression

2009-11-04 Thread Thomas Dill
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


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


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


[il-antlr-interest: 23566] [antlr-interest] Comment

2009-05-07 Thread Thomas Dill
Hi there.

 

I still got the following Problem:

 

In the syntax, I want to parse, a comment line starts with -* and ends at
the end of the line. It's possible that an asterisk can appear in a text,
too.

 

I can't find a solution. Below there's what I tried (and many other things).
Can somebody help me?

 

Example:

 

TABLE FILE CAR

PRINT * -* prtints all fields

BY MODEL

END

 

ANTLR Code:

 

grammar FexParser;

options {k=3; backtrack=true; memoize=true;}

 

report:(comment | text | NEWLINE)+ ;

 

comment   :(COMMENT_START ~(NEWLINE))* ;

text  :(~(COMMENT_START | NEWLINE))+;

 

fragment COMMENT_START

  :'-*';

 

WS:('\t' | '\v' | '\f' | ' ' | '\u00A0') {$channel =
HIDDEN;};

fragment NLCHARS

 :'\n'  // Line feed.

  | '\r'  // Carriage return.

  | '\u2028' // Line separator.

  | '\u2029' // Paragraph separator.

 ;

NEWLINE : (NLCHARS) + ;

 

Best regards,

Tom

 


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


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


[il-antlr-interest: 23496] Re: [antlr-interest] Comment Problem

2009-05-04 Thread Thomas Dill
I tried your solution but wasn't successful. I understand the point with the
NLCHARS and NEWLINE but this doesn't really change something with my origin
problem.

 

From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Jim Idle
Sent: Donnerstag, 30. April 2009 17:40
Cc: antlr-inter...@antlr.org
Subject: Re: [antlr-interest] Comment Problem

 

Thomas Dill wrote: 

Hi there.

 

I got the following Problem:

 

In the syntax, I want to parse, a comment line starts with -* and ends at
the end of the line. It's possible that an asterisk can appear in a text.

 

I can't find a solution. Below there's what I tried (and many other things).
Can somebody help me?

You need to eat the comment in your lexer and ignore it in the parser
(unless it is predictable and you want to preserve it).

COMMENT : '-*' (~(NLCHARS))* NEWLINE ;

fragment NLCHARS
: '\n' | '\r' | '\u2028'| '\u2029' ;

NEWLINE : NLCHARS+ ;

However, your grammar only defines these tokens so the set
~(COMMENT_START|NEWLINE) would not have anything to work with any way. Start
by eating the comments in the lexer though.

You should download the example grammar set and read through them, they will
help you a lot.

Jim




 

Example:

 

TABLE FILE CAR

PRINT * -* prtints all fields

BY MODEL

END

 

ANTLR Code:

grammar FexParser;

options {k=3; backtrack=true; memoize=true;}

 

report:(comment | text | NEWLINE)+ ;

 

comment   :(COMMENT_START ~(NEWLINE))* ;

text  :(~(COMMENT_START | NEWLINE))+;

 

fragment COMMENT_START

  :'-*';

 

WS:('\t' | '\v' | '\f' | ' ' | '\u00A0') {$channel =
HIDDEN;};

NEWLINE   :'\n' | '\r' | '\u2028'| '\u2029';

 

Best regards,

Tom

 



  _  



 
 
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 il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


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


[il-antlr-interest: 23444] [antlr-interest] Comment Problem

2009-04-30 Thread Thomas Dill
Hi there.

 

I got the following Problem:

 

In the syntax, I want to parse, a comment line starts with -* and ends at
the end of the line. It's possible that an asterisk can appear in a text.

 

I can't find a solution. Below there's what I tried (and many other things).
Can somebody help me?

 

Example:

 

TABLE FILE CAR

PRINT * -* prtints all fields

BY MODEL

END

 

ANTLR Code:

grammar FexParser;

options {k=3; backtrack=true; memoize=true;}

 

report:(comment | text | NEWLINE)+ ;

 

comment   :(COMMENT_START ~(NEWLINE))* ;

text  :(~(COMMENT_START | NEWLINE))+;

 

fragment COMMENT_START

  :'-*';

 

WS:('\t' | '\v' | '\f' | ' ' | '\u00A0') {$channel =
HIDDEN;};

NEWLINE   :'\n' | '\r' | '\u2028'| '\u2029';

 

Best regards,

Tom


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


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


[il-antlr-interest: 20189] [antlr-interest] unexpected NoViableAltException

2008-10-28 Thread Thomas Dill
Hi,

 

I'm new in developing with ANTLR and I created a short grammar for a
particular type of file (both are attached). If a fieldname is equal to a
keyword or the fieldname starts with the name of a keyword followed by a '_'
I got a 'NoViableAltException([EMAIL PROTECTED])' (with antlrworks). Why is 
that? 

 

Can somebody help me, please?

 

Thanks!

 

Best regards,

Thomas

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-interest@googlegroups.com
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
-~--~~~~--~~--~--~---



MasterFileDescription.g
Description: Binary data
FILE=DATAOBJ , SUFFIX=SQLORA,$
SEGNAME=DATAOBJ , SEGTYPE=S0,$
FIELD=DATA_OBJECT ,ALIAS=DATA_OBJECT ,USAGE=A30   ,ACTUAL=A30   ,MISSING=OFF, 
TITLE='Tabelle',$
FIELD=OBJ_MFD ,ALIAS=OBJ_MFD ,USAGE=A20   ,ACTUAL=A20   ,MISSING=ON ,$
  FIELD=OBJ_PHS_NAME,ALIAS=OBJ_PHS_NAME,USAGE=A30   ,ACTUAL=A30   ,MISSING=ON ,$
  FIELD=ASCII_STORAGE ,ALIAS=ASCII_STORAGE ,
   USAGE=A80   ,ACTUAL=A80   ,MISSING=ON ,$
  FIELD=ASCII_FORMAT,ALIAS=ASCII_FORMAT,USAGE=A20   ,ACTUAL=A20   ,MISSING=ON ,$
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address