Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1788

Simplify handling of position in the parser

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.13.0
    • Component/s: None
    • Labels:
      None

      Description

      Simplify handling of position in the parser by adding a class Span that keeps track of the tokens that have contributed to the current non-terminal.

      Some patterns:

      • final Span s; declaration of a Span at the top of a production
      • s = span(); initializes s to a Span that includes the token we just saw; very often occurs immediately after the first token in the production
      • s.end(this); adds the most recent token to span s and evaluates to a SqlParserPosition that spans from beginning to end; commonly used when making a call to a function
      • s.add(node); adds a SqlNode's parser position to a span
      • s.addAll(nodeList); adds several SqlNodes' parser positions to a span
      • s = Span.of(); initializes s to an empty Span, not even including the most recent token; rarely used

        Activity

        Hide
        julianhyde Julian Hyde added a comment -

        Please review https://github.com/julianhyde/calcite/tree/1788-parser. It's a big change, but I significant improvement, I think.

        Show
        julianhyde Julian Hyde added a comment - Please review https://github.com/julianhyde/calcite/tree/1788-parser . It's a big change, but I significant improvement, I think.
        Hide
        julianhyde Julian Hyde added a comment -

        Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/d6193040.

        This is a breaking change: Extension parsers will need to change the parameters to their methods from SqlParserPos to Span. The changes made to parserImpls.ftl should give a general idea what needs to be changed.

        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/d6193040 . This is a breaking change: Extension parsers will need to change the parameters to their methods from SqlParserPos to Span . The changes made to parserImpls.ftl should give a general idea what needs to be changed.
        Hide
        jcamachorodriguez Jesus Camacho Rodriguez added a comment -

        Resolved in release 1.13.0 (2017-06-26).

        Show
        jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.13.0 (2017-06-26).

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            julianhyde Julian Hyde
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development