Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parser in Happy

I'm trying to do a parser with Happy (Haskell Tool) But I'm getting a message error: "unused ruled: 11 and unused terminals: 10" and I don't know what this means. In other hand I'm really not sure about the use of $i parameters in the statements of the rules, I think my error is because of that. If any can help me...

like image 424
Anny Avatar asked Jun 28 '26 21:06

Anny


2 Answers

It's not an error if you get these messages, it just means that part of your grammar is unused because it is not reachable from the start symbol. To see more information about how Happy understands your grammar, use the --info flag to Happy:

happy --info MyParser.y

which generates a file MyParser.info in addition to the usual MyParser.hs.

like image 123
Simon Marlow Avatar answered Jun 30 '26 15:06

Simon Marlow


Unused rules and terminals are parts of your grammar for which there is no way to reach from the top level parse statements, if I recall correctly. To see how to use the $$ parameters, read the happy user guide.

The $$ symbol is a placeholder that represents the value of this token. Normally the value of a token is the token itself, but by using the $$ symbol you can specify some component of the token object to be the value.

like image 31
Don Stewart Avatar answered Jun 30 '26 14:06

Don Stewart