Skip to content
Snippets Groups Projects
Commit 9faf8529 authored by plw1g21's avatar plw1g21
Browse files

Bro we are almost there

We get to the Julio file
parent 4bc97ae4
No related branches found
No related tags found
No related merge requests found
No preview for this file type
This diff is collapsed.
No preview for this file type
...@@ -30,8 +30,8 @@ import Tokens ...@@ -30,8 +30,8 @@ import Tokens
or {TOr $$} or {TOr $$}
subtile {TSubtile $$} subtile {TSubtile $$}
gibb {TGibb $$} gibb {TGibb $$}
true {TBool (AlexPn x y z) $$} true {TBoolean (AlexPn x y z) $$}
false {TBool (AlexPn x y z) $$} false {TBoolean (AlexPn x y z) $$}
lt {TLessThan $$} lt {TLessThan $$}
gt {TGreaterThan $$} gt {TGreaterThan $$}
eq {TIsEqual $$} eq {TIsEqual $$}
...@@ -44,7 +44,7 @@ import Tokens ...@@ -44,7 +44,7 @@ import Tokens
print {TPrint $$} print {TPrint $$}
'+' {TAdd $$} '+' {TAdd $$}
'-' {TSub $$} '-' {TSub $$}
nothing {TNothing $$} none {TNone $$}
%left 'joinH' %left 'joinH'
%left 'joinV' %left 'joinV'
...@@ -83,6 +83,7 @@ import Tokens ...@@ -83,6 +83,7 @@ import Tokens
ExpSeq: Exp ';' ExpSeq { ExpSeq $1 $3} ExpSeq: Exp ';' ExpSeq { ExpSeq $1 $3}
| Exp ';' { Exp $1} | Exp ';' { Exp $1}
| none {None}
Exp : repeat int '{' ExpSeq '}' { Repeat $2 $4} Exp : repeat int '{' ExpSeq '}' { Repeat $2 $4}
| joinH Exp Exp { JoinH $2 $3} | joinH Exp Exp { JoinH $2 $3}
...@@ -106,10 +107,10 @@ Exp : repeat int '{' ExpSeq '}' { Repeat $2 $4} ...@@ -106,10 +107,10 @@ Exp : repeat int '{' ExpSeq '}' { Repeat $2 $4}
| true { Bool True } | true { Bool True }
| false { Bool False } | false { Bool False }
| lt Exp Exp { LessThan $2 $3 } | lt Exp Exp { LessThan $2 $3 }
| gt Exp Exp { GreaterThan $1 $3 } | gt Exp Exp { GreaterThan $2 $3 }
| eq Exp Exp {IsEqual $2 $3} | eq Exp Exp {IsEqual $2 $3}
| neq Exp Exp {NotEqual $2 $3} | neq Exp Exp {NotEqual $2 $3}
| if Exp '{' ExpSeq '}' else '{' ConditionExp '}' {If $2 $4 $8} | if Exp '{' ExpSeq '}' else '{' ExpSeq '}' {If $2 $4 $8}
| while Exp '{' ExpSeq '}' {While $2 $4 } | while Exp '{' ExpSeq '}' {While $2 $4 }
| width Exp {Width $2} | width Exp {Width $2}
| height Exp {Height $2} | height Exp {Height $2}
...@@ -117,14 +118,13 @@ Exp : repeat int '{' ExpSeq '}' { Repeat $2 $4} ...@@ -117,14 +118,13 @@ Exp : repeat int '{' ExpSeq '}' { Repeat $2 $4}
| '+' Exp Exp {Add $2 $3} | '+' Exp Exp {Add $2 $3}
| '-' Exp Exp {Sub $2 $3} | '-' Exp Exp {Sub $2 $3}
ConditionExp: nothing {ConditionExp Nothing} {
{ ExpSeq {ConditionExp $1}
parseError :: [Token] -> a parseError :: [Token] -> a
parseError (x:xs) = error ("Parse error at "++ (tokenPosn x)) parseError (x:xs) = error ("Parse error at "++ (tokenPosn x))
data ExpSeq = ExpSeq Exp ExpSeq data ExpSeq = ExpSeq Exp ExpSeq
| Exp Exp | Exp Exp
| None
deriving Show deriving Show
data Exp = Repeat Int ExpSeq data Exp = Repeat Int ExpSeq
...@@ -157,6 +157,5 @@ data Exp = Repeat Int ExpSeq ...@@ -157,6 +157,5 @@ data Exp = Repeat Int ExpSeq
| Add Exp Exp | Add Exp Exp
| Sub Exp Exp | Sub Exp Exp
| If Exp ExpSeq ExpSeq | If Exp ExpSeq ExpSeq
| Nothing
deriving Show deriving Show
} }
\ No newline at end of file
No preview for this file type
This diff is collapsed.
No preview for this file type
...@@ -22,7 +22,7 @@ $white+ ; ...@@ -22,7 +22,7 @@ $white+ ;
"joinH" { \p s -> TJoinH p } "joinH" { \p s -> TJoinH p }
"joinV" { \p s -> TJoinV p } "joinV" { \p s -> TJoinV p }
";" { \p s -> TSemiColon p } ";" { \p s -> TSemiColon p }
"nothing" { \p s -> TNothing p} "none" { \p s -> TNone p}
"not" { \p s -> TNot p } "not" { \p s -> TNot p }
"rotate" { \p s -> TRotate p } "rotate" { \p s -> TRotate p }
"scale" {\ p s -> TScale p } "scale" {\ p s -> TScale p }
...@@ -90,7 +90,7 @@ data Token = ...@@ -90,7 +90,7 @@ data Token =
|TAdd AlexPosn |TAdd AlexPosn
|TSub AlexPosn |TSub AlexPosn
|TBoolean AlexPosn Bool |TBoolean AlexPosn Bool
|TNothing AlexPosn |TNone AlexPosn
deriving (Eq, Show) deriving (Eq, Show)
tokenPosn :: Token -> String tokenPosn :: Token -> String
...@@ -129,5 +129,5 @@ tokenPosn (TPrint(AlexPn a l c)) = show(l) ++ ":" ++ show(c) ...@@ -129,5 +129,5 @@ tokenPosn (TPrint(AlexPn a l c)) = show(l) ++ ":" ++ show(c)
tokenPosn (TAdd (AlexPn a l c)) = show(l) ++ ":" ++ show(c) tokenPosn (TAdd (AlexPn a l c)) = show(l) ++ ":" ++ show(c)
tokenPosn (TSub (AlexPn a l c)) = show(l) ++ ":" ++ show(c) tokenPosn (TSub (AlexPn a l c)) = show(l) ++ ":" ++ show(c)
tokenPosn (TBoolean (AlexPn a l c) x) = show(l) ++ ":" ++ show(c) tokenPosn (TBoolean (AlexPn a l c) x) = show(l) ++ ":" ++ show(c)
tokenPosn (TNothing (AlexPn a l c)) = show(l) ++ ":" ++ show(c) tokenPosn (TNone (AlexPn a l c)) = show(l) ++ ":" ++ show(c)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment