aboutsummaryrefslogtreecommitdiff
path: root/Sil/Parse.dcl
blob: 6febca5381e35e53829bcd57084d25eb594ae96c (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
definition module Sil.Parse

from StdOverloaded import class ==, class toString

from Data.Error import :: MaybeError

from Sil.Parse.Parser import class name
from Sil.Syntax import :: Program, :: Literal

:: Token
	= TParenOpen          //* (
	| TParenClose         //* )
	| TBraceOpen          //* {
	| TBraceClose         //* }
	| TComma              //* ,
	| TSemicolon          //* ;
	| TAssign             //* :=
	| TTilde              //* ~
	| TPlus               //* +
	| TMinus              //* -
	| TStar               //* *
	| TSlash              //* /
	| TPercent            //* %
	| TLit Literal        //* True; False; integers
	| TIf                 //* if
	| TWhile              //* while
	| TReturn             //* return
	| TMachineCode String //* |~ machine code
	| TName String        //* a string

instance == Token
instance toString Token
instance name Token

:: ParseError
	= E.a: Invalid String a & toString a
	| Expected String
	| UnknownError

instance toString ParseError

tokenise :: [Char] -> MaybeError ParseError [Token]

parse :: ([Token] -> MaybeError ParseError Program)