Lower Camel Case

Dec 23, 2009 at 3:30 AM

My current DSL requires that variables be defined in lowerCamelCase. I'm currently using IdentifierTerminal, but obviously this doesn't do the trick. Does anyone have an example of camel case in Irony?



Dec 23, 2009 at 4:58 AM

Use IdentifierTerminal.CaseRestriction property, set it to FirstLower. Other than that, nothing you can do. Parser cannot possibly know that "lowerCamelcase" is wrong, and "lowerCaseCamel" is right, simply because it cannot know all English words and spellings (so it would know that Case is a separate word and should be capitalized) - unless you add a dictionary/spellcheck service.


Dec 23, 2009 at 7:18 PM

I don't require it to check for actual english words/spelling; I'm gonna go with RegexBasedTerminal for my needs. Thanks.

Dec 23, 2009 at 7:46 PM

Well, I don't quite understand what extra functionality regex can give you - IdentifierTerminal with CaseRestriction.FirstLower will give you what you need I think. Keep in mind that regex are slower than direct scanning in specialized terminals like Identifier. Well, whatever works for you. Good luck


Dec 23, 2009 at 7:54 PM

Won't IdentifierTerminal with CaseRestriction.FirstLower allow all of the following?





2 and 3 work for me, but 1 doesn't

Dec 23, 2009 at 8:07 PM

well, the question is - how you distinguish #1? what if identifier is a single word, so no capital letters at all?

Dec 23, 2009 at 8:08 PM

And additionally, you can handle IdentifierTerminal.ValidateToken event and reject the token if you find it invalid, giving your custom error message

Dec 23, 2009 at 10:54 PM

I'll use regular expressions, that way I can distinguish all of them. I'll look into ValidateToken - thanks