Parsing rules with constraints

While adding a rule for enforced named parameter in Skila I wished I could add simple expression to parsing rule like:

param := IDENT=named IDENT COLON IDENT

which would translate that I can have two identifiers in a row, however first has to be equal to “named”. Since NLT is not a generator suite, instead of this straightforward approach I added extra lambda where you can make such comparison yourself. As a bonus I added ability to set custom error message and control if the parsing should continue or stop (check NLT package for details).

Relaxed (job done), I prepared to publish the package, I added small new example for this feature, I checked old examples — bang! Infinite loop in lexer, what the devil? Apparently the one that loves details — I didn’t validate lexer rules whether they match empty input. Such lexer rule:

IDENT = [a-zA-Z]*

asks for trouble because it will work as fallback rule some day matching zero characters and moving forward by zero characters. Not any longer, fixed!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: