How to define capitalized and lowercase identifiers in Irony?

Dec 8, 2014 at 7:41 PM
I'm implementing a grammar using Irony, which has some rules defined like this:
ident   ::=  ( letter ∣  _ ) { letter ∣  0 … 9 ∣  _ ∣  ' }  
 
capitalized-ident   ::=  (A … Z) { letter ∣  0 … 9 ∣  _ ∣  ' }  
 
lowercase-ident ::= (a … z ∣  _) { letter ∣  0 … 9 ∣  _ ∣  ' }  
 
letter  ::=  A … Z ∣  a … z
The point is that I don't know whether IdentifierTerminal captures all the options above. I also did something like this:
RegexBasedTerminal letter = new RegexBasedTerminal("letter", "[a-zA-Z]");
I don't know really how can I implement the above rules in Irony? I nearly finished with everything, though only that part is left.
Coordinator
Dec 8, 2014 at 9:23 PM
you can simply assign AllChars and AllFirstChars properties for lower/upper case versions - these strings contain all characters allowed in identifier
Dec 8, 2014 at 11:13 PM
Can you give me a short code sample, please?
Coordinator
Dec 9, 2014 at 8:51 AM
var allLowerId = new IdentifierTerminal("AllLowerId");
allLowerId.AllFirstChars = "abcd...xyz";
allLowerId.AllChars = allLowerId.AllFirstChars + "0123456789";

var alUpperId = new IdentifierTerminal("AllUpperId ");
alUpperId .AllFirstChars = "ABCD...XYZ";
alUpperId .AllChars = alUpperId .AllFirstChars + "0123456789";
Dec 9, 2014 at 7:40 PM
Thank you very much! One more quick question. I see there is NumberLiteral and StringLiteral, but no CharLiteral. Can I use the above code to define character literal?
Coordinator
Dec 9, 2014 at 7:50 PM
look at c# grammar, there's char literal there