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

fix expression #66

Open
wants to merge 66 commits into
base: master
Choose a base branch
from
Open

fix expression #66

wants to merge 66 commits into from

Conversation

NTTVy03
Copy link
Collaborator

@NTTVy03 NTTVy03 commented Jan 6, 2025

  1. fix error parse out[k] * (out[k] - 1) === 0
  2. re-arrange token kinds
  3. extract tuple expression, tuple identifier and list identifier

crates/lsp/src/global_state.rs Outdated Show resolved Hide resolved
crates/parser/src/grammar/block.rs Show resolved Hide resolved
// "signal input" --> Some(true)
// "signal output" --> Some(false)
// [N][M-1]
fn array(p: &mut Parser) -> bool {
Copy link
Owner

Choose a reason for hiding this comment

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

So we should rename this to array_query?

Copy link
Collaborator Author

@NTTVy03 NTTVy03 Jan 18, 2025

Choose a reason for hiding this comment

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

So we should rename this to array_query?

I don't understand the meaning of "array_query".
This function's use case is parsing [N][M-1] from a (multi-dimensional) array input[N][M-1].

fn array(p: &mut Parser) -> bool {
let is_array = p.at(LBracket);

while p.at(LBracket) {
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we use why here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do we use why here?

For multi-dimensional array


let res = if p.at(InputKw) {
Some(true)
} else if p.at(OutputKw) {
Copy link
Owner

Choose a reason for hiding this comment

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

Why don't we use match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why don't we use match?

You mean:

let result = match p.current() {
    InputKw => Some(true),
    OutputKw => Some(false),
    _ => None
};

It is also another way (replace .at() with .current()). I will change it if you prefer.

p.close(m, SignalHeader);
res
}

pub(crate) fn var_init(p: &mut Parser) {
Copy link
Owner

Choose a reason for hiding this comment

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

Can you give example here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you give example here?

// eg: tmp = 10;


p.expect(RParen);

// p.close(m, ExpressionList);
Copy link
Owner

Choose a reason for hiding this comment

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

So we don't create AST not for those function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So we don't create AST not for those function?

Can you explain your comment?

Update crates/lsp/src/global_state.rs

Co-authored-by: Vu Vo <[email protected]>
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