Hi,

I need to accept statements like:

  "a" and "b" and "c"

and retrieve the quoted strings (i.e. "a", "b", and "c").

When it didn't work as expected I decided to boil it down to its simplest
components.  I would expect the following to match, but it doesn't:

ruleA : QUOTED_TEXT 'and' QUOTED_TEXT 'and' QUOTED_TEXT;

QUOTED_TEXT : '\"' ( options {greedy=false;} : .)* '\"'
{ setText(getText().substring(1, getText().length() - 1)); } ;

With the text '"a" and "b" and "c"' (without the single quotes) it produces
the following output:

line 1:8 mismatched character '"' expecting 'w'
line 1:19 required (...)+ loop did not match anything at character '<EOF>'
line 1:9 mismatched input 'b' expecting 'and'

Changing ruleA so one of the quoted strings is replaced by the QUOTED_TEXT
lexical removes any errors.  For example, the following ruleA definition
works:

ruleA: '"a" and' QUOTED_TEXT 'and "c"';

So, my question is, what have I missed?  (This is using IDEA 8 with the
latest antlr works plugin by the way).

Many thanks,

Col

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 [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.

Reply via email to