From 9f95fa78463d7e6b047485bdce28f1a970a45fd2 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 17 Jul 2017 21:48:37 +0000 Subject: Initial commit --- Sil/Parse.dcl | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Sil/Parse.dcl (limited to 'Sil/Parse.dcl') diff --git a/Sil/Parse.dcl b/Sil/Parse.dcl new file mode 100644 index 0000000..b48fdbc --- /dev/null +++ b/Sil/Parse.dcl @@ -0,0 +1,37 @@ +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 //* := + | TLit Literal //* True; False; integers + | TIf //* if + | TWhile //* while + | TReturn //* return + | 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) -- cgit v1.2.3