@@ -5,6 +5,8 @@ module RUST-ERROR-SYNTAX
5
5
6
6
syntax ValueListOrError ::= concat(ValueOrError, ValueListOrError) [function, total]
7
7
syntax PtrListOrError ::= concat(Ptr, PtrListOrError) [function, total]
8
+ syntax StringOrError ::= concat(StringOrError, StringOrError) [function, total]
9
+ syntax NonEmptyStatementsOrError ::= concat(NonEmptyStatementsOrError, NonEmptyStatementsOrError) [function, total]
8
10
syntax PtrValueOrError ::= wrapPtrValueOrError(Ptr, ValueOrError) [function, total]
9
11
syntax TypePathOrError ::= doubleColonOrError(TypePathSegmentsOrError) [function, total]
10
12
syntax TypePathOrError ::= injectOrError(TypePathSegmentsOrError) [function, total]
@@ -22,10 +24,18 @@ module RUST-ERROR
22
24
rule concat(V:Value, L:ValueList) => V , L
23
25
rule concat(_:Value, E:SemanticsError) => E
24
26
rule concat(E:SemanticsError, _:ValueListOrError) => E
25
- rule concat(E:ValueOrError, L:ValueListOrError)
26
- => error("unexpected branch (concat(ValueOrError, ValueListOrError))", ListItem(E) ListItem(L))
27
+
28
+ rule concat(S1:String:StringOrError, S2:String:StringOrError) => S1 +String S2
29
+ rule concat(_:String:StringOrError, E:SemanticsError:StringOrError) => E
30
+ rule concat(E:SemanticsError:StringOrError, _:StringOrError) => E
31
+ rule concat(S1:StringOrError, S2:StringOrError)
32
+ => error("concat(StringOrError, StringOrError): Unknown error", ListItem(S1) ListItem(S2))
27
33
[owise]
28
34
35
+ rule concat(S1:NonEmptyStatements, S2:NonEmptyStatements) => concatNonEmptyStatements(S1, S2)
36
+ rule concat(_:NonEmptyStatements, E:SemanticsError) => E
37
+ rule concat(E:SemanticsError, _:NonEmptyStatementsOrError) => E
38
+
29
39
rule wrapPtrValueOrError(P:Ptr, V:Value) => ptrValue(P, V)
30
40
rule wrapPtrValueOrError(_:Ptr, E:SemanticsError) => E
31
41
@@ -38,9 +48,9 @@ module RUST-ERROR
38
48
rule concat(_:TypePathSegment, E) => E
39
49
rule concat(S:TypePathSegment, Ss:TypePathSegments) => S :: Ss
40
50
41
- rule andOrError(_:ExpressionOrError, E:SemanticsError) => E
42
- rule andOrError(E:SemanticsError, _:Expression) => E
43
- rule andOrError(E1:Expression, E2:Expression) => E1 && E2
51
+ rule andOrError(_:ExpressionOrError, e( E:SemanticsError)) => e(E)
52
+ rule andOrError(e( E:SemanticsError), v( _:Expression)) => e(E)
53
+ rule andOrError(v( E1:Expression), v( E2:Expression)) => v( E1 && E2)
44
54
45
55
rule tupleOrError(L:ValueList) => tuple(L)
46
56
rule tupleOrError(E:SemanticsError) => E
0 commit comments