You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@iotdb.apache.org by "Xiangdong Huang (Jira)" <ji...@apache.org> on 2021/04/05 03:27:00 UTC

[jira] [Created] (IOTDB-1280) Rewrite the Antlr grammar file

Xiangdong Huang created IOTDB-1280:
--------------------------------------

             Summary: Rewrite the Antlr grammar file
                 Key: IOTDB-1280
                 URL: https://issues.apache.org/jira/browse/IOTDB-1280
             Project: Apache IoTDB
          Issue Type: Task
          Components: Planner/SQLParser
            Reporter: Xiangdong Huang


Current antlr g4 file is not elegant.

1. We should realize that Lexer and Parser having different usage:
 - Lexer is for considering something into one "word", i.e., a string that will not be split in users' program.  E.g., "abcdere324234", "-2.0", "-2e5", "root.sg.a.b" (if we do not split the path any more... which is impossible). All rules that belong to Lexer should start with a Capital Char.

- Parser is for generating AST. According to Antlr's introduction articles, parser is more time consuming than lexer.  The fewer rules that parser has, the faster.
That is, if something can be defined in Lexer, we should not define them as parser.
IMO, the principle is: 
 - if we need to split a word into several words, then put the rule into parser; E.g., "1h"/"1m", as we have to split the word and get its time unit, why not define it as two words directly in Antlr (i.e., do not define  a lexer rule like: "DURATION: (INT+ (Y|M O|W|D|H|M|S|M S|U S|N S))+")?


More, we can test whether a lexer is fast enough for checking a Path. If so, we do not define another Pattern in our program to check whether a  time series name is legal.




--
This message was sent by Atlassian Jira
(v8.3.4#803005)