diff options
author | 2022-08-01 01:44:06 +0200 | |
---|---|---|
committer | 2022-08-01 01:44:06 +0200 | |
commit | e86447b4d74677d86271336727e0bbff9f4c54b5 (patch) | |
tree | 5f32aa78c8aa8a72ec0303cb5675eb83877b3700 /subprojects/frontend/src | |
parent | chore(deps): bump dependencies (diff) | |
download | refinery-e86447b4d74677d86271336727e0bbff9f4c54b5.tar.gz refinery-e86447b4d74677d86271336727e0bbff9f4c54b5.tar.zst refinery-e86447b4d74677d86271336727e0bbff9f4c54b5.zip |
refactor: direct predicates
* Remove the direct keyword because it can be inferred
* Use may/must/current instead of value literals
* Transformation rule changes
Diffstat (limited to 'subprojects/frontend/src')
-rw-r--r-- | subprojects/frontend/src/index.tsx | 12 | ||||
-rw-r--r-- | subprojects/frontend/src/language/indentation.ts | 4 | ||||
-rw-r--r-- | subprojects/frontend/src/language/problem.grammar | 18 | ||||
-rw-r--r-- | subprojects/frontend/src/language/problemLanguageSupport.ts | 15 | ||||
-rw-r--r-- | subprojects/frontend/src/xtext/ContentAssistService.ts | 2 |
5 files changed, 28 insertions, 23 deletions
diff --git a/subprojects/frontend/src/index.tsx b/subprojects/frontend/src/index.tsx index 6cdbbd64..0616007a 100644 --- a/subprojects/frontend/src/index.tsx +++ b/subprojects/frontend/src/index.tsx | |||
@@ -34,12 +34,12 @@ pred invalidTaxStatus(Person p) <-> | |||
34 | parent(p, q), | 34 | parent(p, q), |
35 | !taxStatus(q, retired). | 35 | !taxStatus(q, retired). |
36 | 36 | ||
37 | direct rule createChild(p): | 37 | rule createChild(p, newPerson): |
38 | children(p, newPerson) = unknown, | 38 | may children(p, newPerson), |
39 | equals(newPerson, newPerson) = unknown | 39 | may !equals(newPerson, newPerson) |
40 | ~> new q, | 40 | ==> new q: newPerson, |
41 | children(p, q) = true, | 41 | children(p, q), |
42 | taxStatus(q, child) = true. | 42 | taxStatus(q, child). |
43 | 43 | ||
44 | indiv family. | 44 | indiv family. |
45 | Family(family). | 45 | Family(family). |
diff --git a/subprojects/frontend/src/language/indentation.ts b/subprojects/frontend/src/language/indentation.ts index 55dcd7f1..1c38637f 100644 --- a/subprojects/frontend/src/language/indentation.ts +++ b/subprojects/frontend/src/language/indentation.ts | |||
@@ -80,8 +80,8 @@ export function indentPredicateOrRule(context: TreeIndentContext): number { | |||
80 | if (/^\s+[;.]/.exec(context.textAfter) !== null) { | 80 | if (/^\s+[;.]/.exec(context.textAfter) !== null) { |
81 | return clauseIndent - 2; | 81 | return clauseIndent - 2; |
82 | } | 82 | } |
83 | if (/^\s+(~>)/.exec(context.textAfter) !== null) { | 83 | if (/^\s+(==>)/.exec(context.textAfter) !== null) { |
84 | return clauseIndent - 3; | 84 | return clauseIndent - 4; |
85 | } | 85 | } |
86 | return clauseIndent; | 86 | return clauseIndent; |
87 | } | 87 | } |
diff --git a/subprojects/frontend/src/language/problem.grammar b/subprojects/frontend/src/language/problem.grammar index 1ace2872..6fb188d8 100644 --- a/subprojects/frontend/src/language/problem.grammar +++ b/subprojects/frontend/src/language/problem.grammar | |||
@@ -18,14 +18,14 @@ statement { | |||
18 | (EnumBody { "{" sep<",", IndividualNodeName> "}" } | ".") | 18 | (EnumBody { "{" sep<",", IndividualNodeName> "}" } | ".") |
19 | } | | 19 | } | |
20 | PredicateDefinition { | 20 | PredicateDefinition { |
21 | (ckw<"error"> ckw<"pred">? | ckw<"direct">? ckw<"pred">) | 21 | (ckw<"error"> ckw<"pred">? | ckw<"pred">) |
22 | RelationName ParameterList<Parameter>? | 22 | RelationName ParameterList<Parameter>? |
23 | PredicateBody { ("<->" sep<OrOp, Conjunction>)? "." } | 23 | PredicateBody { ("<->" sep<OrOp, Conjunction>)? "." } |
24 | } | | 24 | } | |
25 | RuleDefinition { | 25 | RuleDefinition { |
26 | ckw<"direct">? ckw<"rule"> | 26 | ckw<"rule"> |
27 | RuleName ParameterList<Parameter>? | 27 | RuleName ParameterList<Parameter>? |
28 | RuleBody { ":" sep<OrOp, Conjunction> "~>" sep<OrOp, Action> "." } | 28 | RuleBody { ":" sep<OrOp, Conjunction> "==>" sep<OrOp, Consequent> "." } |
29 | } | | 29 | } | |
30 | Assertion { | 30 | Assertion { |
31 | kw<"default">? (NotOp | UnknownOp)? RelationName | 31 | kw<"default">? (NotOp | UnknownOp)? RelationName |
@@ -57,14 +57,14 @@ Conjunction { ("," | Literal)+ } | |||
57 | 57 | ||
58 | OrOp { ";" } | 58 | OrOp { ";" } |
59 | 59 | ||
60 | Literal { NotOp? Atom (("=" | ":") sep1<"|", LogicValue>)? } | 60 | Literal { Modality? NotOp? Modality? Atom ((":" | "=") LogicValue)? } |
61 | 61 | ||
62 | Atom { RelationName "+"? ParameterList<Argument> } | 62 | Atom { RelationName "+"? ParameterList<Argument> } |
63 | 63 | ||
64 | Action { ("," | ActionLiteral)+ } | 64 | Consequent { ("," | Action)+ } |
65 | 65 | ||
66 | ActionLiteral { | 66 | Action { |
67 | ckw<"new"> VariableName | | 67 | ckw<"new"> VariableName (":" VariableName)? | |
68 | ckw<"delete"> VariableName | | 68 | ckw<"delete"> VariableName | |
69 | Literal | 69 | Literal |
70 | } | 70 | } |
@@ -79,6 +79,10 @@ LogicValue { | |||
79 | ckw<"true"> | ckw<"false"> | ckw<"unknown"> | ckw<"error"> | 79 | ckw<"true"> | ckw<"false"> | ckw<"unknown"> | ckw<"error"> |
80 | } | 80 | } |
81 | 81 | ||
82 | Modality { | ||
83 | ckw<"must"> | ckw<"may"> | ckw<"current"> | ||
84 | } | ||
85 | |||
82 | ScopeElement { RelationName ("=" | "+=") Multiplicity } | 86 | ScopeElement { RelationName ("=" | "+=") Multiplicity } |
83 | 87 | ||
84 | Multiplicity { (IntMult "..")? (IntMult | StarMult)} | 88 | Multiplicity { (IntMult "..")? (IntMult | StarMult)} |
diff --git a/subprojects/frontend/src/language/problemLanguageSupport.ts b/subprojects/frontend/src/language/problemLanguageSupport.ts index b6e2f14e..550532ef 100644 --- a/subprojects/frontend/src/language/problemLanguageSupport.ts +++ b/subprojects/frontend/src/language/problemLanguageSupport.ts | |||
@@ -28,12 +28,13 @@ const parserWithMetadata = (parser as LRParser).configure({ | |||
28 | LineComment: t.lineComment, | 28 | LineComment: t.lineComment, |
29 | BlockComment: t.blockComment, | 29 | BlockComment: t.blockComment, |
30 | 'problem class enum pred rule indiv scope': t.definitionKeyword, | 30 | 'problem class enum pred rule indiv scope': t.definitionKeyword, |
31 | 'abstract extends refers contains opposite error direct default': t.modifier, | 31 | 'abstract extends refers contains opposite error default': t.modifier, |
32 | 'true false unknown error': t.keyword, | 32 | 'true false unknown error': t.keyword, |
33 | 'may must current': t.operatorKeyword, | ||
33 | 'new delete': t.operatorKeyword, | 34 | 'new delete': t.operatorKeyword, |
34 | NotOp: t.keyword, | 35 | NotOp: t.operator, |
35 | UnknownOp: t.keyword, | 36 | UnknownOp: t.operator, |
36 | OrOp: t.keyword, | 37 | OrOp: t.punctuation, |
37 | StarArgument: t.keyword, | 38 | StarArgument: t.keyword, |
38 | 'IntMult StarMult Real': t.number, | 39 | 'IntMult StarMult Real': t.number, |
39 | StarMult: t.number, | 40 | StarMult: t.number, |
@@ -46,7 +47,7 @@ const parserWithMetadata = (parser as LRParser).configure({ | |||
46 | '( )': t.paren, | 47 | '( )': t.paren, |
47 | '[ ]': t.squareBracket, | 48 | '[ ]': t.squareBracket, |
48 | '. .. , :': t.separator, | 49 | '. .. , :': t.separator, |
49 | '<-> ~>': t.definitionOperator, | 50 | '<-> ==>': t.definitionOperator, |
50 | }), | 51 | }), |
51 | indentNodeProp.add({ | 52 | indentNodeProp.add({ |
52 | ProblemDeclaration: indentDeclaration, | 53 | ProblemDeclaration: indentDeclaration, |
@@ -63,7 +64,7 @@ const parserWithMetadata = (parser as LRParser).configure({ | |||
63 | PredicateBody: foldInside, | 64 | PredicateBody: foldInside, |
64 | RuleBody: foldInside, | 65 | RuleBody: foldInside, |
65 | Conjunction: foldConjunction, | 66 | Conjunction: foldConjunction, |
66 | Action: foldWholeNode, | 67 | Consequent: foldWholeNode, |
67 | UniqueDeclaration: foldDeclaration, | 68 | UniqueDeclaration: foldDeclaration, |
68 | ScopeDeclaration: foldDeclaration, | 69 | ScopeDeclaration: foldDeclaration, |
69 | BlockComment: foldBlockComment, | 70 | BlockComment: foldBlockComment, |
@@ -81,7 +82,7 @@ const problemLanguage = LRLanguage.define({ | |||
81 | }, | 82 | }, |
82 | line: '%', | 83 | line: '%', |
83 | }, | 84 | }, |
84 | indentOnInput: /^\s*(?:\{|\}|\(|\)|;|\.|~>)$/, | 85 | indentOnInput: /^\s*(?:\{|\}|\(|\)|;|\.|==>)$/, |
85 | }, | 86 | }, |
86 | }); | 87 | }); |
87 | 88 | ||
diff --git a/subprojects/frontend/src/xtext/ContentAssistService.ts b/subprojects/frontend/src/xtext/ContentAssistService.ts index cf0fb49f..bedd3b5c 100644 --- a/subprojects/frontend/src/xtext/ContentAssistService.ts +++ b/subprojects/frontend/src/xtext/ContentAssistService.ts | |||
@@ -16,7 +16,7 @@ const PROPOSALS_LIMIT = 1000; | |||
16 | 16 | ||
17 | const IDENTIFIER_REGEXP_STR = '[a-zA-Z0-9_]*'; | 17 | const IDENTIFIER_REGEXP_STR = '[a-zA-Z0-9_]*'; |
18 | 18 | ||
19 | const HIGH_PRIORITY_KEYWORDS = ['<->', '~>']; | 19 | const HIGH_PRIORITY_KEYWORDS = ['<->', '==>']; |
20 | 20 | ||
21 | const log = getLogger('xtext.ContentAssistService'); | 21 | const log = getLogger('xtext.ContentAssistService'); |
22 | 22 | ||