Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.
/ zig-spec Public archive

parser: improve error reporting#42

Merged
Vexu merged 1 commit intoziglang:masterfrom
perillo:improve-parser-error-report
Dec 26, 2022
Merged

parser: improve error reporting#42
Vexu merged 1 commit intoziglang:masterfrom
perillo:improve-parser-error-report

Conversation

@perillo
Copy link
Contributor

@perillo perillo commented Dec 25, 2022

In main.c, define the macro YY_CTX_LOCAL in order to have access to the parsing context and the macro YY_INPUT in order to have access to the current line number. In order to make these macro visible to parser.c, include parser.c in main.c.

Add the yyerror function for improved error report, showing the current line and additional context.

Update the Makefile, removing the full.c file.

@perillo
Copy link
Contributor Author

perillo commented Dec 25, 2022

The yyerror function has been adapted from https://github.com/gpakosz/peg/blob/upstream/src/peg.c#L51.

@perillo perillo force-pushed the improve-parser-error-report branch from 76125d4 to cd64141 Compare December 25, 2022 19:35
In main.c, define the macro YY_CTX_LOCAL in order to have access to the
parsing context and the macro YY_INPUT in order to have access to the
current line number.  In order to make these macro visible to parser.c,
include parser.c in main.c.

Add the yyerror function for improved error report, showing the current
line and additional context.

Update the Makefile, removing the full.c file.
@perillo perillo force-pushed the improve-parser-error-report branch from cd64141 to e1bd6c3 Compare December 25, 2022 19:37
@perillo perillo mentioned this pull request Dec 26, 2022
6 tasks
@Vexu Vexu merged commit b1e25d9 into ziglang:master Dec 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants