aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--parsing/cLexer.ml411
-rw-r--r--parsing/cLexer.mli1
2 files changed, 12 insertions, 0 deletions
diff --git a/parsing/cLexer.ml4 b/parsing/cLexer.ml4
index 31025075c..8a8e41956 100644
--- a/parsing/cLexer.ml4
+++ b/parsing/cLexer.ml4
@@ -69,6 +69,15 @@ let ttree_remove ttree str =
in
remove ttree 0
+let ttree_elements ttree =
+ let rec elts tt accu =
+ let accu = match tt.node with
+ | None -> accu
+ | Some s -> CString.Set.add s accu
+ in
+ CharMap.fold (fun _ tt accu -> elts tt accu) tt.branch accu
+ in
+ elts ttree CString.Set.empty
(* Errors occurring while lexing (explained as "Lexer error: ...") *)
@@ -221,6 +230,8 @@ let add_keyword str =
let remove_keyword str =
token_tree := ttree_remove !token_tree str
+let keywords () = ttree_elements !token_tree
+
(* Freeze and unfreeze the state of the lexer *)
type frozen_t = ttree
diff --git a/parsing/cLexer.mli b/parsing/cLexer.mli
index f69d95335..e0fdf8cb5 100644
--- a/parsing/cLexer.mli
+++ b/parsing/cLexer.mli
@@ -9,6 +9,7 @@
val add_keyword : string -> unit
val remove_keyword : string -> unit
val is_keyword : string -> bool
+val keywords : unit -> CString.Set.t
val check_ident : string -> unit
val is_ident : string -> bool