diff options
Diffstat (limited to 'language-web')
-rw-r--r-- | language-web/src/main/js/editor/EditorParent.ts | 3 | ||||
-rw-r--r-- | language-web/src/main/js/editor/problem.grammar | 23 | ||||
-rw-r--r-- | language-web/src/main/js/editor/problemLanguageSupport.ts | 3 | ||||
-rw-r--r-- | language-web/src/main/js/index.tsx | 2 |
4 files changed, 22 insertions, 9 deletions
diff --git a/language-web/src/main/js/editor/EditorParent.ts b/language-web/src/main/js/editor/EditorParent.ts index 316c5072..a2f6c266 100644 --- a/language-web/src/main/js/editor/EditorParent.ts +++ b/language-web/src/main/js/editor/EditorParent.ts | |||
@@ -65,6 +65,9 @@ export const EditorParent = styled('div')(({ theme }) => ({ | |||
65 | '.cmt-number': { | 65 | '.cmt-number': { |
66 | color: '#6188a6', | 66 | color: '#6188a6', |
67 | }, | 67 | }, |
68 | '.cmt-string': { | ||
69 | color: theme.palette.secondary.dark, | ||
70 | }, | ||
68 | '.cmt-keyword': { | 71 | '.cmt-keyword': { |
69 | color: theme.palette.primary.main, | 72 | color: theme.palette.primary.main, |
70 | }, | 73 | }, |
diff --git a/language-web/src/main/js/editor/problem.grammar b/language-web/src/main/js/editor/problem.grammar index 921cec53..cf940698 100644 --- a/language-web/src/main/js/editor/problem.grammar +++ b/language-web/src/main/js/editor/problem.grammar | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | @top Problem { statement* } | 1 | @top Problem { statement* } |
3 | 2 | ||
4 | statement { | 3 | statement { |
@@ -7,6 +6,7 @@ statement { | |||
7 | } | | 6 | } | |
8 | ClassDefinition { | 7 | ClassDefinition { |
9 | ckw<"abstract">? ckw<"class"> RelationName | 8 | ckw<"abstract">? ckw<"class"> RelationName |
9 | (ckw<"extends"> sep<",", RelationName>)? | ||
10 | (ClassBody { "{" ReferenceDeclaration* "}" } | ".") | 10 | (ClassBody { "{" ReferenceDeclaration* "}" } | ".") |
11 | } | | 11 | } | |
12 | EnumDefinition { | 12 | EnumDefinition { |
@@ -21,6 +21,9 @@ statement { | |||
21 | ckw<"default">? (NotOp | UnknownOp)? RelationName | 21 | ckw<"default">? (NotOp | UnknownOp)? RelationName |
22 | ParameterList<AssertionArgument> (":" LogicValue)? "." | 22 | ParameterList<AssertionArgument> (":" LogicValue)? "." |
23 | } | | 23 | } | |
24 | NodeValueAssertion { | ||
25 | UniqueNodeName ":" Constant "." | ||
26 | } | | ||
24 | UniqueDeclaration { | 27 | UniqueDeclaration { |
25 | ckw<"unique"> sep<",", UniqueNodeName> "." | 28 | ckw<"unique"> sep<",", UniqueNodeName> "." |
26 | } | | 29 | } | |
@@ -30,18 +33,17 @@ statement { | |||
30 | } | 33 | } |
31 | 34 | ||
32 | ReferenceDeclaration { | 35 | ReferenceDeclaration { |
33 | ((kw<"refers"> | kw<"contains">) !times RelationName | !plus RelationName) | 36 | (kw<"refers"> | kw<"contains">)? |
37 | RelationName | ||
34 | RelationName | 38 | RelationName |
35 | ( "[" Multiplicity? "]" )? | 39 | ( "[" Multiplicity? "]" )? |
36 | (kw<"opposite"> RelationName)? | 40 | (kw<"opposite"> RelationName)? |
37 | ";"? | 41 | ";"? |
38 | } | 42 | } |
39 | 43 | ||
40 | @precedence { times @left, plus } | ||
41 | |||
42 | Parameter { RelationName? VariableName } | 44 | Parameter { RelationName? VariableName } |
43 | 45 | ||
44 | Conjunction { sep1<",", Literal> } | 46 | Conjunction { ("," | Literal)+ } |
45 | 47 | ||
46 | OrOp { ";" } | 48 | OrOp { ";" } |
47 | 49 | ||
@@ -49,9 +51,11 @@ Literal { NotOp? Atom } | |||
49 | 51 | ||
50 | Atom { RelationName ParameterList<Argument>? } | 52 | Atom { RelationName ParameterList<Argument>? } |
51 | 53 | ||
52 | Argument { VariableName | Real } | 54 | Argument { VariableName | Constant } |
53 | 55 | ||
54 | AssertionArgument { NodeName | StarArgument | Real } | 56 | AssertionArgument { NodeName | StarArgument | Constant } |
57 | |||
58 | Constant { Real | String } | ||
55 | 59 | ||
56 | LogicValue { | 60 | LogicValue { |
57 | ckw<"true"> | ckw<"false"> | ckw<"unknown"> | ckw<"error"> | 61 | ckw<"true"> | ckw<"false"> | ckw<"unknown"> | ckw<"error"> |
@@ -108,6 +112,11 @@ sep1<separator, content> { content (separator content?)* } | |||
108 | 112 | ||
109 | exponential { int ("e" | "E") ("+" | "-")? int } | 113 | exponential { int ("e" | "E") ("+" | "-")? int } |
110 | 114 | ||
115 | String { | ||
116 | "'" (![\\'\n] | "\\" ![\n] | "\\\n")+ "'" | | ||
117 | "\"" (![\\"\n] | "\\" (![\n] | "\n"))* "\"" | ||
118 | } | ||
119 | |||
111 | NotOp { "!" } | 120 | NotOp { "!" } |
112 | 121 | ||
113 | UnknownOp { "?" } | 122 | UnknownOp { "?" } |
diff --git a/language-web/src/main/js/editor/problemLanguageSupport.ts b/language-web/src/main/js/editor/problemLanguageSupport.ts index 2bf7c7a4..c9e61b31 100644 --- a/language-web/src/main/js/editor/problemLanguageSupport.ts +++ b/language-web/src/main/js/editor/problemLanguageSupport.ts | |||
@@ -26,7 +26,7 @@ const parserWithMetadata = (parser as LRParser).configure({ | |||
26 | LineComment: t.lineComment, | 26 | LineComment: t.lineComment, |
27 | BlockComment: t.blockComment, | 27 | BlockComment: t.blockComment, |
28 | 'problem class enum pred unique scope': t.definitionKeyword, | 28 | 'problem class enum pred unique scope': t.definitionKeyword, |
29 | 'abstract refers contains opposite error default': t.modifier, | 29 | 'abstract extends refers contains opposite error default': t.modifier, |
30 | 'true false unknown error': t.keyword, | 30 | 'true false unknown error': t.keyword, |
31 | NotOp: t.keyword, | 31 | NotOp: t.keyword, |
32 | UnknownOp: t.keyword, | 32 | UnknownOp: t.keyword, |
@@ -34,6 +34,7 @@ const parserWithMetadata = (parser as LRParser).configure({ | |||
34 | StarArgument: t.keyword, | 34 | StarArgument: t.keyword, |
35 | 'IntMult StarMult Real': t.number, | 35 | 'IntMult StarMult Real': t.number, |
36 | StarMult: t.number, | 36 | StarMult: t.number, |
37 | String: t.string, | ||
37 | 'RelationName/QualifiedName': t.typeName, | 38 | 'RelationName/QualifiedName': t.typeName, |
38 | 'UniqueNodeName/QualifiedName': t.atom, | 39 | 'UniqueNodeName/QualifiedName': t.atom, |
39 | 'VariableName/QualifiedName': t.variableName, | 40 | 'VariableName/QualifiedName': t.variableName, |
diff --git a/language-web/src/main/js/index.tsx b/language-web/src/main/js/index.tsx index 1b24eadb..9316db4d 100644 --- a/language-web/src/main/js/index.tsx +++ b/language-web/src/main/js/index.tsx | |||
@@ -26,7 +26,7 @@ enum TaxStatus { | |||
26 | % A child cannot have any dependents. | 26 | % A child cannot have any dependents. |
27 | error invalidTaxStatus(Person p) <-> | 27 | error invalidTaxStatus(Person p) <-> |
28 | taxStatus(p, child), | 28 | taxStatus(p, child), |
29 | children(p, _q) | 29 | children(p, _q), |
30 | ; taxStatus(p, retired), | 30 | ; taxStatus(p, retired), |
31 | parent(p, q), | 31 | parent(p, q), |
32 | !taxStatus(q, retired). | 32 | !taxStatus(q, retired). |