Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PLC CW
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
Jackson
PLC CW
Commits
46e2b399
Commit
46e2b399
authored
2 years ago
by
kwsa1g20
Browse files
Options
Downloads
Patches
Plain Diff
Lexer first draft
parent
139988ab
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tokens.hs
+20012
-0
20012 additions, 0 deletions
Tokens.hs
Tokens.x
+92
-6
92 additions, 6 deletions
Tokens.x
with
20104 additions
and
6 deletions
Tokens.hs
0 → 100644
+
20012
−
0
View file @
46e2b399
This diff is collapsed.
Click to expand it.
Tokens.x
+
92
−
6
View file @
46e2b399
...
...
@@ -11,7 +11,7 @@ tokens :-
$white+ ;
"--".* ;
$digit+ { tok (\p s -> Token
In
t p (read s) )}
$digit+ { tok (\p s -> Token
Digi
t p (read s) )}
\- { tok (\p s -> TokenMinus p )}
\* { tok (\p s -> TokenMult p )}
\/ { tok (\p s -> TokenDiv p )}
...
...
@@ -52,7 +52,7 @@ tokens :-
Bool { tok (\p s -> TokenBool p )}
true { tok (\p s -> TokenBTrue p )}
false { tok (\p s -> TokenBFalse p )}
'['
$alpha [$alpha $digit \_ \']*
']'
{tok (\p s -> TokenGroup p)}
\[
$alpha [$alpha $digit \_ \']*
\]
{tok (\p s -> TokenGroup p
)}
$alpha [$alpha $digit \_ \']* { tok (\p s -> TokenVar p s)}
{
...
...
@@ -62,10 +62,96 @@ tok f p s = f p s
-- The token type:
data TokenType =
Var AlexPosn String |
Int AlexPosn Int
TokenDigit AlexPosn Int |
TokenMinus AlexPosn |
TokenMult AlexPosn |
TokenDiv AlexPosn |
TokenOpBracket AlexPosn |
TokenClBracket AlexPosn |
TokenEq AlexPosn |
TokenPlus AlexPosn |
TokenDot AlexPosn |
TokenLess AlexPosn |
TokenComma AlexPosn |
TokenOSBracket AlexPosn |
TokenClSBracket AlexPosn |
TokenClCurBracket AlexPosn |
TokenOCurBracket AlexPosn |
TokenIf AlexPosn |
TokenThen AlexPosn |
TokenElse AlexPosn |
TokenFor AlexPosn |
TokenEmpty AlexPosn |
TokenCreate AlexPosn |
TokenBlank AlexPosn |
TokenFlipX AlexPosn |
TokenFlipY AlexPosn |
TokenRotate AlexPosn |
TokenSubtile AlexPosn |
TokenConj AlexPosn |
TokenNeg AlexPosn |
TokenSupersize AlexPosn |
TokenStack AlexPosn |
TokenJoin AlexPosn |
TokenShape AlexPosn |
TokenAND AlexPosn |
TokenOR AlexPosn |
TokenNOT AlexPosn |
TokenInt AlexPosn |
TokenTile AlexPosn |
TokenTileG AlexPosn |
TokenBool AlexPosn |
TokenBTrue AlexPosn |
TokenBFalse AlexPosn |
TokenGroup AlexPosn |
TokenVar AlexPosn String
deriving (Eq,Show)
token_posn (Var p _) = p
token_posn (Int p _) = p
token_posn (TokenDigit (AlexPn a l c)_) = show(l) ++ ":" ++ show(c)
token_posn (TokenMinus (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenMult (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenDiv (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenOpBracket (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenClBracket (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenEq (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenPlus (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenDot (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenLess (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenComma (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenOSBracket (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenClSBracket (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenClCurBracket (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenOCurBracket (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenIf (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenThen (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenElse (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenFor (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenCreate (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenBlank (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenFlipX (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenFlipY (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenRotate (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenSubtile (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenConj (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenNeg (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenSupersize (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenStack (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenJoin (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenShape (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenAND (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenOR (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenNOT (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenInt (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenTile (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenTileG (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenBool (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenBTrue (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenBFalse (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenGroup (AlexPn a l c) ) = show(l) ++ ":" ++ show(c)
token_posn (TokenVar (AlexPn a l c) _) = show(l) ++ ":" ++ show(c)
}
\ No newline at end of file
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