File: Light.g

package info (click to toggle)
frown 0.6.1-14
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,956 kB
  • ctags: 271
  • sloc: haskell: 35,132; makefile: 228; csh: 35; yacc: 23
file content (78 lines) | stat: -rw-r--r-- 2,201 bytes parent folder | download | duplicates (6)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{-

This example demonstrates the use of error correction. A closing brace
is automatically inserted if it is missing.

	frown --debug Light.g
	frown --debug --trace Light.g

Try

	decls [LBRACE, Var, EQU, Var, EOF] :: IO ()
        expr [Var, LPAR, LET, LBRACE, Var, EQU, Var, IN, Var, RPAR, EOF] :: IO ()

-}

module Light
where
import Monad

type Result                   =  Maybe

%{

Terminal                      =  LBRACE
                              |  RBRACE
                              |  SEMICOLON
                              |  EQU
                              |  LET
                              |  IN
                              |  LPAR
                              |  RPAR
                              |  Var
                              | *EOF;

Nonterminal                   = *decls
                              |  declList
                              |  decl
                              |  close
                              | *expr
                              |  fexpr
                              |  aexpr;

decls                         :  LBRACE, declList, close;

declList                      :  declList, SEMICOLON, decl;
                              |  declList, SEMICOLON;
                              |  decl;
                              |  ;

decl                          :  Var, EQU, expr;

close                         :  RBRACE;
                              |  insert RBRACE;

expr                          :  LET, decls, IN, expr;
                              |  fexpr;

fexpr                         :  fexpr, aexpr;
                              |  aexpr;

aexpr                         :  Var;
                              |  LPAR, expr, RPAR;
}%


data Terminal                 =  LBRACE
                              |  RBRACE
                              |  SEMICOLON
                              |  EQU
                              |  LET
                              |  IN
                              |  LPAR
                              |  RPAR
                              |  Var
                              |  EOF
                                 deriving (Show)

frown _                       =  fail "syntax error"