aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/qparser/idents.ml59
-rw-r--r--lib/syntax/get_type.ml2
-rw-r--r--lib/syntax/t.ml4
-rw-r--r--lib/syntax/type_of.ml2
-rw-r--r--test/syntax.ml17
5 files changed, 41 insertions, 43 deletions
diff --git a/lib/qparser/idents.ml b/lib/qparser/idents.ml
index 06bf32a..f96dd95 100644
--- a/lib/qparser/idents.ml
+++ b/lib/qparser/idents.ml
@@ -3,6 +3,20 @@ module T = Qsp_syntax.T
let keyword_table = Hashtbl.create 53
+(* Thoses ident are considered as variables and not declared here
+ "BACKIMAGE",
+ "$BACKIMAGE",
+ "BCOLOR",
+ "DEBUG",
+ "DISABLESCROLL"
+ "DISABLESUBEX",
+ "FCOLOR",
+ "$FNAME",
+ "FSIZE",
+ "GC",
+ "LCOLOR",
+ "NOSAVE"
+*)
let _ =
List.iter
(fun (kwd, tok) -> Hashtbl.add keyword_table kwd tok)
@@ -15,11 +29,7 @@ let _ =
("AND", AND);
("ARRCOMP", FUNCTION T.Arrcomp);
("ARRPOS", FUNCTION T.Arrpos);
- ("ARRSIZE", FUNCTION T.Arrsize)
- (*
- ; "BACKIMAGE", KEYWORD "BACKIMAGE"
- ; "$BACKIMAGE", KEYWORD "BACKIMAGE"
- ; "BCOLOR", KEYWORD "BCOLOR" *);
+ ("ARRSIZE", FUNCTION T.Arrsize);
("CLA", KEYWORD T.Cla);
("CLEAR", KEYWORD T.Clear);
("*CLEAR", KEYWORD T.Clear');
@@ -35,21 +45,14 @@ let _ =
("CURACTS", IDENT "CURACTS");
("$CURACTS", IDENT "$CURACTS");
("CURLOC", IDENT "CURLOC");
- ("$CURLOC", IDENT "$CURLOC")
- (*
- ; "DEBUG", KEYWORD "DEBUG"
-*);
+ ("$CURLOC", IDENT "$CURLOC");
("DELACT", KEYWORD T.DelAct);
("DEL ACT", KEYWORD T.DelAct);
("DELLIB", KEYWORD T.FreeLib);
("DELOBJ", KEYWORD T.DelObj);
("DEL OBJ", KEYWORD T.DelObj);
("DESC", FUNCTION T.Desc);
- ("$DESC", FUNCTION T.Desc')
- (*
- ; "DISABLESCROLL", KEYWORD "DISABLESCROLL"
- ; "DISABLESUBEX", KEYWORD "DISABLESUBEX"
-*);
+ ("$DESC", FUNCTION T.Desc');
("DYNAMIC", KEYWORD T.Dynamic);
("DYNEVAL", FUNCTION T.Dyneval);
("$DYNEVAL", FUNCTION T.Dyneval');
@@ -57,23 +60,14 @@ let _ =
("ELSEIF", ELIF);
("END", END);
("EXEC", KEYWORD T.Exec);
- ("EXIT", KEYWORD T.Exit)
- (*
- ; "FCOLOR", KEYWORD "FCOLOR"
- ; "$FNAME", KEYWORD "$FNAME"
-*);
- ("FREELIB", KEYWORD T.FreeLib)
- (*
- ; "FSIZE", KEYWORD "FSIZE"
-*);
+ ("EXIT", KEYWORD T.Exit);
+ ("FREELIB", KEYWORD T.FreeLib);
("FUNC", FUNCTION T.Func);
("$FUNC", FUNCTION T.Func');
("GETOBJ", FUNCTION T.Getobj);
("$GETOBJ", FUNCTION T.Getobj');
("GOSUB", KEYWORD T.Gosub);
- ("GOTO", KEYWORD T.Goto) (*
- ; "GC", KEYWORD "GC"
-*);
+ ("GOTO", KEYWORD T.Goto);
("GS", KEYWORD T.Gosub);
("GT", KEYWORD T.Goto);
("IF", IF);
@@ -91,10 +85,7 @@ let _ =
("KILLQST", KEYWORD T.FreeLib);
("KILLVAR", KEYWORD T.KillVar);
("LCASE", FUNCTION T.Lcase);
- ("$LCASE", FUNCTION T.Lcase')
- (*
- ; "LCOLOR", KEYWORD "LCOLOR"
-*);
+ ("$LCASE", FUNCTION T.Lcase');
("LEN", FUNCTION T.Len);
("LET", LET);
("LOC", FUNCTION T.Loc);
@@ -112,9 +103,7 @@ let _ =
("MSG", KEYWORD T.Msg);
("NL", KEYWORD T.Nl);
("*NL", KEYWORD T.Nl');
- ("NO", NO) (*
- ; "NOSAVE", KEYWORD "NOSAVE"
-*);
+ ("NO", NO);
("OBJ", OBJ);
("$ONACTSEL", IDENT "$ONACTSEL");
("$ONGLOAD", IDENT "$ONGLOAD");
@@ -150,8 +139,8 @@ let _ =
("SHOWINPUT", KEYWORD T.ShowInput);
("SHOWOBJS", KEYWORD T.ShowObjs);
("SHOWSTAT", KEYWORD T.ShowStat);
- ("STATTXT", FUNCTION T.Stattxt);
- ("$STATTXT", FUNCTION T.Stattxt');
+ ("STATTXT", IDENT "STATTXT");
+ ("$STATTXT", IDENT "$STATTXT");
("STR", FUNCTION T.Str);
("$STR", FUNCTION T.Str');
("STRCOMP", FUNCTION T.Strcomp);
diff --git a/lib/syntax/get_type.ml b/lib/syntax/get_type.ml
index 4dee125..c8af9ec 100644
--- a/lib/syntax/get_type.ml
+++ b/lib/syntax/get_type.ml
@@ -85,8 +85,6 @@ let function_ : S.pos -> T.function_ -> t list -> t =
| Rgb -> Raw Integer
| Rnd -> Raw Integer
| Selact -> Variable String
- | Stattxt -> Variable String
- | Stattxt' -> Variable String
| Str | Str' -> Raw String
| Strcomp -> Raw Bool
| Strfind -> Variable String
diff --git a/lib/syntax/t.ml b/lib/syntax/t.ml
index 697b18e..cb9c7ce 100644
--- a/lib/syntax/t.ml
+++ b/lib/syntax/t.ml
@@ -70,8 +70,6 @@ type function_ =
| Rgb
| Rnd
| Selact
- | Stattxt
- | Stattxt'
| Str
| Str'
| Strcomp
@@ -128,6 +126,8 @@ type keywords =
| ShowInput
| ShowObjs
| ShowStat
+ | Stattxt
+ | Stattxt'
| Unselect
| View
| Wait
diff --git a/lib/syntax/type_of.ml b/lib/syntax/type_of.ml
index 4344a11..239717c 100644
--- a/lib/syntax/type_of.ml
+++ b/lib/syntax/type_of.ml
@@ -273,8 +273,6 @@ module TypedExpression = struct
let report = Helper.compare_args pos [] types report in
(default, report)
| Selact -> (default, report)
- | Stattxt -> (default, report)
- | Stattxt' -> (default, report)
| Str | Str' ->
let expected = Helper.[ Variable (Fixed Integer) ] in
let report = Helper.compare_args pos expected types report in
diff --git a/test/syntax.ml b/test/syntax.ml
index f64129f..3b7c2f9 100644
--- a/test/syntax.ml
+++ b/test/syntax.ml
@@ -596,7 +596,7 @@ let test_if_inline_act () =
let test_if_multiline () =
_test_instruction {|if 1 _
- and hour >= 8: 1|}
+ and _hour >= 8: 1|}
[
Ast.If
{
@@ -611,7 +611,7 @@ let test_if_multiline () =
( _position,
Qsp_syntax.T.Gte,
Ast.Ident
- { Ast.pos = _position; name = "HOUR"; index = None },
+ { Ast.pos = _position; name = "_HOUR"; index = None },
Ast.Integer (_position, "8") ) ),
[ Tree.Ast.Expression (Tree.Ast.Integer (_position, "1")) ] );
elifs = [];
@@ -884,6 +884,18 @@ let minus_operator () =
Tree.Ast.Integer (_position, "7") ));
]
+(** STATTXT was considered as a function and raised an error in the syntax *)
+let test_stattxt () =
+ _test_instruction "$value = $stattxt"
+ [
+ Tree.Ast.Declaration
+ ( _position,
+ { Tree.Ast.pos = _position; name = "$VALUE"; index = None },
+ T.Eq',
+ Tree.Ast.Ident
+ { Tree.Ast.pos = _position; name = "$STATTXT"; index = None } );
+ ]
+
let test =
( "Syntax",
[
@@ -952,4 +964,5 @@ let test =
Alcotest.test_case "inline if else if" `Quick test_mutiple_inline_ifs;
Alcotest.test_case "Precedence7" `Quick test_precedence7;
Alcotest.test_case "Precedence8" `Quick test_precedence8;
+ Alcotest.test_case "stattxt" `Quick test_stattxt;
] )