[antlr-interest] COBOL

Balvinder Singh bals1978 at hotmail.com
Wed May 29 00:20:17 PDT 2002



Hi all,

   I'm writing cobol parser only for WORKING STORAGE AREA of data division. 
I'm using grammar rule and lexical rule for WORKING STORAGE AREA from VS 
COBOL II (http://adam.wins.uva.nl/~x/grammars/vs-cobol-ii/)

I have converted lexical rule to ANTLR format, but I'm getting conflicts for 
some of the rules, rules are as follows :


Literal : NonNumeric | Numeric
        ;

protected
NonNumeric : '"' ( (~'"') | '"' '"' )* '"'
           | '\'' ( (~'\'') | '\'' '\'')* '\''
           | ('X' 'x') '"' HexDigits '"'
           | ('X' 'x') '\'' HexDigits '\''
           ;

AphabeticUserDefinedWord : (('0'.. '9')+ ('-')*)* ('0' .. '9')* ('A' .. 
'Z' 'a' .. 'z') ('A' .. 'Z' 'a' .. 'z' '0' .. '9')* (('-')+ ('A' .. 'Z' 'a' 
.. 'z' '0' .. '9')+)*
                          ;
protected
Numeric : ('+' '-')?(('0' .. '9')* '.' ('0' .. '9')+ | ('0' .. '9')+)
        ;

protected
HexDigits : ('0' .. '9' 'A' .. 'F' 'a' .. 'f')+
          ;

PictureString : (Currency)? ((PicChar)+ (Repeat)?)+ (Punctuation ((PicChar)+ 
(Repeat)?)+)*
              ;

protected
Currency : ~('0' .. '9' | 'A' | 'B' | 'C' | 'D' | 'P' | 'R' | 'S' | 'V' | 
'X' |
'Z' | 'a' .. 'z' | '*' | '+' | '-' | '/' | ',' | '.' | ';' | '(' | ')' | '=' 
|
'\'' | '"' | '\n')
         ;

protected
PicChar : ('A' 'B' 'E' 'G' 'P' 'S' 'V' 'X' 'Z' 'a' 'b' 'e' 'g' 'p' 's' 'v' 
'x'
'z' '9' '0' '+' '-' '*' '$')
        | 'C' 'R'
        | 'D' 'B'
        ;

protected
Repeat : '(' ('0' .. '9')+ ')'
       ;

protected
Punctuation : ('/' ',' '.' ':')
            ;

LevelNumber : ('0')? ('1' .. '9')
            | ('1' .. '4') ('0' .. '9')
            | "66"
            | "77"
            | "88"
            ;

So conflicts are in AphabeticUserDefinedWord and NonNumeric.

can't we get some context from parsing rule and give it as input parameter 
to lexical rule or I have to change lexical rule.

can someone explain me with example .


balvinder




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list