Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Alloy DSL for Alloy 6 #1963

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
089a723
Make default style meet WCAG AA
not-my-profile Nov 2, 2021
970dc34
Regenerate HTML test files.
Anteru Nov 13, 2021
622609f
Improve NSIS lexer.
Anteru Nov 13, 2021
cd897be
Improve HexdumpLexer.
Anteru Nov 13, 2021
fe3e101
Fix #1896.
Anteru Nov 13, 2021
6fcc278
Handle ' and " in the repeated token script.
Anteru Nov 13, 2021
272b1fe
Update CHANGES.
Anteru Nov 13, 2021
28c9d43
Fix #1479.
Anteru Nov 13, 2021
6dd14ca
Update CHANGES.
Anteru Nov 13, 2021
8555313
Promote styles meeting WCAG AA in styles gallery (#1954)
not-my-profile Nov 14, 2021
ea12e00
Fix docs build.
Anteru Nov 14, 2021
7be47bb
Add missing colors to dark styles
not-my-profile Nov 14, 2021
0d19572
Slightly adjust sas style to meet WCAG AA
not-my-profile Nov 14, 2021
e2e0d4f
Improve CddlLexer performance (#1959)
blu-base Nov 16, 2021
cf51855
CSharp: add "cs" alias
birkenfeld Nov 17, 2021
ebf0161
demo: Sort options in lexer select (#1958)
not-my-profile Nov 17, 2021
4e34d1a
Asm lex bugfix #1895: register re check for boundary (#1961)
blu-base Nov 17, 2021
7a8223c
Devicetree: recognize hexadecimal addresses for nodes
birkenfeld Nov 17, 2021
7da4cb2
Merge branch 'master' of https://github.com/hwayne/pygments
hwayne Nov 29, 2021
c48cca4
Merge branch 'master' of https://github.com/hwayne/pygments
hwayne Nov 29, 2021
ddf0217
Fix highlighting for alloy facts
hwayne Nov 17, 2021
fc6b812
Add new Alloy 6 temporal keywords
hwayne Nov 17, 2021
2759c7a
Fix handling of " as a token
hwayne Nov 17, 2021
f92ecf0
Update the alloy golden test
hwayne Nov 29, 2021
b0aa980
Fix golden tests again
hwayne Nov 29, 2021
fa8755a
Merge branch 'master' of https://github.com/hwayne/pygments
hwayne Nov 18, 2022
41293ec
Fix highlighting for alloy facts
hwayne Nov 17, 2021
ee9fd8f
Add new Alloy 6 temporal keywords
hwayne Nov 17, 2021
3b57033
Fix handling of " as a token
hwayne Nov 17, 2021
bed19fb
Update the alloy golden test
hwayne Nov 29, 2021
3e9d1f6
Fix golden tests again
hwayne Nov 29, 2021
f64c531
Fix regexlint issue
hwayne Nov 18, 2022
79f60b9
Fix merge conflict
hwayne Nov 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 17 additions & 9 deletions pygments/lexers/dsls.py
Expand Up @@ -601,8 +601,9 @@ class AlloyLexer(RegexLexer):

flags = re.MULTILINE | re.DOTALL

iden_rex = r'[a-zA-Z_][\w\']*'
text_tuple = (r'[^\S\n]+', Whitespace)
iden_rex = r'[a-zA-Z_][\w]*"*'
string_rex = r'"\b(\\\\|\\[^\\]|[^"\\])*"'
text_tuple = (r'[^\S\n]+', Text)

tokens = {
'sig': [
Expand All @@ -621,6 +622,10 @@ class AlloyLexer(RegexLexer):
(r'\{', Operator, '#pop'),
(iden_rex, Name, '#pop'),
],
'fact': [
include('fun'),
(string_rex, String, '#pop')
],
'root': [
(r'--.*?$', Comment.Single),
(r'//.*?$', Comment.Single),
Expand All @@ -631,18 +636,21 @@ class AlloyLexer(RegexLexer):
(r'(sig|enum)(\s+)', bygroups(Keyword.Declaration, Whitespace), 'sig'),
(r'(iden|univ|none)\b', Keyword.Constant),
(r'(int|Int)\b', Keyword.Type),
(r'(this|abstract|extends|set|seq|one|lone|let)\b', Keyword),
(r'(var|this|abstract|extends|set|seq|one|lone|let)\b', Keyword),
(r'(all|some|no|sum|disj|when|else)\b', Keyword),
(r'(run|check|for|but|exactly|expect|as)\b', Keyword),
(r'(run|check|for|but|exactly|expect|as|steps)\b', Keyword),
(r'(always|after|eventually|until|release)\b', Keyword), # future time operators
(r'(historically|before|once|since|triggered)\b', Keyword), # past time operators
(r'(and|or|implies|iff|in)\b', Operator.Word),
(r'(fun|pred|fact|assert)(\s+)', bygroups(Keyword, Whitespace), 'fun'),
(r'!|#|&&|\+\+|<<|>>|>=|<=>|<=|\.|->', Operator),
(r'[-+/*%=<>&!^|~{}\[\]().]', Operator),
(r'(fun|pred|assert)(\s+)', bygroups(Keyword, Text), 'fun'),
(r'(fact)(\s+)', bygroups(Keyword, Text), 'fact'),
(r'!|#|&&|\+\+|<<|>>|>=|<=>|<=|\.\.|\.|->', Operator),
(r'[-+/*%=<>&!^|~{}\[\]().\';]', Operator),
(iden_rex, Name),
(r'[:,]', Punctuation),
(r'[0-9]+', Number.Integer),
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
(r'\n', Whitespace),
(string_rex, String),
(r'\n', Text),
]
}

Expand Down
40 changes: 20 additions & 20 deletions tests/examplefiles/alloy/example.als
Expand Up @@ -32,8 +32,8 @@ module examples/systems/views
*
* As a terminological convention, when there are two
* complementary view relationships, we will give them types
* t and t'. For example, KeySetView propagates from map to
* set, and KeySetView' propagates from set to map.
* t and t". For example, KeySetView propagates from map to
* set, and KeySetView" propagates from set to map.
*
* author: Daniel Jackson
*/
Expand Down Expand Up @@ -76,12 +76,12 @@ sig SetRef extends Ref {}
fact {State.obj[SetRef] in Set}

abstract sig ViewType {}
one sig KeySetView, KeySetView', IteratorView extends ViewType {}
one sig KeySetView, KeySetView", IteratorView extends ViewType {}
fact ViewTypes {
State.views[KeySetView] in MapRef -> SetRef
State.views[KeySetView'] in SetRef -> MapRef
State.views[KeySetView"] in SetRef -> MapRef
State.views[IteratorView] in IteratorRef -> SetRef
all s: State | s.views[KeySetView] = ~(s.views[KeySetView'])
all s: State | s.views[KeySetView] = ~(s.views[KeySetView"])
}

/**
Expand All @@ -107,20 +107,20 @@ pred allocates [pre, post: State, rs: set Ref] {
}

/**
* models frame condition that limits change to view object from v to v' when backing object changes to b'
* models frame condition that limits change to view object from v to v" when backing object changes to b"
*/
pred viewFrame [t: ViewType, v, v', b': Object] {
t in KeySetView => v'.elts = dom [b'.map]
t in KeySetView' => b'.elts = dom [v'.map]
t in KeySetView' => (b'.elts) <: (v.map) = (b'.elts) <: (v'.map)
t in IteratorView => v'.elts = b'.left + b'.done
pred viewFrame [t: ViewType, v, v", b": Object] {
t in KeySetView => v".elts = dom [b".map]
t in KeySetView" => b".elts = dom [v".map]
t in KeySetView" => (b".elts) <: (v.map) = (b".elts) <: (v".map)
t in IteratorView => v".elts = b".left + b".done
}

pred MapRef.keySet [pre, post: State, setRefs: SetRef] {
post.obj[setRefs].elts = dom [pre.obj[this].map]
modifies [pre, post, none]
allocates [pre, post, setRefs]
post.views = pre.views + KeySetView->this->setRefs + KeySetView'->setRefs->this
post.views = pre.views + KeySetView->this->setRefs + KeySetView"->setRefs->this
}

pred MapRef.put [pre, post: State, k, v: Ref] {
Expand All @@ -141,22 +141,22 @@ pred SetRef.iterator [pre, post: State, iterRef: IteratorRef] {
}

pred IteratorRef.remove [pre, post: State] {
let i = pre.obj[this], i' = post.obj[this] {
i'.left = i.left
i'.done = i.done - i.lastRef
no i'.lastRef
let i = pre.obj[this], i" = post.obj[this] {
i".left = i.left
i".done = i.done - i.lastRef
no i".lastRef
}
modifies [pre,post,this]
allocates [pre, post, none]
pre.views = post.views
}

pred IteratorRef.next [pre, post: State, ref: Ref] {
let i = pre.obj[this], i' = post.obj[this] {
let i = pre.obj[this], i" = post.obj[this] {
ref in i.left
i'.left = i.left - ref
i'.done = i.done + ref
i'.lastRef = ref
i".left = i.left - ref
i".done = i.done + ref
i".lastRef = ref
}
modifies [pre, post, this]
allocates [pre, post, none]
Expand Down