Hello everyone,
In the stg files in the org\antlr\codegen\templates\your_language folder
there are two functions where NoViableAltExceptions are generated:
dfaState and sfaStateSwitch. Both of these have an edges attribute,
which contain the if/switch statements that precede the
NoViableAltException. What I want to do (see also the "How to get a list
of all valid options for the next token?" discussion) is to get a list
of the numbers in those statements.
My approach of including <edges> in @" " (C#'s syntax for a string
literal) and applying a regular expression to it works for simple cases,
but if two of these sections are nested C# chokes on the nested quotes.
So I need to preprocess the edges variable somehow.
>From what I've been able to find it's not possible to use programming
code inside a stringtemplate, so something like
edges.toString().replace(...) is impossible (if it is possible I'd love
to hear how). So that leaves me with using the properties and such that
stringtemplate allows. To do this I need to know what type it is though.
According to the code in ACyclicDFACodeGenerator.java in
org\antlr\codegen its type should be StringTemplate, because of
dfaST.setAttribute("edges", edgeST);
and
StringTemplate edgeST = templates.getInstanceOf(dfaEdgeName);
However, if I put for instance <edges.version> in the stg file and try
to compile my grammar file with AntlrWorks I get an error that
STAttributeList doesn't have that property. Ok, apparently edges is an
STAttributeList (though how that follows from a StringTemplate is still
a mystery to me), which inherits from ArrayList, so I can access the
elements in edges with something like <edges:{e|<e>}>. But then what
type are the elements in edge?
So can anyone tell me the type of the elements in edges (or how to use a
replace/regex function on attributes in stg files)?
Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address