This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
-
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.
feat: implement string interpolation
- Loading branch information
Showing
12 changed files
with
159 additions
and
31 deletions.
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
17 changes: 17 additions & 0 deletions
17
src/code-analysis/parser/ast/expressions/string-interpolation.ts
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,17 @@ | ||
import type { Token } from "../../../syntax/token"; | ||
import type { LiteralExpression } from "./literal"; | ||
import AST from ".."; | ||
|
||
export class StringInterpolationExpression extends AST.Expression { | ||
public constructor( | ||
public readonly parts: (LiteralExpression<string> | AST.Expression)[] | ||
) { super(); } | ||
|
||
public accept<R>(visitor: AST.Visitor.Expression<R>): R { | ||
return visitor.visitStringInterpolationExpression(this); | ||
} | ||
|
||
public get token(): Token { | ||
return this.parts[0].token; | ||
} | ||
} |
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
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
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
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
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
21 changes: 21 additions & 0 deletions
21
src/code-analysis/type-checker/binder/bound-expressions/string-interpolation.ts
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,21 @@ | ||
import { Token } from "../../../syntax/token"; | ||
import { BoundExpression } from "../bound-node"; | ||
import BoundLiteralExpression from "./literal"; | ||
import SingularType from "../../types/singular-type"; | ||
import AST from "../../../parser/ast"; | ||
|
||
export default class BoundStringInterpolationExpression extends BoundExpression { | ||
public override readonly type = new SingularType("string"); | ||
|
||
public constructor( | ||
public readonly parts: (BoundLiteralExpression<string> | BoundExpression)[] | ||
) { super(); } | ||
|
||
public accept<R>(visitor: AST.Visitor.BoundExpression<R>): R { | ||
return visitor.visitStringInterpolationExpression(this); | ||
} | ||
|
||
public get token(): Token { | ||
return this.parts[0].token; | ||
} | ||
} |
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
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
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
Oops, something went wrong.