kitten i'll be honest mommy's about to kill herself

This commit is contained in:
crumbtoo
2024-01-14 18:19:37 -07:00
parent e597ecbfc6
commit 17ddf3530c
4 changed files with 390 additions and 148 deletions

View File

@@ -1,6 +1,6 @@
{
module Rlp.Parse
(
( parseRlpProgram
)
where
import Rlp.Lex
@@ -8,7 +8,8 @@ import Rlp.Syntax
import Rlp.Parse.Types
}
%name rlp
%name parseRlpProgram StandaloneProgram
%monad { P }
%lexer { lexerCont } { Located _ TokenEOF }
%error { parseError }
@@ -16,23 +17,56 @@ import Rlp.Parse.Types
%token
varname { Located _ (TokenVarName $$) }
litint { Located _ (TokenLitInt $$) }
'=' { Located _ TokenEquals }
';' { Located _ TokenSemicolon }
';?' { Located _ TokenSemicolonV }
'{' { Located _ TokenLBrace }
'}' { Located _ TokenRBrace }
'{?' { Located _ TokenLBraceV }
'?}' { Located _ TokenRBraceV }
eof { Located _ TokenEOF }
%%
StandaloneProgram :: { [PartialDecl'] }
StandaloneProgram : VL Decls VR eof { $2 }
VL :: { () }
VL : '{?' { () }
VR :: { () }
VR : '?}' { () }
| error { () }
Decls :: { [PartialDecl'] }
Decls : Decl Semi Decls { $1 : $3 }
| Decl Semi { [$1] }
| Decl { [$1] }
Semi :: { Located RlpToken }
Semi : ';' { $1 }
| ';?' { $1 }
Decl :: { PartialDecl' }
Decl : FunDecl { undefined }
FunDecl :: { PartialDecl' }
FunDecl : varname '=' Expr { undefined }
Expr :: { RlpExpr' }
Expr : { undefined }
Expr :: { RlpExpr' }
Expr : Literal { LitE $1 }
| Var { VarE $1 }
Literal :: { Lit' }
Literal : litint { IntL $1 }
Var :: { VarId }
Var : varname { NameVar $1 }
{
parseError :: Located RlpToken -> P a
parseError = error "aaaaah"
parseError = error . show
}