File: Parser.y

package info (click to toggle)
happy 1.20.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,300 kB
  • sloc: haskell: 5,916; xml: 3,727; yacc: 2,448; makefile: 318
file content (29 lines) | stat: -rw-r--r-- 468 bytes parent folder | download | duplicates (12)
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

{
module Parser (parse) where

import Lexer (lex_tok)
import ParserM (Token(..), Tree(..), ParserM, run_parser, get_pos, show_pos,
                happyError)
}

%name      parsex tree
%tokentype { Token }
%monad     { ParserM }
%lexer     { lex_tok } { TEOF }

%token
    fork { TFork }
    leaf { TLeaf }

%%

tree :: { Tree }
tree : leaf           { Leaf }
     | fork tree tree { Fork $2 $3 }

{
parse :: String -> Either String Tree
parse = run_parser parsex
}