Quodatum / xqlint

XQuery Quality Checker
https://www.npmjs.com/package/@quodatum/xqlint
Apache License 2.0
1 stars 0 forks source link

AST missing last tokens when syntax error #8

Open apb2006 opened 2 years ago

apb2006 commented 2 years ago

Running in https://github.com/wcandillon/xqlint

var XQLint = require('../lib/xqlint').XQLint;
var linter = new XQLint('2 +');
console.log(linter.printAST());

The XQueryParser is

// This file was generated on Fri Apr 10, 2015 00:54 (UTC+01) by REx v5.33 which is Copyright (c) 1979-2015 by Gunther Rademacher <grd@gmx.net>
// REx command line: XQueryParser.ebnf -ll 2 -backtrack -tree -javascript -a xqlint

result

<XQuery>
    <Module>
      <MainModule>
        <Prolog>
        </Prolog>
        <Program>
          <StatementsAndOptionalExpr>
            <Statements>
            </Statements>
            <Expr>
              <ExprSingle>
                <ExprSimple>
                  <AdditiveExpr>
                    <PrimaryExpr>
                      <Literal>
                        <NumericLiteral>
                          <IntegerLiteral>2</IntegerLiteral>
                          <IntegerLiteral>
                          </IntegerLiteral>
                        </NumericLiteral>
                      </Literal>
                    </PrimaryExpr>
                    <WS> </WS>
                    <WS>
                    </WS>
                    <TOKEN>+</TOKEN>
                    <TOKEN>
                    </TOKEN>
                  </AdditiveExpr>
                </ExprSimple>
              </ExprSingle>
            </Expr>
          </StatementsAndOptionalExpr>
        </Program>
      </MainModule>
    </Module>
  </XQuery>
apb2006 commented 2 years ago

Here

// This file was generated on Sat Feb 19, 2022 22:44 (UTC) by REx v5.55 which is Copyright (c) 1979-2022 by Gunther Rademacher <grd@gmx.net>
// REx command line: XQueryParser.ebnf -ll 2 -backtrack -tree -javascript -a xqlint

the + is missing

<XQuery>
   <Module>
    <MainModule>
     <Prolog>
     </Prolog>
     <QueryBody>
      <Expr>
       <ExprSingle>
        <Literal>
         <NumericLiteral>
          <IntegerLiteral>4</IntegerLiteral>
         </NumericLiteral>
        </Literal>
       </ExprSingle>
      </Expr>
     </QueryBody>
    </MainModule>
   </Module>
  </XQuery>