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

feat: Create parser with AST #19

Merged
merged 13 commits into from
Aug 19, 2024
Merged

feat: Create parser with AST #19

merged 13 commits into from
Aug 19, 2024

Conversation

Gashmob
Copy link
Member

@Gashmob Gashmob commented Aug 15, 2024

Closes #12

Part of #12

filc can now take a single file as argument and parse it.

Only literals are supported for now

Note: dump of AST structure will be done in a future commit. It needs
visitor pattern to be implemented
@Gashmob Gashmob added the enhancement New feature or request label Aug 15, 2024
@Gashmob Gashmob added this to the v0.1.0 milestone Aug 15, 2024
@Gashmob Gashmob self-assigned this Aug 15, 2024
@Gashmob Gashmob linked an issue Aug 15, 2024 that may be closed by this pull request
Gashmob added 10 commits August 15, 2024 11:56
Part of #12

Comments are simply ignored by the Lexer

*Testing:*

Write comments in your file, they should be ignored
Part of #12

By running `filc --dump=ast <file>` you can now see AST structure of you
program
Part of #12

When testing this workflow on antoher repository, it appears that it
wasn't working. There was 2 problems

- Lack of permission: the step needs `contents:write` permission to be
  able to add files to the release. I give it to entire workflow to
  avoid problems. I also add packages permissions for when we will add
  docker image
- Wrong config: the file argument of the actions takes a semicolon list
  of file, not a multiline list. I've bad-read this part of the
  documentation (my fault)
Part of #12

We can now declare variable and constant with:
- var name
- val name

We cannot yet assign value to them

Also increase clang-format column limit to 120 (80 is to small)
Part of #12

Variable can now have a type and a value
Part of #12

Instead of having multiple tests in same TEST, expand them to multiple
TESTs. It will ease debug and corrections
Part of #12

https://typicode.github.io/husky/ is a tool that help configuring git
hooks.

Here we use it for pre-commit hook to run clang-format each time

*Testing:*

If you write some c++ code which is not valid along clang-format, when
commiting it should be linted automagically
Part of #12

In previous commit we've added Husky which uses (p)npm. In order to keep
this dependency up-to-date, add 'npm' to dependabot config
Part of #12

The parser now handle binary calculs with `left op right`.

Operator priorities should be good, I'm just not totally sure for the
priority between % and /,*.
@Gashmob Gashmob force-pushed the 12-create-parser-with-ast branch from c5a70a5 to 433faff Compare August 18, 2024 09:27
Part of #12

It allow to use variable name as expression
Part of #12

The parse now handle assignations `foo = "bar"`.

A shorthand is also available, from `bar = bar || true` to `bar ||= true`

Note: Also add missing e2e memory test on dump
@Gashmob Gashmob merged commit 863a3b5 into master Aug 19, 2024
13 checks passed
@Gashmob Gashmob deleted the 12-create-parser-with-ast branch August 19, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create parser with AST
1 participant