Hadron67 / tscc-compiler

An LALR(1) parser generator written in Typescript

Home Page:https://hadroncfy.com/tscc-compiler/web-demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to show line/col on rule conflicts ?

mingodad opened this issue · comments

Trying an alternative online playground for tscc here https://meimporta.eu/TsccYaccLex/playground.html I want to be able to click on the conflict messages and the editor jump to the line/col of it, I already got something close but all line/col info are the one from the head lhs of the rule instead of the sub rule.

To see it go to https://meimporta.eu/TsccYaccLex/playground.html select JZend using the select in the upper middle screen then comment this line:

//%left '*' '/' '%'

Now click the Parse button (upper left corner) to get this messages:

Warning: state 75, shift/reduce conflict:
    token: "*"
    used rule: [ 112: expr_without_var => expr . "*" expr ]* (line 600, column 0)
    discarded rule: [ 118: expr_without_var => "+" expr . ]*  (line 600, column 0)
Warning: state 75, shift/reduce conflict:
    token: "/"
    used rule: [ 113: expr_without_var => expr . "/" expr ]* (line 600, column 0)
    discarded rule: [ 118: expr_without_var => "+" expr . ]*  (line 600, column 0)
Warning: state 75, shift/reduce conflict:
    token: "%"
    used rule: [ 114: expr_without_var => expr . "%" expr ]* (line 600, column 0)
    discarded rule: [ 118: expr_without_var => "+" expr . ]*  (line 600, column 0)
...

I would like to have the line/col of each used/discarded rule correctly pointing to then.

Could you give any help on it ?

This is based on https://github.com/yhirose/cpp-peglib playground here https://yhirose.github.io/cpp-peglib/
and also https://github.com/ChrisHixon/chpeg playground here https://chrishixon.github.io/chpeg/playground/
and https://github.com/mingodad/CocoR-Typescript playground here https://mingodad.github.io/CocoR-Typescript/playground

Cheers !

Also the line/col numbers seem to be zero based and that doesn't match what editors use to jump/show then.