Reputation: 159
How do I match a string in bison grammar? A string that stands for itself like "polySphere" let's say. Will I have to create a token in the .lex file like POLYSPHERE and then use that in bison? Can't I just use the string directly?
Thanks
Upvotes: 0
Views: 1739
Reputation: 126536
You could recognize the string in bison character by character, eg:
polysphere: 'p' 'o' 'l' 'y' 'S' 'p' 'h' 'e' 'r' 'e'
but that is rather ineffecient -- generally its much better to recognize the string in the lexer and return a single token
Upvotes: 1
Reputation: 1220
you can't identify a string in your grammar.you will have an error like this :
multicharacter literal tokens not supported
you should simply add in your lex
"polySphere" { return POLYSPHERE; }
Upvotes: 1