Commit 3aee11b9 authored by POTTIER Francois's avatar POTTIER Francois

Cleanup of the handling of keywords in the lexer.

parent 94de7b51
......@@ -10,12 +10,6 @@ type t = {
be several files. *)
filenames: string list;
(* A list of keywords that appear in this semantic action, with their
positions. This list is maintained only up to the well-formedness check in
[PartialGrammar.check_keywords]. Thereafter, it is no longer used. So, the
keyword-renaming functions do not bother to update it. *)
pkeywords : keyword Positions.located list;
(* The set of keywords that appear in this semantic action. They can be thought
of as free variables that refer to positions. They must be renamed during
inlining. *)
......@@ -25,17 +19,11 @@ type t = {
(* Creation. *)
let pkeywords_to_keywords pkeywords =
KeywordSet.of_list (List.map Positions.value pkeywords)
let from_stretch s =
let pkeywords = s.Stretch.stretch_keywords in
{
expr = IL.ETextual s;
filenames = [ s.Stretch.stretch_filename ];
pkeywords = pkeywords;
keywords = pkeywords_to_keywords pkeywords;
}
let from_stretch s = {
expr = IL.ETextual s;
filenames = [ s.Stretch.stretch_filename ];
keywords = KeywordSet.of_list s.Stretch.stretch_keywords
}
(* Defining a keyword in terms of other keywords. *)
......@@ -57,7 +45,6 @@ let compose x a1 a2 =
expr = IL.ELet ([ IL.PVar x, a1.expr ], a2.expr);
keywords = KeywordSet.union a1.keywords a2.keywords;
filenames = a1.filenames @ a2.filenames;
pkeywords = [] (* don't bother; already checked *)
}
(* Substitutions, represented as association lists.
......@@ -136,7 +123,6 @@ let rename f phi a =
{
expr = expr;
filenames = a.filenames;
pkeywords = []; (* don't bother *)
keywords = keywords;
}
......@@ -149,9 +135,6 @@ let filenames action =
let keywords action =
action.keywords
let pkeywords action =
action.pkeywords
let print f action =
let module P = Printer.Make (struct let f = f
let locate_stretches = None
......
......@@ -47,9 +47,6 @@ val to_il_expr: t -> IL.expr
the standard library. *)
val filenames: t -> string list
(** [pkeywords a] returns a list of all keyword occurrences in [a]. *)
val pkeywords: t -> keyword Positions.located list
(** [keywords a] is the set of keywords used in the semantic action [a]. *)
val keywords: t -> KeywordSet.t
......
This diff is collapsed.
......@@ -3,7 +3,6 @@ open Syntax
open ConcreteSyntax
open InternalSyntax
open Positions
open Keyword
(* ------------------------------------------------------------------------- *)
(* This adds one declaration [decl], as found in file [filename], to
......@@ -582,24 +581,6 @@ let join grammar pgrammar =
List.fold_left (join_declaration filename) grammar pgrammar.pg_declarations
$$ join_trailer pgrammar.pg_trailer
(* Check that there are not two symbols carrying the same name. *)
let check_keywords producers action =
List.iter (fun keyword ->
match Positions.value keyword with
| Position (RightNamed id, _, _) ->
let found = ref false in
List.iter (fun (ido, _) ->
if ido.value = id then found := true
) producers;
if not !found then
Error.errorp keyword
"%s refers to a nonexistent symbol." id
| Position ((Before | Left), _, _)
| SyntaxError ->
()
) (Action.pkeywords action)
let check_parameterized_grammar_is_well_defined grammar =
(* Every start symbol is defined and has a %type declaration. *)
......@@ -658,7 +639,6 @@ let check_parameterized_grammar_is_well_defined grammar =
(* Check each branch. *)
(fun { pr_producers = producers;
pr_branch_prec_annotation;
pr_action = action
} -> ignore (List.fold_left
(* Check the producers. *)
......@@ -692,8 +672,6 @@ let check_parameterized_grammar_is_well_defined grammar =
) StringSet.empty producers);
check_keywords producers action;
match pr_branch_prec_annotation with
| None -> ()
......
......@@ -14,7 +14,7 @@ type t = {
stretch_linecount : int;
stretch_raw_content : string;
stretch_content : string;
stretch_keywords : Keyword.keyword Positions.located list
stretch_keywords : Keyword.keyword list
}
(* An Objective Caml type is either a stretch (if it was found in some
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment