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

Expression parser #9

Merged
merged 75 commits into from
Nov 19, 2023
Merged

Expression parser #9

merged 75 commits into from
Nov 19, 2023

Conversation

Korunka1
Copy link
Collaborator

Add new AST nodes, functions for creating them, expression parsing wi
thout error and end handling

@Korunka1 Korunka1 requested a review from loumadev October 30, 2023 08:15
Copy link
Owner

@loumadev loumadev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

include/compiler/parser/Expressions.h Outdated Show resolved Hide resolved
src/compiler/parser/ASTNodes.c Outdated Show resolved Hide resolved
src/compiler/parser/Expressions.c Outdated Show resolved Hide resolved
include/compiler/parser/Expressions.h Outdated Show resolved Hide resolved
include/compiler/parser/Expressions.h Outdated Show resolved Hide resolved
src/compiler/parser/ASTNodes.c Outdated Show resolved Hide resolved
src/compiler/parser/ASTNodes.c Outdated Show resolved Hide resolved
return id;
}
if(id->token->type = TOKEN_IDENTIFIER){
IdentifierASTNode *identifierE = new_IdentifierASTNode(id->token->value.string); //string or identifier?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings are being considered literals; This might not apply if the string is interpolated (we'll discuss this later).

The general idea is that when the string literal is encountered, some sub-procedure should trigger and match pattern like "string expression string ... string expression string". After each string, there should be either an expression (without any direct operator, "str" 2 + 3) or operator ("str" + 2 + 3), or some terminator (;, EOF, ...).

["str", 2, +, 3], should be parsed into:

StringLiteralExpression:
  * StringLiteralSegmentList:
    - StringSegment
      * value: String* ("str")
    - BinaryExpression
      * left: ... (2)
      * right: ... (3)
        ...
    - StringSegment (string literal is guaranteed to end by string)
      * value: String* ("")

Note: The strings can be nested: "pre\("in")post" -> ["pre", "in", "post"] ->

StringLiteralExpression [
  StringSegment("pre"),
  StringLiteralExpression [ StringSegment("in") ],
  StringSegment("post")
]

Notice: This feature is not currently available in the project, but will be implemented in the upcoming time.

include/compiler/parser/ASTNodes.h Outdated Show resolved Hide resolved
loumadev and others added 29 commits November 14, 2023 23:40
@loumadev loumadev merged commit 97125ac into master Nov 19, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants