summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-10-24 17:25:47 +0100
committerAlasdair Armstrong2018-10-24 18:00:19 +0100
commit5471af45fd04169eb184371dcd8f791e507eab6f (patch)
treeeb87790c74b3ac6076f4ef4f567055a3836ac962 /editors
parente489f2d37efa4c320004d35c3025c77e0a0c60d0 (diff)
Add constraint synonyms
Currently not enabled by default, the flag -Xconstraint_synonyms enables them For generating constraints in ASL parser, we want to be able to give names to the constraints that we attach to certain variables. It's slightly awkward right now when constraints get long complicated because the entire constraint always has to be typed out in full whenever it appears, and there's no way to abstract away from that. This adds constraint synonyms, which work much like type synonyms except for constraints, e.g. constraint Size('n) = 'n in {1, 2, 4, 8} | 128 <= 'n <= 256 these constraints can then be used instead of the full constraint, e.g. val f : forall 'n, where Size('n). int('n) -> unit Unfortunatly we need to have a keyword to 'call' the constraint synonym otherwise the grammer stops being LR(1). This could be resolved by parsing all constraints into Parse_ast.atyp and then de-sugaring them into constraints, which is what happens for n-expressions already, but that would require quite a bit of work on the parser. To avoid this forcing changes to any other parts of Sail, the intended invariant is that all constraints appearing anywhere in a type-checked AST have no constraint synonyms, so they don't have to worry about matching on NC_app, or calling Env.expand_typquant_synonyms (which isn't even exported for this reason).
Diffstat (limited to 'editors')
-rw-r--r--editors/sail2-mode.el2
1 files changed, 1 insertions, 1 deletions
diff --git a/editors/sail2-mode.el b/editors/sail2-mode.el
index 05d3eb60..de8c3d11 100644
--- a/editors/sail2-mode.el
+++ b/editors/sail2-mode.el
@@ -9,7 +9,7 @@
"overload" "cast" "sizeof" "constraint" "default" "assert" "newtype" "from"
"pure" "infixl" "infixr" "infix" "scattered" "end" "try" "catch" "and" "to"
"throw" "clause" "as" "repeat" "until" "while" "do" "foreach" "bitfield"
- "mapping"))
+ "mapping" "where"))
(defconst sail2-kinds
'("Int" "Type" "Order" "inc" "dec"