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

KCL Boolean Logic (& and |) and keyword parsing fix #4194

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

guptaarnav
Copy link
Collaborator

@guptaarnav guptaarnav commented Oct 17, 2024

Implemented boolean logical and (&) and boolean logical or (|). Closes #4188

Fixed a bug in the parsing of keywords; the unambiguous_keywords function looks ahead after a possible keyword candidate for more characters (letters, numbers, -, or _) to see if its an identifier instead of a keyword. This parsing was causing incorrect behavior if there is no token after the word being parsed, e.g. "true" (with EOF afterwards) would be parsed as an identifier because there are no characters to look ahead. This is resolved now.

Copy link

qa-wolf bot commented Oct 17, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

vercel bot commented Oct 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Oct 28, 2024 2:05pm

@adamchalmers
Copy link
Collaborator

adamchalmers commented Oct 17, 2024

I just changed how AST nodes are serialized, could you please merge/rebase main and then rerun the parser snapshot tests? Your snapshots should be less verbose now.

adamchalmers and others added 4 commits October 17, 2024 16:41
This will make our snapshots and JSON representations easier to read (making our tests less verbose).
* Add syntax highlighting for comparison operators

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)

* Confirm

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Neater code, and better error messages.
@lf94
Copy link
Contributor

lf94 commented Oct 29, 2024

@adamchalmers I'll need you to carry this one

@lf94 lf94 mentioned this pull request Oct 29, 2024
// the start of a normal word.
let keyword = terminated(
keyword_candidates,
peek(none_of(('a'..='z', 'A'..='Z', '-', '_', '0'..='9'))),
not(peek(one_of(('a'..='z', 'A'..='Z', '-', '_', '0'..='9')))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since #4502, I think this change is no longer relevant. Characters that follow are no longer checked. inner_word() consumes an entire word, and then if it's in the map, its token type is changed to a keyword or type.

It would be nice to keep the tests for this, though.

Copy link
Collaborator

@jtran jtran Nov 25, 2024

Choose a reason for hiding this comment

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

Please move these to simulation tests. See #4487 for an example.

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.

Add Boolean 'and' and 'or' to kcl stdlib
4 participants