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

Show parsing errors in context of line where they occur #168

Merged
merged 5 commits into from
Aug 20, 2024

Conversation

ldemailly
Copy link
Member

@ldemailly ldemailly commented Aug 20, 2024

Now:

$ if true {
>    len{}
13:04:44.844 [ERR] parser error: expected next token to be `(`, got `{` instead:
   len{}
      ^
$ 1e+999 - 6
13:05:15.404 [ERR] parser error: could not parse "1e+999" as float:
1e+999 - 6
     ^
$ if foo {  % blah
13:07:21.791 [ERR] parser error: no prefix parse function for `%` found:
if foo {  % blah
          ^

Fixes #15 (at least for parsing errors, for eval time we may want a stack trace)
Fixes #166 (will follow up in discord bot PR)

@ldemailly ldemailly requested a review from ccoVeille August 20, 2024 20:03
@ldemailly ldemailly merged commit 1e3deb4 into main Aug 20, 2024
1 check passed
@ldemailly ldemailly deleted the parsing_error branch August 20, 2024 22:10
eval/eval.go Show resolved Hide resolved
parser/parser.go Show resolved Hide resolved
parser/parser.go Show resolved Hide resolved
parser/parser_test.go Show resolved Hide resolved
token/token.go Show resolved Hide resolved
@ccoVeille
Copy link
Contributor

I would like to recommend you

https://github.com/meyermarcel/annot

(Hi @meyermarcel 👋)

@ldemailly
Copy link
Member Author

I would like to recommend you

https://github.com/meyermarcel/annot

(Hi @meyermarcel 👋)

fancy :) I think I'm ok with my lowkey single ^ though for now :)

ldemailly added a commit that referenced this pull request Aug 21, 2024
ldemailly added a commit that referenced this pull request Aug 21, 2024
…direct access and ranges (#171)

* Index range expression, including right relative to the end

* Add l:r to generate array of ints. handle for arrays and maps

* Handle x[n:] case

* simplify and add some basic test

* checkpoint

* review comments from #168

* allow negative (from end) access for both direct index and ranges

* use : to replace generateIndices()

* update test for negative index

* add one range test
@ccoVeille
Copy link
Contributor

I would like to recommend you

https://github.com/meyermarcel/annot

(Hi @meyermarcel 👋)

fancy :) I think I'm ok with my lowkey single ^ though for now :)

Noted. I also found https://github.com/caarlos0/mdtree

New and interesting

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.

limit number of parsing errors Better errors, line numbers, dump the ast etc
2 participants