Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add string interpolation support #25

Open
2 tasks
alexdovzhanyn opened this issue Aug 3, 2024 · 3 comments
Open
2 tasks

Add string interpolation support #25

alexdovzhanyn opened this issue Aug 3, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest A good issue to work on for Hacktoberfest help wanted Extra attention is needed

Comments

@alexdovzhanyn
Copy link
Collaborator

We currently don't support string interpolation in Theta. Lets add string interpolation in, following the format:

name<String> = 'Bob'

outPut<String> = 'Hello my name is #{name}!'

We can do this directly in the parser. For each string that gets parsed, we can search through it and, if any interpolation is found, convert it to a BinaryOperationNode. in this way, the interpolation will just be syntactic sugar over string concatenation.

The above example should be converted to an AST matching the following structure:

BinaryOperationNode
  left:
    StringLiteralNode 'Hello my name is '
  right:
    BinaryOperationNode
      left:
        IdentifierNode
          name
      right:
        StringLiteralNode '!'
  • Update the parser to reinterpret strings with interpolation into string concatenation
  • Write a test to ensure string interpolation works
@alexdovzhanyn alexdovzhanyn added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Aug 3, 2024
@alexdovzhanyn alexdovzhanyn added the hacktoberfest A good issue to work on for Hacktoberfest label Sep 23, 2024
@PranavKeshav24
Copy link

Please assign this issue to me. I would be very happy to work on it.

@Probatio-Diabolica
Copy link

Hii Alex can you please assign this to me. thanks

@alexdovzhanyn
Copy link
Collaborator Author

alexdovzhanyn commented Oct 1, 2024

@Probatio-Diabolica assigned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest A good issue to work on for Hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants