Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
<lexer> | ||
<config> | ||
<name>Alloy</name> | ||
<alias>alloy</alias> | ||
<filename>*.als</filename> | ||
<mime_type>text/x-alloy</mime_type> | ||
<dot_all>true</dot_all> | ||
</config> | ||
<rules> | ||
<state name="sig"> | ||
<rule pattern="(extends)\b"><token type="Keyword"/><pop depth="1"/></rule> | ||
<rule pattern="[a-zA-Z_][\w]*"*"><token type="Name"/></rule> | ||
<rule pattern="[^\S\n]+"><token type="TextWhitespace"/></rule> | ||
<rule pattern=","><token type="Punctuation"/></rule> | ||
<rule pattern="\{"><token type="Operator"/><pop depth="1"/></rule> | ||
</state> | ||
<state name="module"> | ||
<rule pattern="[^\S\n]+"><token type="TextWhitespace"/></rule> | ||
<rule pattern="[a-zA-Z_][\w]*"*"><token type="Name"/><pop depth="1"/></rule> | ||
</state> | ||
<state name="fun"> | ||
<rule pattern="[^\S\n]+"><token type="TextWhitespace"/></rule> | ||
<rule pattern="\{"><token type="Operator"/><pop depth="1"/></rule> | ||
<rule pattern="[a-zA-Z_][\w]*"*"><token type="Name"/><pop depth="1"/></rule> | ||
</state> | ||
<state name="fact"> | ||
<rule><include state="fun"/></rule> | ||
<rule pattern=""\b(\\\\|\\[^\\]|[^"\\])*""><token type="LiteralString"/><pop depth="1"/></rule> | ||
</state> | ||
<state name="root"> | ||
<rule pattern="--.*?$"><token type="CommentSingle"/></rule> | ||
<rule pattern="//.*?$"><token type="CommentSingle"/></rule> | ||
<rule pattern="/\*.*?\*/"><token type="CommentMultiline"/></rule> | ||
<rule pattern="[^\S\n]+"><token type="TextWhitespace"/></rule> | ||
<rule pattern="(module|open)(\s+)"><bygroups><token type="KeywordNamespace"/><token type="TextWhitespace"/></bygroups><push state="module"/></rule> | ||
<rule pattern="(sig|enum)(\s+)"><bygroups><token type="KeywordDeclaration"/><token type="TextWhitespace"/></bygroups><push state="sig"/></rule> | ||
<rule pattern="(iden|univ|none)\b"><token type="KeywordConstant"/></rule> | ||
<rule pattern="(int|Int)\b"><token type="KeywordType"/></rule> | ||
<rule pattern="(var|this|abstract|extends|set|seq|one|lone|let)\b"><token type="Keyword"/></rule> | ||
<rule pattern="(all|some|no|sum|disj|when|else)\b"><token type="Keyword"/></rule> | ||
<rule pattern="(run|check|for|but|exactly|expect|as|steps)\b"><token type="Keyword"/></rule> | ||
<rule pattern="(always|after|eventually|until|release)\b"><token type="Keyword"/></rule> | ||
<rule pattern="(historically|before|once|since|triggered)\b"><token type="Keyword"/></rule> | ||
<rule pattern="(and|or|implies|iff|in)\b"><token type="OperatorWord"/></rule> | ||
<rule pattern="(fun|pred|assert)(\s+)"><bygroups><token type="Keyword"/><token type="TextWhitespace"/></bygroups><push state="fun"/></rule> | ||
<rule pattern="(fact)(\s+)"><bygroups><token type="Keyword"/><token type="TextWhitespace"/></bygroups><push state="fact"/></rule> | ||
<rule pattern="!|#|&&|\+\+|<<|>>|>=|<=>|<=|\.\.|\.|->"><token type="Operator"/></rule> | ||
<rule pattern="[-+/*%=<>&!^|~{}\[\]().\';]"><token type="Operator"/></rule> | ||
<rule pattern="[a-zA-Z_][\w]*"*"><token type="Name"/></rule> | ||
<rule pattern="[:,]"><token type="Punctuation"/></rule> | ||
<rule pattern="[0-9]+"><token type="LiteralNumberInteger"/></rule> | ||
<rule pattern=""\b(\\\\|\\[^\\]|[^"\\])*""><token type="LiteralString"/></rule> | ||
<rule pattern="\n"><token type="TextWhitespace"/></rule> | ||
</state> | ||
</rules> | ||
</lexer> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
sig Node { | ||
edges: set Node | ||
} | ||
|
||
fact "Connected graph" { | ||
some n: Node | n.*edges = Node | ||
} | ||
|
||
fact "No self edges" { | ||
no iden & edges | ||
} | ||
|
||
one sig Ball { | ||
-- note the var | ||
var loc: Node | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
[ | ||
{"type":"KeywordDeclaration","value":"sig"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"Node"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"{"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"Name","value":"edges"}, | ||
{"type":"Punctuation","value":":"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Keyword","value":"set"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"Node"}, | ||
{"type":"TextWhitespace","value":"\n"}, | ||
{"type":"Operator","value":"}"}, | ||
{"type":"TextWhitespace","value":"\n\n"}, | ||
{"type":"Keyword","value":"fact"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"LiteralString","value":"\"Connected graph\""}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"{"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"Keyword","value":"some"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"n"}, | ||
{"type":"Punctuation","value":":"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"Node"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"|"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"n"}, | ||
{"type":"Operator","value":".*"}, | ||
{"type":"Name","value":"edges"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"="}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"Node"}, | ||
{"type":"TextWhitespace","value":"\n"}, | ||
{"type":"Operator","value":"}"}, | ||
{"type":"TextWhitespace","value":"\n\n"}, | ||
{"type":"Keyword","value":"fact"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"LiteralString","value":"\"No self edges\""}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"{"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"Keyword","value":"no"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"KeywordConstant","value":"iden"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"\u0026"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"edges"}, | ||
{"type":"TextWhitespace","value":"\n"}, | ||
{"type":"Operator","value":"}"}, | ||
{"type":"TextWhitespace","value":"\n\n"}, | ||
{"type":"Keyword","value":"one"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"KeywordDeclaration","value":"sig"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"Ball"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Operator","value":"{"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"CommentSingle","value":"-- note the var"}, | ||
{"type":"TextWhitespace","value":"\n "}, | ||
{"type":"Keyword","value":"var"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"loc"}, | ||
{"type":"Punctuation","value":":"}, | ||
{"type":"TextWhitespace","value":" "}, | ||
{"type":"Name","value":"Node"}, | ||
{"type":"TextWhitespace","value":"\n"}, | ||
{"type":"Operator","value":"}"}, | ||
{"type":"TextWhitespace","value":"\n"} | ||
] |