diff options
| author | Emilio Jesus Gallego Arias | 2020-02-20 13:56:23 -0500 |
|---|---|---|
| committer | Emilio Jesus Gallego Arias | 2020-02-20 13:56:23 -0500 |
| commit | f748ca04748ef00b85de7f31dc1dc7f0a985ec3f (patch) | |
| tree | 60a101df6b546e33878a9ac0900d1009f666c7be /parsing/notgram_ops.ml | |
| parent | 935101ee1375ed930e993d0e76f2325ade562506 (diff) | |
| parent | a8307ceecc4347593e67cff2044a250b75060f5a (diff) | |
Merge PR #10832: Addressing #6082 and #7766: warning when overriding notation format + new notion of format associated to a given interpretation
Ack-by: maximedenes
Diffstat (limited to 'parsing/notgram_ops.ml')
| -rw-r--r-- | parsing/notgram_ops.ml | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/parsing/notgram_ops.ml b/parsing/notgram_ops.ml index a5ade43295..661f9c5cad 100644 --- a/parsing/notgram_ops.ml +++ b/parsing/notgram_ops.ml @@ -14,21 +14,23 @@ open Util open Notation open Notation_gram -(* Uninterpreted notation levels *) +(* Register the level of notation for parsing and printing + (we also register a precomputed parsing rule) *) let notation_level_map = Summary.ref ~name:"notation_level_map" NotationMap.empty -let declare_notation_level ?(onlyprint=false) ntn level = +let declare_notation_level ntn ~onlyprint parsing_rule level = try - let (level,onlyprint) = NotationMap.find ntn !notation_level_map in - if not onlyprint then anomaly (str "Notation " ++ pr_notation ntn ++ str " is already assigned a level.") + let _ = NotationMap.find ntn !notation_level_map in + anomaly (str "Notation " ++ pr_notation ntn ++ str " is already assigned a level.") with Not_found -> - notation_level_map := NotationMap.add ntn (level,onlyprint) !notation_level_map + notation_level_map := NotationMap.add ntn (onlyprint,parsing_rule,level) !notation_level_map -let level_of_notation ?(onlyprint=false) ntn = - let (level,onlyprint') = NotationMap.find ntn !notation_level_map in - if onlyprint' && not onlyprint then raise Not_found; - level +let level_of_notation ntn = + NotationMap.find ntn !notation_level_map + +let get_defined_notations () = + NotationSet.elements @@ NotationMap.domain !notation_level_map (**********************************************************************) (* Equality *) |
