-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Support for Statement Definitions
- Loading branch information
Showing
5 changed files
with
59 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
File renamed without changes.
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,43 @@ | ||
// | ||
// Statement.swift | ||
// | ||
// | ||
// Generated by SyntaxDefinitionGenerator on 06/26/24 | ||
// | ||
|
||
|
||
public protocol Statement { | ||
func accept<V: StatementVisitor, R>(visitor: V) -> R where R == V.StatementVisitorReturn | ||
} | ||
|
||
public protocol StatementVisitor { | ||
associatedtype StatementVisitorReturn | ||
|
||
func visit(_ expr: Expr) -> StatementVisitorReturn | ||
func visit(_ expr: Print) -> StatementVisitorReturn | ||
} | ||
|
||
public struct Expr: Statement { | ||
let expression: Expression | ||
|
||
init(expression: Expression) { | ||
self.expression = expression | ||
} | ||
|
||
public func accept<V: StatementVisitor, R>(visitor: V) -> R where R == V.StatementVisitorReturn { | ||
return visitor.visit(self) | ||
} | ||
} | ||
|
||
public struct Print: Statement { | ||
let expression: Expression | ||
|
||
init(expression: Expression) { | ||
self.expression = expression | ||
} | ||
|
||
public func accept<V: StatementVisitor, R>(visitor: V) -> R where R == V.StatementVisitorReturn { | ||
return visitor.visit(self) | ||
} | ||
} | ||
|
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
Sources/SyntaxDefinitionGenerator/Resources/statement.json
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,14 @@ | ||
|
||
{ | ||
"baseName": "Statement", | ||
"types": [ | ||
{ | ||
"name": "Expr", | ||
"parameterField": "expression: Expression" | ||
}, | ||
{ | ||
"name": "Print", | ||
"parameterField": "expression: Expression" | ||
} | ||
] | ||
} |