Commit c8982829 authored by mnay1u19's avatar mnay1u19
Browse files

alex file

parent 29f6828b
--tokens
{
module Lexer where
}
.in
.out
\ No newline at end of file
%wrapper "basic"
$digit = 0-9
$alpha = [a-zA-Z]
tokens :-
$white+ ;
"--".* ;
Filter {\s -> TokenFilter }
SetName {\s -> TokenSetName s }
Func {\s -> TokenFunc }
Nat {\s -> TokenNat (read s) }
VarName {\s -> TokenVarName s }
Record {\s -> TokenRecord }
true {\s -> TokenTrue }
false {\s -> TokenFalse }
String {\s -> TokenString s }
'[' {\s -> TokenLeftSqBracket }
']' {\s -> TokenRightSqBracket }
"->" {\s -> TokenArrow }
"==" {\s -> TokenisEqual }
"/=" {\s -> TokenisNotEqual }
'(' {\s -> TokenLeftBracket }
')' {\s -> TokenRightBracket }
';' {\s -> TokenApp }
'\\' {\s -> TokenLambda }
',' {\s -> TokenComma }
'.' {\s -> TokenFullstop }
in {\s -> TokenInSet }
out {\s -> TokenOutSet }
$digit $digit+ {(\p s -> TokenInt p (read s))}
$alpha [$alpha $digit \_ \’]* { \p s -> TokenVar p s }
{
--token type:
data Token =
TokenFilter |
TokenSetName String |
TokenFunc |
TokenNat Int |
TokenVarName String |
TokenRecord |
TokenTrue |
TokenFalse |
TokenString String |
TokenLeftSqBracket |
TokenRightSqBracket |
TokenArrow |
TokenisEqual |
TokenisNotEqual |
TokenLeftBracket |
TokenRightBracket |
TokenApp |
TokenLambda |
TokenComma |
TokenFullStop |
TokenInSet |
TokenOutSet
deriving (Eq, Show)
}
......@@ -10,7 +10,7 @@ SetSetFuncCalls : SetFuncCall {[SetFuncCall]}
| SetFuncCall; SetFuncCalls {SetFuncCall:SetFuncCalls}
SetFuncCall : filter '['SetName']' (Func)
--filter[A](\r -> r[2] /= "")
Func : \'('VarNames')' -> Expr
\(r) -> r[1] == "hello"
......@@ -26,3 +26,4 @@ Expr : Expr == Expr
Record : '['Exprs']'
Exprs : Expr
| Expr','Exprs
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment