Skip to content

Commit

Permalink
Co-authored-by: David Yang <david518yang@users.noreply.github.com>
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Hwang <mokawop@users.noreply.github.com>
Co-authored-by: Owen Sheow <osheow@users.noreply.github.com>
  • Loading branch information
Mattmart42 committed Apr 26, 2024
2 parents 3c9cfaa + 3247088 commit 5a1318a
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 270 deletions.
15 changes: 9 additions & 6 deletions src/MODE.ohm
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,26 @@ MODE {
IfStmt = if Exp Block else Block --long
| if Exp Block else IfStmt --elsif
| if Exp Block --short
| Ternary --ternary
LoopStmt = WhileStmt | ForStmt
WhileStmt = while Exp Block
ForStmt = for id in Exp Block --iterable
| for id in Exp ".." Exp Block --range
Block = "{" Stmt+ "}"
BreakStmt = break ";"
Ternary = if "(" Exp ")" yield Exp otherwise Exp ";"
Ternary = if "(" Exp ")" yield Exp otherwise Exp
Lambda = "(" (id ",")* id ")" "->" Exp --lambda
ClassDef = class id "{" Field* "}" --classdef
ClassDef = class id "{" Field* "}" ";"
Field = id ":" Type ";"
FunDecl = func id Params (":" Type)? Block
Params = "(" ListOf<Param, ","> ")"
Param = id ":" Type

Type = Type "[" "]" --arr
| types --primitive
Exp = Exp1 relop Exp1 --comparison
Type = Type "[" "]" --arr
| types --primitive
| id --id
Exp = Ternary
| Exp0
Exp0 = Exp1 relop Exp1 --comparison
| Exp1
Exp1 = Exp1 ("+" | "-") Term --binary
| Term
Expand All @@ -48,6 +50,7 @@ MODE {
Primary = Primary_id "(" ListOf<Exp, ","> ")" --call
| float --num
| int --int
| Primary "." id --member
| id --id
| string ~mut --string
| true ~mut --true
Expand Down

0 comments on commit 5a1318a

Please sign in to comment.