aboutsummaryrefslogtreecommitdiff
path: root/lib/parser.mly
diff options
context:
space:
mode:
authorChimrod <>2023-10-06 08:35:56 +0200
committerChimrod <>2023-10-06 08:35:56 +0200
commit97ab5c9a21166f0bffee482210d69877fd6809fa (patch)
treed1fa44000fa07631edc8924a90020f2cfe637263 /lib/parser.mly
parent40f4dbe7844725e0ab07f03f25c35f55b4699b46 (diff)
Moved qparser and syntax in the library folder
Diffstat (limited to 'lib/parser.mly')
-rw-r--r--lib/parser.mly89
1 files changed, 0 insertions, 89 deletions
diff --git a/lib/parser.mly b/lib/parser.mly
deleted file mode 100644
index 84c1af8..0000000
--- a/lib/parser.mly
+++ /dev/null
@@ -1,89 +0,0 @@
-
-%{
- module T = Qsp_syntax.T
-%}
-
-%parameter<Analyzer: Qsp_syntax.S.Analyzer>
-%start <Analyzer.Location.repr>main
-%on_error_reduce expression instruction unary_operator assignation_operator
-
-%%
-
-main:
- | before_location*
- LOCATION_START
- EOL+
- expressions = line_statement*
- LOCATION_END
- {
- Analyzer.Location.location $loc expressions
- }
-
-before_location:
- | EOL {}
- | COMMENT EOL { }
-
-(* All these statement should terminate with EOL *)
-line_statement:
- | COMMENT EOL+ { Analyzer.Instruction.comment $loc }
- | COLUMN i=IDENT EOL* { Analyzer.Instruction.location $loc i }
- | s = terminated(instruction, line_sep)
- | s = terminated(inline_action, line_sep)
- { s }
- | a = action_bloc(IF, elif_else_body)
- { let loc, expression, statements, loc_s, body = a in
- let elifs, else_ = match body with
- | None -> [], []
- | Some (elifs, else_) -> (elifs, else_)
- in
- Analyzer.Instruction.if_
- loc
- (loc_s, expression, statements)
- ~elifs
- ~else_
- }
- | a = action_bloc(ACT, empty_body)
- { let loc, label, statements, _, _ = a in
- Analyzer.Instruction.act loc ~label statements
- }
-
-(** Represent an instruction which can either be on a single line,
- or created in a block until an END
- *)
-%inline action_bloc(TOKEN, BODY):
- | TOKEN
- e = expression
- COLUMN EOL+
- s = line_statement*
- b = BODY
- END TOKEN?
- line_sep
- { $loc, e, s, $loc(s), b }
-
-empty_body:
- | { None }
-
-elif:
- | ELIF
- e = expression
- COLUMN EOL+
- s = line_statement*
- { $loc, e, s }
-
-else_:
- | ELSE EOL+
- expressions = line_statement*
- { expressions }
- | { [] }
-
-
-elif_else_body:
- | elifs = elif*
- else_ = else_
- { Some (elifs, else_) }
-
-
-%inline line_sep:
- | EOL+
- | AMPERSAND+ EOL*
- {}