summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>1995-07-12 14:28:51 +0000
committerXavier Leroy <xavier.leroy@inria.fr>1995-07-12 14:28:51 +0000
commita2ef5d87140f9284035c4bf12c924dcb5799caec (patch)
tree70ef9067a47e1fc92133945828ffc46ad23e02d3
parent2241e743e252f9c9e94b2c7926b16e4fb317f5b6 (diff)
downloadocaml-a2ef5d87140f9284035c4bf12c924dcb5799caec.tar.gz
Modif des actions des parsers produits par camlyacc: elles prennent
l'env en premier argument et le repassent a peek_val (plus efficace pour le compilateur natif). git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@91 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--stdlib/parsing.ml40
-rw-r--r--stdlib/parsing.mli6
2 files changed, 24 insertions, 22 deletions
diff --git a/stdlib/parsing.ml b/stdlib/parsing.ml
index 60d81b6395..04ee6164f9 100644
--- a/stdlib/parsing.ml
+++ b/stdlib/parsing.ml
@@ -1,23 +1,5 @@
(* The parsing engine *)
-type parse_tables =
- { actions : (unit -> Obj.t) array;
- transl_const : int array;
- transl_block : int array;
- lhs : string;
- len : string;
- defred : string;
- dgoto : string;
- sindex : string;
- rindex : string;
- gindex : string;
- tablesize : int;
- table : string;
- check : string }
-
-exception YYexit of Obj.t
-exception Parse_error
-
open Lexing
(* Internal interface to the parsing engine *)
@@ -38,6 +20,24 @@ type parser_env =
mutable sp : int; (* Saved sp for parse_engine *)
mutable state : int } (* Saved state for parse_engine *)
+type parse_tables =
+ { actions : (parser_env -> Obj.t) array;
+ transl_const : int array;
+ transl_block : int array;
+ lhs : string;
+ len : string;
+ defred : string;
+ dgoto : string;
+ sindex : string;
+ rindex : string;
+ gindex : string;
+ tablesize : int;
+ table : string;
+ check : string }
+
+exception YYexit of Obj.t
+exception Parse_error
+
type parser_input =
Start
| Token_read
@@ -106,7 +106,7 @@ let yyparse tables start lexer lexbuf =
| Raise_parse_error ->
raise Parse_error
| Compute_semantic_action ->
- loop Semantic_action_computed (tables.actions.(env.rule_number) ())
+ loop Semantic_action_computed (tables.actions.(env.rule_number) env)
| Grow_stacks_1 ->
grow_stacks(); loop Stacks_grown_1 (Obj.repr ())
| Grow_stacks_2 ->
@@ -135,7 +135,7 @@ let yyparse tables start lexer lexbuf =
else tables.transl_const.(Obj.magic tok) = curr_char);
raise exn
-let peek_val n =
+let peek_val env n =
Obj.magic env.v_stack.(env.asp - n)
let symbol_start () =
diff --git a/stdlib/parsing.mli b/stdlib/parsing.mli
index e2c17d40c9..99e891ce19 100644
--- a/stdlib/parsing.mli
+++ b/stdlib/parsing.mli
@@ -29,8 +29,10 @@ exception Parse_error
(* The following definitions are used by the generated parsers only.
They are not intended to be used by user programs. *)
+type parser_env
+
type parse_tables =
- { actions : (unit -> Obj.t) array;
+ { actions : (parser_env -> Obj.t) array;
transl_const : int array;
transl_block : int array;
lhs : string;
@@ -48,5 +50,5 @@ exception YYexit of Obj.t
val yyparse :
parse_tables -> int -> (Lexing.lexbuf -> 'a) -> Lexing.lexbuf -> 'b
-val peek_val : int -> 'a
+val peek_val : parser_env -> int -> 'a
val is_current_lookahead: 'a -> bool