BenjaminSchaaf / sbnf

A BNF-style language for writing sublime-syntax files
MIT License
58 stars 6 forks source link

Suspected regression into "not yet implemented" from earlier versions #32

Closed mitranim closed 1 year ago

mitranim commented 1 year ago

The following syntax used to compile in earlier SBNF versions, but fails to compile after updating SBNF.

Error:

thread 'main' panicked at 'not yet implemented', src/compiler/codegen/lookahead.rs:337:22
stack backtrace:
   0:        0x102876152 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9515a3bdbd0baca0
   1:        0x1028862ca - core::fmt::write::hfb97b04d44bdb4d8
   2:        0x102860abc - std::io::Write::write_fmt::h686d9784d8415cb9
   3:        0x1028620bf - std::panicking::default_hook::{{closure}}::ha298777f08731ac8
   4:        0x102861d4f - std::panicking::default_hook::hb5f65353eb4f3d66
   5:        0x1028627d2 - std::panicking::rust_panic_with_hook::he911070515b336d8
   6:        0x102876462 - std::panicking::begin_panic_handler::{{closure}}::h752456daaf48f28e
   7:        0x1028762a8 - std::sys_common::backtrace::__rust_end_short_backtrace::hc10b12502582d9b6
   8:        0x1028622ed - _rust_begin_unwind
   9:        0x102891c43 - core::panicking::panic_fmt::hc606b9962be5fb74
  10:        0x102891b27 - core::panicking::panic::h5459910156e8485f
  11:        0x1027cc3ae - sbnf::compiler::codegen::lookahead::Lookahead::concatenate::h7d24fa81884601e5
  12:        0x1027cf0c2 - sbnf::compiler::codegen::lookahead::advance_terminal::h0cb103cbbe3eaaa2
  13:        0x1027be4ba - sbnf::compiler::codegen::gen_contexts::hf9860dea2b38e497
  14:        0x1027c1b49 - sbnf::compiler::codegen::gen_contexts::hf9860dea2b38e497
  15:        0x1027c1b49 - sbnf::compiler::codegen::gen_contexts::hf9860dea2b38e497
  16:        0x1027bcc2c - sbnf::compiler::codegen::codegen::he15295d34c267b1c
  17:        0x1027a46f7 - sbnf::compiler::<impl sbnf::compiler::common::Compiler>::compile::h13e67923474829e8
  18:        0x10278f6aa - sbnf::main::hdfa69efdab621c46
  19:        0x102788f66 - std::sys_common::backtrace::__rust_begin_short_backtrace::hfc70961e13c1c14a
  20:        0x10278a0bc - std::rt::lang_start::{{closure}}::hebc75a2c16d5dcad
  21:        0x102860248 - std::rt::lang_start_internal::h7de129d052efa930
  22:        0x10279047f - _main
BenjaminSchaaf commented 1 year ago

I reduced this to a minimal example:

main : (~any)* ;
any
: `(`{open} (~any)* `)`{close}
| 'end'{end1}
| 'drop'{drop} 'if'{if}?
| 'natural'{natural}? 'end'{end2}
;

I've got a fix for that, but there's still something it doesn't like in your grammar. After fixing another issue it now never halts.