diff options
author | Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr> | 2016-05-11 15:33:47 +0200 |
---|---|---|
committer | Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr> | 2016-05-11 19:09:19 +0200 |
commit | 16d0e6f7cfc453944874cc1665a0eb4db8ded354 (patch) | |
tree | 56ba9db96c8eed38d1605bfce5d389d9c45c057a /parsing/pcoq.mli | |
parent | 85753a0bdb6183604a78232c4c32fd15f7a21a2a (diff) |
Making the grammar command extend API purely functional.
Instead of leaving the responsibility of extending the grammar to the caller,
we ask for a list of extensions in the return value of the function.
Diffstat (limited to 'parsing/pcoq.mli')
-rw-r--r-- | parsing/pcoq.mli | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/parsing/pcoq.mli b/parsing/pcoq.mli index 1d076e295..ed82607dd 100644 --- a/parsing/pcoq.mli +++ b/parsing/pcoq.mli @@ -241,12 +241,18 @@ type 'a grammar_command (** Type of synchronized parsing extensions. The ['a] type should be marshallable. *) -type 'a grammar_extension = 'a -> GramState.t -> int * GramState.t +type extend_rule = +| ExtendRule : 'a Gram.entry * gram_reinit option * 'a extend_statment -> extend_rule + +type 'a grammar_extension = 'a -> GramState.t -> extend_rule list * GramState.t +(** Grammar extension entry point. Given some ['a] and a current grammar state, + such a function must produce the list of grammar extensions that will be + applied in the same order and kept synchronized w.r.t. the summary, together + with a new state. It should be pure. *) val create_grammar_command : string -> 'a grammar_extension -> 'a grammar_command -(** Create a new grammar-modifying command with the given name. The function - should modify the parser state and return the number of grammar extensions - performed. *) +(** Create a new grammar-modifying command with the given name. The extension + function is called to generate the rules for a given data. *) val extend_grammar_command : 'a grammar_command -> 'a -> unit (** Extend the grammar of Coq with the given data. *) |