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

Unreachable non-terminals error at parol v0.16.0 #57

Closed
dalance opened this issue Jan 19, 2023 · 5 comments
Closed

Unreachable non-terminals error at parol v0.16.0 #57

dalance opened this issue Jan 19, 2023 · 5 comments
Assignees

Comments

@dalance
Copy link

dalance commented Jan 19, 2023

I found the information about unreachable non-terminals is decreased at v0.16.0.

  • v0.16.0
Caused by:
  process didn't exit successfully: `/home/hatta/work/repos/veryl/target/debug/build/veryl-parser-a3b0e4ec4f25b7de/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=veryl.par

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UserError(Grammar contains unreachable non-terminals)', crates/parser/build.rs:18:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  • v0.15.0
Caused by:
  process didn't exit successfully: `/home/hatta/work/repos/veryl/target/debug/build/veryl-parser-958b4e738b7a632f/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=veryl.par

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: parol::analysis::unreachable_non_terminals

    × Basic grammar checks and transformations failed!
    ╰─▶ Grammar contains unreachable non-terminals
    help: If not used they can safely be removed

  Error:
    × Non-terminal: Attribute
  Error:
    × Non-terminal: AttributeList
  Error:
    × Non-terminal: AttributeListList
  Error:
    × Non-terminal: AttributeListOpt
  Error:
    × Non-terminal: AttributeOpt
  ', crates/parser/build.rs:18:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@jsinger67
Copy link
Owner

@dalance
Although the output format changed a bit, I can't confirm this:

error[parol::analysis::unreachable_non_terminals]: Grammar contains unreachable non-terminals
 = Non-terminals:
 = B, C
 = Unreachable non-terminals are not allowed. If not used they can be safely removed.

Did you use the new error report approach? You can have a look at json_parser_auto example, especially at the use of the struct JSONErrorReporter.

@dalance
Copy link
Author

dalance commented Jan 19, 2023

Sorry. My explanation was lack.
This is the output of build.rs which is generated by parol new command.

For example, adding the following terminal to https://github.com/jsinger67/parol/blob/main/examples/json_parser_auto/json.par

A : 'a';

I got

error: failed to run custom build command for `json_parser_auto v0.4.0 (/home/hatta/work/repos/parol/examples/json_parser_auto)`

Caused by:
  process didn't exit successfully: `/home/hatta/work/repos/parol/target/debug/build/json_parser_auto-5260c2348092750d/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=json.par

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UserError(Grammar contains unreachable non-terminals)', examples/json_parser_auto/build.rs:15:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@jsinger67
Copy link
Owner

I see.
I will have a closer look at it.
I think I have to change the code generated by parol new to adapt to the new error reporting approach.
Thank you @dalance for reporting this. 👍

@jsinger67 jsinger67 self-assigned this Jan 19, 2023
@jsinger67
Copy link
Owner

Fixed parol new to support standard error reporting according the new approach for both build script and the executable itself.

@dalance
Copy link
Author

dalance commented Jan 20, 2023

Thanks.
I updated my build.rs as the same as abd007b, and got the detailed error.

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

When branches are created from issues, their pull requests are automatically linked.

2 participants