Parser in happy

I am trying to make a parser using Happy (Haskell Tool). But I get the error message: "unused rule: 11 and unused terminals: 10", and I don't know what that means. In the other hand, I'm really not sure about the use of the $ i parameters in the rules instructions, I think my mistake is because of this. If anyone can help me ...

+3
source share
3 answers

It is not a mistake if you receive these messages, it simply means that part of your grammar is not used, because it is inaccessible from the start character. To learn more about how Happy understands your grammar, use the flag --infofor Happy:

happy --info MyParser.y

MyParser.info MyParser.hs.

+4

- , , . , $$, .

$$ , . , $$ , - -, .

+3

, , ( " true, 1 2", 2 ). --info.

$$ : , , :

data TokenType = INT | SYM
data TokenLex = L TokenType String

TokenType , .

String $$

%token INTEGER   {L INT $$ }
%token OTHER     {L _  $$}

foo : INTEGER bar INTEGER   { read $1 + read $3 }
  | ...

$1 " INTEGER" 3 $" INTEGER". $2 " ( ).

$$, $1 $3 - geniune Haskell String, Happy, " INTEGER - " String " TokenLex", .

+1

Source: https://habr.com/ru/post/1751629/


All Articles