Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp2212-cw-2021
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PLC
comp2212-cw-2021
Commits
c69a3807
Commit
c69a3807
authored
4 years ago
by
mnay1u19
Browse files
Options
Downloads
Patches
Plain Diff
union,intersection,concat,startswith,difference, isSublist have been added to lexer and paser files
parent
69416607
Branches
newSematics
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Lexer.x
+23
-4
23 additions, 4 deletions
Lexer.x
Parser.y
+30
-7
30 additions, 7 deletions
Parser.y
with
53 additions
and
11 deletions
Lexer.x
+
23
−
4
View file @
c69a3807
...
@@ -53,6 +53,13 @@ $digit+ {\p s -> TokenNat p (read s) }
...
@@ -53,6 +53,13 @@ $digit+ {\p s -> TokenNat p (read s) }
\"[$alpha $digit]+\" {\p s -> TokenString p (init.tail $ s) }
\"[$alpha $digit]+\" {\p s -> TokenString p (init.tail $ s) }
AND {\p s -> TokenBoolAND p }
AND {\p s -> TokenBoolAND p }
OR {\p s -> TokenBoolOR 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 }
{
{
...
@@ -94,7 +101,13 @@ data Token =
...
@@ -94,7 +101,13 @@ data Token =
TokenThen AlexPosn |
TokenThen AlexPosn |
TokenEqual AlexPosn |
TokenEqual AlexPosn |
TokenBoolAND AlexPosn |
TokenBoolAND AlexPosn |
TokenBoolOR AlexPosn
TokenBoolOR AlexPosn |
TokenIsSubList AlexPosn |
TokenConcat AlexPosn |
TokenStartsWith AlexPosn |
TokenUnion AlexPosn |
TokenISection AlexPosn |
TokenDifference AlexPosn
deriving (Eq, Show)
deriving (Eq, Show)
...
@@ -135,4 +148,10 @@ pos token = case token of
...
@@ -135,4 +148,10 @@ pos token = case token of
(TokenIf p) -> p
(TokenIf p) -> p
(TokenThen p) -> p
(TokenThen p) -> p
(TokenEqual 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
This diff is collapsed.
Click to expand it.
Parser.y
+
30
−
7
View file @
c69a3807
...
@@ -39,11 +39,7 @@ import CSV
...
@@ -39,11 +39,7 @@ import CSV
x { TokenXProduct _ }
x { TokenXProduct _ }
map { TokenMap _ }
map { TokenMap _ }
xx { TokenXXProduct _ }
xx { TokenXXProduct _ }
-- mapr { TokenMapr _ }
-- '!' { TokenNot _ }
-- zip { TokenZip _ }
contains { TokenContains _ }
contains { TokenContains _ }
-- isSubstring { TokenIsSubstring _ }
isEmpty { TokenIsEmpty _ }
isEmpty { TokenIsEmpty _ }
let { TokenLet _}
let { TokenLet _}
if { TokenIf _}
if { TokenIf _}
...
@@ -52,6 +48,17 @@ import CSV
...
@@ -52,6 +48,17 @@ import CSV
'=' { TokenEqual _}
'=' { TokenEqual _}
or { TokenBoolAND _ }
or { TokenBoolAND _ }
and { TokenBoolOR _ }
and { TokenBoolOR _ }
isSublist {TokenIsSubList _ }
startswith {TokenStartsWith _}
concat {TokenConcat _ }
union {TokenUnion _ }
i'section {TokenISection _ }
difference {TokenDifference _ }
-- isSubstring { TokenIsSubstring _ }
-- zip { TokenZip _ }
-- mapr { TokenMapr _ }
-- '!' { TokenNot _ }
%left FUNCCALL
%left FUNCCALL
...
@@ -90,6 +97,16 @@ Expr :
...
@@ -90,6 +97,16 @@ Expr :
| PredefFunc {PredefFunc $1}
| PredefFunc {PredefFunc $1}
| Expr or Expr {FuncCall (PredefFunc Or) [] [$1,$3]}
| Expr or Expr {FuncCall (PredefFunc Or) [] [$1,$3]}
| Expr and Expr {FuncCall (PredefFunc And) [] [$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}
PredefFunc : isEmpty {IsEmpty}
| filter {Filter}
| filter {Filter}
...
@@ -98,6 +115,12 @@ PredefFunc : isEmpty {IsEmpty}
...
@@ -98,6 +115,12 @@ PredefFunc : isEmpty {IsEmpty}
| map {Map}
| map {Map}
| and {And}
| and {And}
| or {Or}
| or {Or}
| isSublist {isSublist}
| startswith {startswith}
| concat {concat}
| union {union}
| i'section {i'section}
| difference {difference}
-- | zip {Zip}
-- | zip {Zip}
-- | Mapr
-- | Mapr
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment