Brian Nelson wrote:
So I have been working on this for about a week, and I even bought the ANTLR book, but I can't seem to find how to get what seems like simple data out of the grammar.

Here's a very, very limited example. I am merely trying to get data out of CSS files. I guess the questions I have are:
1) Should I be using an AST? I assumes I would, since CSS can br broken down to a tree very simply, but upon further reading, it may not actually be beneficial since I am not trying to solve a really complex language issue...
2) How would one, in speudo code, get the actual data out of the following:

The input would be "aa, bb, cc" and I simply want a list of ['aa','bb','cc']. I am not trying to process it, just get the list out of it, ignoring the commas, in a variable I can use.

prog : rone (COMMA rone)*
      ;

rone : IDENT;
You probably do not need a tree if you are just extracting information and you don't need to refer to other parts of the css. From your example above, then  you probably just want the text of your rone rule, which is trivial:

prog
   : r1=rone   { System.out.println($r1.text); }

        (COMMA r2=rone  { System.out.println($r2.text); })*
;

Obviously, though I use sout here, you can do anything with the String that $rn.text gives you.

Jim

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com
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

Reply via email to