aboutsummaryrefslogtreecommitdiff
path: root/Sil/Parse.dcl
blob: cf27df22a2023596ddbdb6507052df4506d53f8f (plain) (blame)
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
definition module Sil.Parse

from StdOverloaded import class ==, class toString

from Data.Error import :: MaybeError

from Sil.Error import :: Error
from Sil.Syntax import :: Program, :: Literal
from Sil.Util.Parser import class name, :: ParseInput

:: Token
	= TParenOpen          //* (
	| TParenClose         //* )
	| TBrackOpen          //* [
	| TBrackClose         //* ]
	| TBraceOpen          //* {
	| TBraceClose         //* }
	| TComma              //* ,
	| TColon              //* :
	| TSemicolon          //* ;
	| TField String       //* . and field name
	| TAssign             //* :=
	| TTilde              //* ~
	| TExclamation        //* !
	| TPlus               //* +
	| TMinus              //* -
	| TStar               //* *
	| TSlash              //* /
	| TPercent            //* %
	| TEquals             //* ==
	| TUnequals           //* <>
	| TLe                 //* <=
	| TGe                 //* >=
	| TLt                 //* <
	| TGt                 //* >
	| TDoubleBar          //* ||
	| TDoubleAmpersand    //* &&
	| TLit Literal        //* True; False; integers
	| TIf                 //* if
	| TElse               //* else
	| TWhile              //* while
	| TReturn             //* return
	| TMachineCode String //* |~ machine code
	| TName String        //* a string

instance == Token
instance toString Token
instance name Token

tokenise :: [Char] -> MaybeError Error [ParseInput Token]

parse :: ([ParseInput Token] -> MaybeError Error Program)