aboutsummaryrefslogtreecommitdiff
path: root/lib/qparser
diff options
context:
space:
mode:
authorChimrod <>2023-10-22 07:14:20 +0200
committerChimrod <>2023-10-25 17:56:30 +0200
commit2a2198e91063684a1b19974acc19c25b55266724 (patch)
treeb43e4b1b62c61fd828a53d6b261c790ffa797ae0 /lib/qparser
parent2cad3abf180c14e0c026033d65f4fb895b5348f7 (diff)
Refactoring the API
Diffstat (limited to 'lib/qparser')
-rw-r--r--lib/qparser/parser.mly10
-rw-r--r--lib/qparser/qsp_expression.mly2
-rw-r--r--lib/qparser/qsp_instruction.mly14
3 files changed, 11 insertions, 15 deletions
diff --git a/lib/qparser/parser.mly b/lib/qparser/parser.mly
index 63b9577..d84e534 100644
--- a/lib/qparser/parser.mly
+++ b/lib/qparser/parser.mly
@@ -1,4 +1,3 @@
-
%{
module T = Qsp_syntax.T
open StdLabels
@@ -6,8 +5,7 @@
type action_block =
{ loc : Qsp_syntax.S.pos
; expression :
- Qsp_syntax.Report.t list
- -> Analyzer.Expression.t' * Qsp_syntax.Report.t list
+ Analyzer.Expression.t' * Qsp_syntax.Report.t list
; body : Analyzer.Instruction.t Qsp_syntax.S.repr list
; pos : Qsp_syntax.S.pos
; clauses : (
@@ -21,7 +19,7 @@
%}
%parameter<Analyzer: Qsp_syntax.S.Analyzer>
-%start <Analyzer.Location.t Qsp_syntax.S.repr>main
+%start <(Analyzer.Location.t * Qsp_syntax.Report.t list) Qsp_syntax.S.repr>main
%on_error_reduce expression instruction unary_operator assignation_operator
%%
@@ -77,7 +75,7 @@ line_statement:
END TOKEN?
line_sep
{
- let expression = Helper.v e in
+ let expression = Helper.v' e in
let clauses = match b with
| None -> None
| Some (elifs, clauses) ->
@@ -86,7 +84,7 @@ line_statement:
| _ ->
List.map elifs
~f:(fun ((pos:Qsp_syntax.S.pos), e, instructions) ->
- let e = Helper.v e in
+ let e = Helper.v' e in
(pos, e, instructions)
)
diff --git a/lib/qparser/qsp_expression.mly b/lib/qparser/qsp_expression.mly
index 799be31..362c717 100644
--- a/lib/qparser/qsp_expression.mly
+++ b/lib/qparser/qsp_expression.mly
@@ -1,5 +1,3 @@
-(* %start <(Elements.pos) Elements.exppression>expression *)
-
%%
%public arguments(X):
diff --git a/lib/qparser/qsp_instruction.mly b/lib/qparser/qsp_instruction.mly
index 8272cff..e8f5a77 100644
--- a/lib/qparser/qsp_instruction.mly
+++ b/lib/qparser/qsp_instruction.mly
@@ -18,7 +18,7 @@ argument(X):
%public inline_action:
| a = onliner(ACT)
{ let loc, label, statements, _, _ = a in
- let label = Helper.v label in
+ let label = Helper.v' label in
Analyzer.Instruction.act loc ~label statements
}
| a = onliner(IF)
@@ -30,7 +30,7 @@ argument(X):
| Some instructions -> Some ($loc(else_opt), [ instructions ]) in
Analyzer.Instruction.if_
loc
- (loc_s, Helper.v expr, statements)
+ (loc_s, Helper.v' expr, statements)
~elifs
~else_
}
@@ -42,21 +42,21 @@ argument(X):
Analyzer.Instruction.if_
loc
- (loc_s, Helper.v expr, statements)
+ (loc_s, Helper.v' expr, statements)
~elifs
~else_
}
single_instruction:
| expr = expression
{
- let expr = Helper.v expr in
+ let expr = Helper.v' expr in
Analyzer.Instruction.expression expr
}
| e = let_assignation { e }
| k = keyword
args = argument(expression)
{
- let args = List.map args ~f:(Helper.v) in
+ let args = List.map args ~f:(Helper.v') in
Analyzer.Instruction.call $loc k args
}
@@ -69,8 +69,8 @@ let_assignation:
op = assignation_operator
value = expression
{
- let variable = Helper.variable variable
- and value = Helper.v value in
+ let variable = Helper.variable' variable
+ and value = Helper.v' value in
Analyzer.Instruction.assign $loc variable op value
}