antlr3 - what does | mean when there is no right side in antlr -


i saw in antlr grammar today not sure means. wish google let me search characters...

resultlist: (star | attributelist |) -> ^(result attributelist? star?);

notice second "|" character has no right side element? mean?

thanks, dean

it means matches nothing. following, more verbose rule, same:

resultlist : star -> ^(result star) | attributelist -> ^(result attributelist) | /* nothing */ -> result ; 

i think version above more clear, , easier evaluate later on sine there no 2 optional child nodes, attributelist , star, need check presence.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -