[antlr-interest] simple annotation parser
Ben Corne
ben.corne at gmail.com
Thu Mar 10 05:55:07 PST 2011
Hello
I'm trying to parse the examplary lines:
example1: "//@author Ben Corne"
example2: "//@ this is an example docstring"
However, when running this in the interpreter window on example 1 or 2, it
always seems to cut off the last last part of the letters in the resulting
tree:
http://igor.rave.org/annotation.png
here's my attempt so far:
-------------------------------
grammar Annotation;
options {
language = Java;
output = AST;
}
@header{
package edu.vub.at.parser;
}
@lexer::header{
package edu.vub.at.parser;
}
annotation
: '//@' rule
;
rule
: ('\t'|'\n'|' '|'\r')* author
| docstring
;
// Documentation rules
author
: 'author'!
(( '\t' | ' ' )+)!
.*
EOF
;
docstring
: (( '\t' | ' ')+)!
.*
EOF
;
-------------------------------
More information about the antlr-interest
mailing list