diff --git a/Lexer.x b/Lexer.x index bdec949699d531f9d9b42b6300aa1cd01e8c62e4..429d0bdff2be97f84a2f6ffdb44fdda591c6eb53 100644 --- a/Lexer.x +++ b/Lexer.x @@ -35,7 +35,7 @@ then {\p s -> TokenThen p } "==" {\p s -> TokenisEqual p } "/=" {\p s -> TokenisNotEqual p } "+" {\p s -> TokenPlus p } -\= {\p s -> TokenEqual p } +\= {\p s -> TokenEqual p } \( {\p s -> TokenLeftBracket p } \) {\p s -> TokenRightBracket p } \: {\p s -> TokenCol p } @@ -53,6 +53,13 @@ $digit+ {\p s -> TokenNat p (read s) } \"[$alpha $digit]+\" {\p s -> TokenString p (init.tail $ s) } AND {\p s -> TokenBoolAND p } OR {\p s -> TokenBoolOR p } +isSublist {\p s -> TokenIsSubList p } +startswith {\p s -> TokenStartsWith p } +concat {\p s -> TokenConcat p } +union {\p s -> TokenUnion p } +i'section {\p s -> TokenISection p } +difference {\p s -> TokenDifference p } + { @@ -70,8 +77,8 @@ data Token = TokenString AlexPosn String | TokenLeftSqBracket AlexPosn | TokenRightSqBracket AlexPosn | - TokenLeftBrace AlexPosn | - TokenRightBrace AlexPosn | + TokenLeftBrace AlexPosn | + TokenRightBrace AlexPosn | TokenArrow AlexPosn | TokenisEqual AlexPosn | TokenisNotEqual AlexPosn | @@ -94,7 +101,13 @@ data Token = TokenThen AlexPosn | TokenEqual AlexPosn | TokenBoolAND AlexPosn | - TokenBoolOR AlexPosn + TokenBoolOR AlexPosn | + TokenIsSubList AlexPosn | + TokenConcat AlexPosn | + TokenStartsWith AlexPosn | + TokenUnion AlexPosn | + TokenISection AlexPosn | + TokenDifference AlexPosn deriving (Eq, Show) @@ -135,4 +148,10 @@ pos token = case token of (TokenIf p) -> p (TokenThen p) -> p (TokenEqual p) -> p + (TokenIsSubList p) -> p + (TokenStartsWith p) -> p + (TokenConcat p) -> p + (TokenUnion p) -> p + (TokenISection p) -> p + (TokenDifference p) -> p } \ No newline at end of file diff --git a/Parser.y b/Parser.y index 0fdabac071d6388a40e15463f77481c0d2f45012..923cc91b0c8c08303b70d3c503ac947209998d23 100644 --- a/Parser.y +++ b/Parser.y @@ -39,11 +39,7 @@ import CSV x { TokenXProduct _ } map { TokenMap _ } xx { TokenXXProduct _ } --- mapr { TokenMapr _ } --- '!' { TokenNot _ } --- zip { TokenZip _ } contains { TokenContains _ } --- isSubstring { TokenIsSubstring _ } isEmpty { TokenIsEmpty _ } let { TokenLet _} if { TokenIf _} @@ -52,6 +48,17 @@ import CSV '=' { TokenEqual _} or { TokenBoolAND _ } and { TokenBoolOR _ } + isSublist {TokenIsSubList _ } + startswith {TokenStartsWith _} + concat {TokenConcat _ } + union {TokenUnion _ } + i'section {TokenISection _ } + difference {TokenDifference _ } +-- isSubstring { TokenIsSubstring _ } +-- zip { TokenZip _ } +-- mapr { TokenMapr _ } +-- '!' { TokenNot _ } + %left FUNCCALL @@ -63,12 +70,12 @@ import CSV Prog : in SetDecls out Instructions {($2,$4)} -SetDecl : SetName':'Nat {$1} +SetDecl : SetName':'Nat {$1} SetDecls : SetDecl {[$1]} - | SetDecls','SetDecl {$3:$1} + | SetDecls','SetDecl {$3:$1} Instructions : Expr ';' {[$1]} - | Expr';' Instructions {$1:$3} + | Expr';' Instructions {$1:$3} Expr : Expr '('Exprs')' %prec FUNCCALL {FuncCall $1 [] $3} @@ -90,7 +97,17 @@ Expr : | PredefFunc {PredefFunc $1} | Expr or Expr {FuncCall (PredefFunc Or) [] [$1,$3]} | Expr and Expr {FuncCall (PredefFunc And) [] [$1,$3]} + | isSublist dType dType {FuncCall (PredefFunc isSublist) [] [$2,$3]} + | startswith dType dType {FuncCall (PredefFunc startswith) [] [$2,$3]} + | concat dType dType {FuncCall (PredefFunc concat) [] [$2,$3]} + | union dType dType {FuncCall (PredefFunc union) [] [$2,$3]} + | i'section dType dType {FuncCall (PredefFunc i'section) [] [$2,$3]} + | difference dType dType {FuncCall (PredefFunc difference) [] [$2,$3]} +dType :: record {Record} + | Str {String $1} + + PredefFunc : isEmpty {IsEmpty} | filter {Filter} | contains {Contains} @@ -98,6 +115,12 @@ PredefFunc : isEmpty {IsEmpty} | map {Map} | and {And} | or {Or} + | isSublist {isSublist} + | startswith {startswith} + | concat {concat} + | union {union} + | i'section {i'section} + | difference {difference} -- | zip {Zip} -- | Mapr