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

lex: advancement in lexer implementation #13

Merged
merged 5 commits into from
Aug 16, 2024
Merged

lex: advancement in lexer implementation #13

merged 5 commits into from
Aug 16, 2024

Conversation

FedericoBruzzone
Copy link
Contributor

@FedericoBruzzone FedericoBruzzone commented Aug 14, 2024

  • Fix documentation
  • Add the list initialization
  • Add the tuple initialization
  • Add unit type
  • Add the function initialization
  • Add +, -, *, / (basic) operators in functions
  • Refactoring StateSymbol struct

Signed-off-by: FedericoBruzzone <[email protected]>
Signed-off-by: FedericoBruzzone <[email protected]>
Co-authored-by: Federico Guerinoni <[email protected]>
@FedericoBruzzone FedericoBruzzone changed the title lex: add the list initialization lex: advancement in lexer implementation Aug 15, 2024
Copy link
Contributor Author

@FedericoBruzzone FedericoBruzzone left a comment

Choose a reason for hiding this comment

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

LGTM
@guerinoni let me know

src/lexer/states.rs Show resolved Hide resolved
src/lexer/states.rs Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
x_func: () -> unit = () -> print "hello" ;
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case print what is it? identifier but why? later can be parsed and found as another func?

Copy link
Contributor Author

@FedericoBruzzone FedericoBruzzone Aug 16, 2024

Choose a reason for hiding this comment

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

Function invocation does not require ().

I expect that when visiting the AST we will have a symbol table in that we will have all our functions, BUT at the same time we will have a separate symbol table for the functions that our stdlib will provide.

In this case in the symbol table of the stdlib there will be defined the print (and probably the Optional type, hd function to get the head of a list etc...)

Comment on lines +373 to +376
TokenKind::TokenPlus => write!(f, "TokenPlus"),
TokenKind::TokenMinus => write!(f, "TokenMinus"),
TokenKind::TokenMultiply => write!(f, "TokenMultiply"),
TokenKind::TokenDivide => write!(f, "TokenDivide"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should add those also for assignment/initialization

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by this comment?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Support for
x = x + 1 and friends

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should already be covered!
I'll try to write two tests to add to this PR 👍

@FedericoBruzzone FedericoBruzzone merged commit d43ca55 into main Aug 16, 2024
9 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.

2 participants