Awesome, got it working just as you mentioned, by defining it as a
lexer rule.  I got it there accidentally by just using good practices,
but you've pointed out why it didn't originally work.

Yeah, I won't be using it for any other constructs.  The idea is that
basically anything between the braces will get evaluated by a JSON lib
in the application itself.  I don't particularly need to parse JSON
grammar with Antlr for now as I can just allow JSON libs to do it I'm
sure in a non as efficient manner, but am planning on parsing with
Antlr in the future when the time permits to refactor.

Thanks a bunch to everyone.

Ilya Sterin



On Mon, Nov 24, 2008 at 2:28 PM, Gavin Lambert <[EMAIL PROTECTED]> wrote:
> At 13:22 24/11/2008, Ilya Sterin wrote:
>>So in my grammar, I capture blocks of JSON-like structures.  I
>>don't want antlr to try to parse that structure, but rather to
>>evaluate it as a string.
>>
>>Here is a sample code...
>>
>>define project as {
>>    "name": "some_widget",
>>    "version": "0.01-alpha"
>>}
> [...]
>>json
>>  :  '{' .* '}'
>>  ;
>
> The problem is because you've used a parser rule instead of a lexer rule
> (and thus . means "any token", not "any character").  If you change this to
> a lexer rule, then it should work.
>
> (Of course, this assumes that {...} isn't used for any other construct in
> your language.  If it is, then things get more complicated.)
>
>

List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/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