Hi,

    I am new to ANTLR but have written grammar previously for bison/flex 
(a long time ago)

    I am trying to familiarize myself with the terminology in ANTLR.

    I am trying to parse the following content to build an object 
representing the information.

    This is the output from a compiled RenderMan shader

8<------8<------8<------8<------8<------8<------8<------8<------
light "distantlight"
    "intensity" "parameter uniform float"
        Default value: 1
    "lightcolor" "parameter uniform color"
        Default value: "rgb" [1 1 1]
    "from" "parameter uniform point"
        Default value: "shader" [0 0 0]
    "to" "parameter uniform point"
        Default value: "shader" [0 0 1]
    "__nondiffuse" "parameter uniform float"
        Default value: 0
    "__nonspecular" "parameter uniform float"
        Default value: 0
8<------8<------8<------8<------8<------8<------8<------8<------

    I have trying out the following grammar.

    I am able to identify keywords like light and name like "distantlight"

    As you can see, the default value line is different depending on the 
content **inside** the "parameter ...." string.

    Does it mean that I have to write two different grammar? i.e. Parser 
within a parser? If I do, how do I communicate that information back out 
to the outer parser to continue?

8<------8<------8<------8<------8<------8<------8<------8<------
class CSILexer extends Lexer;

options { k=1; filter=true; }

LIGHT : ("light")
    {System.out.println("Found light shader: "+getText());}
  ;

SURFACE : ("surface")
    {System.out.println("Found surface shader: "+getText());}
  ;

QUOTEDALPHANUM : '"' ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9')* '"'
    {System.out.println("Found quoted alphanumeric: "+getText());}
  ;


NUMERIC : ('0'..'9')+
    { System.out.println("Found numeric: "+getText()); }
  ;

EXIT    : '.' { System.exit(0); } ;
8<------8<------8<------8<------8<------8<------8<------8<------

Regards


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