aboutsummaryrefslogtreecommitdiff
path: root/lib/syntax
diff options
context:
space:
mode:
authorChimrod <>2023-10-03 18:19:15 +0200
committerChimrod <>2023-10-15 19:04:36 +0200
commit5a18a66763bcc19de117cb83293d7bd25a0ea10c (patch)
tree1627ae50da1a87e5952b5fab21b7290b0555041e /lib/syntax
parent49f69c1ab4d3d8716f30d7bd36a66a4241e16d33 (diff)
Switched the keyword from string to a sum type
Diffstat (limited to 'lib/syntax')
-rw-r--r--lib/syntax/S.ml2
-rw-r--r--lib/syntax/t.ml20
-rw-r--r--lib/syntax/tree.ml4
-rw-r--r--lib/syntax/tree.mli2
-rw-r--r--lib/syntax/type_of.ml2
5 files changed, 11 insertions, 19 deletions
diff --git a/lib/syntax/S.ml b/lib/syntax/S.ml
index 3873eed..63fcd08 100644
--- a/lib/syntax/S.ml
+++ b/lib/syntax/S.ml
@@ -53,7 +53,7 @@ module type Instruction = sig
type expression
type variable
- val call : pos -> string -> expression list -> repr
+ val call : pos -> T.keywords -> expression list -> repr
(** Call for an instruction like [GT] or [*CLR] *)
val location : pos -> string -> repr
diff --git a/lib/syntax/t.ml b/lib/syntax/t.ml
index e9a901d..bf31253 100644
--- a/lib/syntax/t.ml
+++ b/lib/syntax/t.ml
@@ -78,7 +78,7 @@ type function_ =
[@@deriving eq, show]
type keywords =
- | Inclib
+ | IncLib
| Addobj
| Cla
| Clear
@@ -88,10 +88,6 @@ type keywords =
| Cls
| CmdClear
| CopyArr
- | CurActs
- | CurActs'
- | CurLoc
- | CurLoc'
| DelAct
| FreeLib
| DelObj
@@ -100,7 +96,6 @@ type keywords =
| Exit
| Gosub
| Goto
- | IncLib
| Jump
| KillAll
| KillObj
@@ -113,23 +108,20 @@ type keywords =
| Nl'
| P
| P'
+ | Pl
+ | Pl'
| Play
- | Play'
+ | OpenGame
+ | OpenQst
| RefInt
| SaveGame
- | SelAct'
- | SelObj
- | SelObj'
| SetTimer
| ShowActs
| ShowInput
| ShowObjs
| ShowStat
| Unselect
- | UseHTML
- | UserCom'
- | UserText
- | UserText'
| View
| Wait
| XGoto
+[@@deriving eq, show]
diff --git a/lib/syntax/tree.ml b/lib/syntax/tree.ml
index bb31253..ecad1b4 100644
--- a/lib/syntax/tree.ml
+++ b/lib/syntax/tree.ml
@@ -28,7 +28,7 @@ module Ast = struct
| Declaration of ('a * 'a variable * T.assignation_operator * 'a expression)
| Expression of 'a expression
| Comment of 'a
- | Call of 'a * string * 'a expression list
+ | Call of 'a * T.keywords * 'a expression list
| Location of 'a * string
[@@deriving eq, show]
end
@@ -64,7 +64,7 @@ module Instruction :
type expression = Expression.repr
type variable = Expression.variable
- let call : pos -> string -> expression list -> repr =
+ let call : pos -> T.keywords -> expression list -> repr =
fun pos name args -> Ast.Call (pos, name, args)
let location : pos -> string -> repr =
diff --git a/lib/syntax/tree.mli b/lib/syntax/tree.mli
index ca5a639..ad052e9 100644
--- a/lib/syntax/tree.mli
+++ b/lib/syntax/tree.mli
@@ -37,7 +37,7 @@ module Ast : sig
| Declaration of ('a * 'a variable * T.assignation_operator * 'a expression)
| Expression of 'a expression
| Comment of 'a
- | Call of 'a * string * 'a expression list
+ | Call of 'a * T.keywords * 'a expression list
| Location of 'a * string
[@@deriving eq, show]
end
diff --git a/lib/syntax/type_of.ml b/lib/syntax/type_of.ml
index d578700..462f1cd 100644
--- a/lib/syntax/type_of.ml
+++ b/lib/syntax/type_of.ml
@@ -310,7 +310,7 @@ module Instruction = struct
type variable = Expression.variable
(** Call for an instruction like [GT] or [*CLR] *)
- let call : pos -> string -> expression list -> repr =
+ let call : pos -> T.keywords -> expression list -> repr =
fun _pos _ expressions report ->
List.fold_left expressions ~init:report ~f:(fun report expression ->
let result = expression report in