class CSVParser extends Parser;
options { k=2; }
file {System.out.println("
");}
: ( line (NEWLINE line)* (NEWLINE)? EOF)
{System.out.println("
");}
;
line {System.out.println(" ");}
: ( (record)+ )
{System.out.println("
");}
;
record {System.out.print(" ");}
: ( (r:RECORD) (COMMA)? )
{System.out.print(r.getText());
System.out.println(" | ");}
;
class CSVLexer extends Lexer;
options { charVocabulary='\3'..'\377'; }
RECORD : '"'! (~(','|'\r'|'\n'))+ ;
COMMA : ',' ;
NEWLINE : ('\r''\n')=> '\r''\n' //DOS
| '\r' //MAC
| '\n' //UNIX
{ System.out.println("matched newline"); newline(); }
;
WS : (' '|'\t') { $setType(Token.SKIP); } ;