I'm trying to write a parser for PL/SQL package header files but I'm banging
my head against the wall with a basic problem to do with case-insensitive
parsing. I'm using Jim Idle's NoCaseFileStream to convert tokens into upper
case, but I'm finding that the parser gets confused when it comes across
language keywords that are embedded within comments. Here's some example
input which has the OR keyword embedded within the package comment. The
"create or replace package" statement is deliberately messed up - the parser
handles this correctly, but it stumbles against the first 'or' on line 2:
/**
blah blah or blah
*/
create Or rePlace PACKAGE
test IS
Here's the grammar:
grammar Test;
input: statement+ ;
statement: pkgComment | pkgStmt ;
pkgComment: '/**' description '*/' ;
pkgStmt: 'CREATE' ('OR' 'REPLACE') 'PACKAGE' ID ('AS' | 'IS')
{System.out.println("found package: "+$ID.text); }
;
descrption: (ID {System.out.println("description: ID="+$ID.text);})+ ;
ID: Letter (Letter | Digit)* ;
NUMBER: Digit Digit* ('.' Digit*)? ;
fragment
Digit: '0'..'9' ;
fragment
Letter: 'a'..'z' | 'A'..'Z' | '_' ;
NL: ('\r'? '\n') { skip();} ;
WS: (' '| '\t') {skip();} ;
EVERYTHING_ELSE: . ;
I get the following output which shows that the pkgStmt parsing is ok, but
the pkgComment isn't working:
line 11:2 mismatched character '-' expecting '*'
description: ID=blah
description: ID=blah
line 2:10 mismatched input 'or' expecting '*/'
found package: test
I'm slowly working my way through the book, and I've looked through the wiki
FAQs and postings here but haven't found anything that'll help me (that I
can understand, at least!) - any suggestions would be most appreciated!
Thanks in advance!
Bob.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address