|
@ -10,7 +10,9 @@ import Presyntax.Lexer |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
%name parseExp Exp |
|
|
|
|
|
|
|
|
%name parseExp Exp |
|
|
|
|
|
%name parseStmt Statement |
|
|
|
|
|
%name parseProg Program |
|
|
|
|
|
|
|
|
%tokentype { Token } |
|
|
%tokentype { Token } |
|
|
|
|
|
|
|
@ -32,6 +34,7 @@ import Presyntax.Lexer |
|
|
|
|
|
|
|
|
'->' { Token TokArrow _ _ } |
|
|
'->' { Token TokArrow _ _ } |
|
|
':' { Token TokColon _ _ } |
|
|
':' { Token TokColon _ _ } |
|
|
|
|
|
';' { Token TokSemi _ _ } |
|
|
'=' { Token TokEqual _ _ } |
|
|
'=' { Token TokEqual _ _ } |
|
|
',' { Token TokComma _ _ } |
|
|
',' { Token TokComma _ _ } |
|
|
'*' { Token TokStar _ _ } |
|
|
'*' { Token TokStar _ _ } |
|
@ -43,12 +46,12 @@ import Presyntax.Lexer |
|
|
|
|
|
|
|
|
Exp :: { Expr } |
|
|
Exp :: { Expr } |
|
|
Exp |
|
|
Exp |
|
|
: ExpProj Exp { App Ex $1 $2 } |
|
|
|
|
|
| ExpProj '{' Exp '}' { App Im $1 $3 } |
|
|
|
|
|
|
|
|
: Exp ExpProj { App Ex $1 $2 } |
|
|
|
|
|
| Exp '{' Exp '}' { App Im $1 $3 } |
|
|
|
|
|
|
|
|
| '\\' LambdaList '->' Exp { makeLams $2 $4 } |
|
|
| '\\' LambdaList '->' Exp { makeLams $2 $4 } |
|
|
| '(' VarList ':' Exp ')' '->' Exp { makePis Ex $2 $4 $7 } |
|
|
|
|
|
| '{' VarList ':' Exp '}' '->' Exp { makePis Im $2 $4 $7 } |
|
|
|
|
|
|
|
|
| '(' VarList ':' Exp ')' ProdTail { makePis Ex $2 $4 $6 } |
|
|
|
|
|
| '{' VarList ':' Exp '}' ProdTail { makePis Im $2 $4 $6 } |
|
|
| ExpProj '->' Exp { Pi Ex (T.singleton '_') $1 $3 } |
|
|
| ExpProj '->' Exp { Pi Ex (T.singleton '_') $1 $3 } |
|
|
|
|
|
|
|
|
| '(' VarList ':' Exp ')' '*' Exp { makeSigmas $2 $4 $7 } |
|
|
| '(' VarList ':' Exp ')' '*' Exp { makeSigmas $2 $4 $7 } |
|
@ -56,6 +59,11 @@ Exp |
|
|
|
|
|
|
|
|
| ExpProj { $1 } |
|
|
| ExpProj { $1 } |
|
|
|
|
|
|
|
|
|
|
|
ProdTail :: { Expr } |
|
|
|
|
|
: '(' VarList ':' Exp ')' ProdTail { makePis Ex $2 $4 $6 } |
|
|
|
|
|
| '{' VarList ':' Exp '}' ProdTail { makePis Im $2 $4 $6 } |
|
|
|
|
|
| '->' Exp { $2 } |
|
|
|
|
|
|
|
|
LambdaList :: { [(Plicity, Text)] } |
|
|
LambdaList :: { [(Plicity, Text)] } |
|
|
: var { [(Ex, $1)] } |
|
|
: var { [(Ex, $1)] } |
|
|
| var LambdaList { (Ex, $1):$2 } |
|
|
| var LambdaList { (Ex, $1):$2 } |
|
@ -80,6 +88,14 @@ Tuple :: { Expr } |
|
|
: Exp { $1 } |
|
|
: Exp { $1 } |
|
|
| Exp ',' Tuple { Pair $1 $3 } |
|
|
| Exp ',' Tuple { Pair $1 $3 } |
|
|
|
|
|
|
|
|
|
|
|
Statement :: { Statement } |
|
|
|
|
|
: var ':' Exp { Decl $1 $3 } |
|
|
|
|
|
| var '=' Exp { Defn $1 $3 } |
|
|
|
|
|
|
|
|
|
|
|
Program :: { [Statement] } |
|
|
|
|
|
: Statement { [$1] } |
|
|
|
|
|
| Statement ';' Program { $1:$3 } |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
lexer cont = alexMonadScan >>= cont |
|
|
lexer cont = alexMonadScan >>= cont |
|
|
|
|
|
|
|
|