Lower Camel Case

Dec 23, 2009 at 4: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?

 

Thanks;

Coordinator
Dec 23, 2009 at 5: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.

Roman

Dec 23, 2009 at 8:18 PM

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

Coordinator
Dec 23, 2009 at 8: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

Roman

Dec 23, 2009 at 8:54 PM

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

thisisntcamelcase

thisIscamelCase

thisIsCamelCase

 

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

Coordinator
Dec 23, 2009 at 9:07 PM

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

Coordinator
Dec 23, 2009 at 9: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 11:54 PM

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