Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Enhance context output of UnrecognizedToken exception #111

Open
ohader opened this issue Oct 6, 2020 · 0 comments
Open

Enhance context output of UnrecognizedToken exception #111

ohader opened this issue Oct 6, 2020 · 0 comments

Comments

@ohader
Copy link

ohader commented Oct 6, 2020

Grammar

%pragma		parser.lookahead 	0
%skip		space				\s
%token a	a+
%token b	b+
%token c	c+
#root:
    ( <a> | <b> | <c> )*

Source

a
b
c
d

Results

Parsing above scenario leads to expected exception, since lexeme d is not defined in grammar. In thrown UnrecognizedToken

  • line & column can be enhanced
  • (helpful) position pointer can be adjusted
Hoa\Compiler\Exception\UnrecognizedToken: Unrecognized token "d" at line 1 and column 7:
a
b
c
d
      ↑ in /Users/olly/Development/Packages/fluid-compiler/vendor/hoa/compiler/Llk/Lexer.php on line 1

With adjustments

Hoa\Compiler\Exception\UnrecognizedToken: Unrecognized token "d" at line 4 and column 1:
a
b
c
d
↑ in /Users/olly/Development/Packages/fluid-compiler/vendor/hoa/compiler/Llk/Lexer.php on line 1
@ohader ohader changed the title Enhance context output of UnrecognizedToken Enhance context output of UnrecognizedToken exception Oct 6, 2020
ohader added a commit to ohader/Compiler that referenced this issue Oct 6, 2020
* enhances `UnrecognizedToken` exception, see hoaproject#111
* enhances `UnexpectedToken` exception, see hoaproject#112

Fixes: hoaproject#111, hoaproject#112
ohader added a commit to ohader/Compiler that referenced this issue Oct 6, 2020
* enhances `UnrecognizedToken` exception, see hoaproject#111
* enhances `UnexpectedToken` exception, see hoaproject#112

Fixes: hoaproject#111, hoaproject#112
sanmai added a commit to sanmai/hoa-compiler that referenced this issue Oct 7, 2020
[TASK] Add more context to exceptions

* enhances `UnrecognizedToken` exception, see hoaproject/Compiler#111
* enhances `UnexpectedToken` exception, see hoaproject/Compiler#112

[BUGFIX] Allow colons in PCRE part of default namespace

See: hoaproject/Compiler#113
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant