File: shift01.y

package info (click to toggle)
happy 2.1.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 656 kB
  • sloc: yacc: 2,501; haskell: 1,329; makefile: 273
file content (30 lines) | stat: -rw-r--r-- 471 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- Testing the %shift directive

{
module Main where

import System.IO
import Data.Char
}

%expect 0    -- We must resolve the conflicts with %shift
%name group_a
%tokentype { Token }

%token 'A' { A }

%%
exp : exp 'A'       %shift { $1 ++ ",A" }
    | exp 'A' 'A'          { $1 ++ ",2A" }
    |                      { "S" }

{
main =
  if group_a [A, A, A] == "S,2A,A"
    then return ()
    else error "bad parse"

data Token = A

happyError _ = error "parse error"
}