ANTLR:输入语法没有可行的选择'语法'

时间:2014-12-30 01:00:14

标签: antlr

我已经创建了如下语法,但我收到错误消息“第1行:0输入'语法'没有可行的选择”。我的语法有问题吗?

=================语法开始============================ =====


    grammar SglV1;

    parse
     : sgl_stmt
     ;

    sgl_stmt
     : create_stream_stmt 
     | drop_stream_stmt
     ;

    create_stream_stmt
     :K_CREATE K_STREAM IDENTIFIER '.' IDENTIFIER K_AS factored_pick_stmt
     ;

    drop_stream_stmt
     : K_DROP K_STREAM  IDENTIFIER '.' IDENTIFIER
     ;

    factored_pick_stmt
     : pick_core ( compound_operator pick_core )*
     ;

    pick_core
     : K_PICK ( K_TOP NUMERIC_LITERAL )? K_WHERE expr 
     ;

    expr
     : STRING_LITERAL
     | IDENTIFIER '.' IDENTIFIER 
     | expr ( '==' | '' ) expr
     | expr K_AND expr
     | expr K_OR expr
     | '(' expr ')'
     ;

    compound_operator
     : K_UNION
     | K_INTERSECT
     | K_EXCEPT
     ;


    keyword
     : K_ABORT
     | K_ACTION
     | K_ADD
     | K_AFTER
     | K_ALL
     | K_ALTER
     | K_ANALYZE
     | K_AND
     | K_AS
     | K_ASC
     | K_ATTACH
     | K_AUTOINCREMENT
     | K_BEFORE
     | K_BEGIN
     | K_BETWEEN
     | K_BY
     | K_CASCADE
     | K_CASE
     | K_CAST
     | K_CHECK
     | K_COLLATE
     | K_COLUMN
     | K_COMMIT
     | K_CONFLICT
     | K_CONSTRAINT
     | K_CREATE
     | K_CROSS
     | K_CURRENT_DATE
     | K_CURRENT_TIME
     | K_CURRENT_TIMESTAMP
     | K_DATABASE
     | K_DEFAULT
     | K_DEFERRABLE
     | K_DEFERRED
     | K_DELETE
     | K_DESC
     | K_DETACH
     | K_DISTINCT
     | K_DROP
     | K_EACH
     | K_ELSE
     | K_END
     | K_ESCAPE
     | K_EXCEPT
     | K_EXCLUSIVE
     | K_EXISTS
     | K_EXPLAIN
     | K_FAIL
     | K_FOR
     | K_FOREIGN
     | K_FROM
     | K_FULL
     | K_GLOB
     | K_GROUP
     | K_HAVING
     | K_IF
     | K_IGNORE
     | K_IMMEDIATE
     | K_IN
     | K_INDEX
     | K_INDEXED
     | K_INITIALLY
     | K_INNER
     | K_INSERT
     | K_INSTEAD
     | K_INTERSECT
     | K_INTO
     | K_IS
     | K_ISNULL
     | K_JOIN
     | K_KEY
     | K_LEFT
     | K_LIKE
     | K_TOP
     | K_MATCH
     | K_NATURAL
     | K_NO
     | K_NOT
     | K_NOTNULL
     | K_NULL
     | K_OF
     | K_OFFSET
     | K_ON
     | K_OR
     | K_ORDER
     | K_OUTER
     | K_PLAN
     | K_PRAGMA
     | K_PRIMARY
     | K_QUERY
     | K_RAISE
     | K_RECURSIVE
     | K_REFERENCES
     | K_REGEXP
     | K_REINDEX
     | K_RELEASE
     | K_RENAME
     | K_REPLACE
     | K_RESTRICT
     | K_RIGHT
     | K_ROLLBACK
     | K_ROW
     | K_SAVEPOINT
     | K_PICK
     | K_SET
     | K_STREAM
     | K_TEMP
     | K_TEMPORARY
     | K_THEN
     | K_TO
     | K_TRANSACTION
     | K_TRIGGER
     | K_UNION
     | K_UNIQUE
     | K_UPDATE
     | K_USING
     | K_VACUUM
     | K_VALUES
     | K_VIEW
     | K_VIRTUAL
     | K_WHEN
     | K_WHERE
     | K_WITH
     | K_WITHOUT
     ;

    SCOL : ';';
    DOT : '.';
    OPEN_PAR : '(';
    CLOSE_PAR : ')';
    COMMA : ',';
    STAR : '*';
    PLUS : '+';
    MINUS : '-';
    TILDE : '~';
    PIPE2 : '||';
    DIV : '/';
    MOD : '%';
    LT2 : '>';
    AMP : '&';
    PIPE : '|';
    LT : '';
    GT_EQ : '>=';
    EQ : '==';
    NOT_EQ : '';


    K_ABORT : A B O R T;
    K_ACTION : A C T I O N;
    K_ADD : A D D;
    K_AFTER : A F T E R;
    K_ALL : A L L;
    K_ALTER : A L T E R;
    K_ANALYZE : A N A L Y Z E;
    K_AND : A N D;
    K_AS : A S;
    K_ASC : A S C;
    K_ATTACH : A T T A C H;
    K_AUTOINCREMENT : A U T O I N C R E M E N T;
    K_BEFORE : B E F O R E;
    K_BEGIN : B E G I N;
    K_BETWEEN : B E T W E E N;
    K_BY : B Y;
    K_CASCADE : C A S C A D E;
    K_CASE : C A S E;
    K_CAST : C A S T;
    K_CHECK : C H E C K;
    K_COLLATE : C O L L A T E;
    K_COLUMN : C O L U M N;
    K_COMMIT : C O M M I T;
    K_CONFLICT : C O N F L I C T;
    K_CONSTRAINT : C O N S T R A I N T;
    K_CREATE : C R E A T E;
    K_CROSS : C R O S S;
    K_CURRENT_DATE : C U R R E N T '_' D A T E;
    K_CURRENT_TIME : C U R R E N T '_' T I M E;
    K_CURRENT_TIMESTAMP : C U R R E N T '_' T I M E S T A M P;
    K_DATABASE : D A T A B A S E;
    K_DEFAULT : D E F A U L T;
    K_DEFERRABLE : D E F E R R A B L E;
    K_DEFERRED : D E F E R R E D;
    K_DELETE : D E L E T E;
    K_DESC : D E S C;
    K_DETACH : D E T A C H;
    K_DISTINCT : D I S T I N C T;
    K_DROP : D R O P;
    K_EACH : E A C H;
    K_ELSE : E L S E;
    K_END : E N D;
    K_ESCAPE : E S C A P E;
    K_EXCEPT : E X C E P T;
    K_EXCLUSIVE : E X C L U S I V E;
    K_EXISTS : E X I S T S;
    K_EXPLAIN : E X P L A I N;
    K_FAIL : F A I L;
    K_FOR : F O R;
    K_FOREIGN : F O R E I G N;
    K_FROM : F R O M;
    K_FULL : F U L L;
    K_GLOB : G L O B;
    K_GROUP : G R O U P;
    K_HAVING : H A V I N G;
    K_IF : I F;
    K_IGNORE : I G N O R E;
    K_IMMEDIATE : I M M E D I A T E;
    K_IN : I N;
    K_INDEX : I N D E X;
    K_INDEXED : I N D E X E D;
    K_INITIALLY : I N I T I A L L Y;
    K_INNER : I N N E R;
    K_INSERT : I N S E R T;
    K_INSTEAD : I N S T E A D;
    K_INTERSECT : I N T E R S E C T;
    K_INTO : I N T O;
    K_IS : I S;
    K_ISNULL : I S N U L L;
    K_JOIN : J O I N;
    K_KEY : K E Y;
    K_LEFT : L E F T;
    K_LIKE : L I K E;
    K_TOP : T O P;
    K_MATCH : M A T C H;
    K_NATURAL : N A T U R A L;
    K_NO : N O;
    K_NOT : N O T;
    K_NOTNULL : N O T N U L L;
    K_NULL : N U L L;
    K_OF : O F;
    K_OFFSET : O F F S E T;
    K_ON : O N;
    K_OR : O R;
    K_ORDER : O R D E R;
    K_OUTER : O U T E R;
    K_PLAN : P L A N;
    K_PRAGMA : P R A G M A;
    K_PRIMARY : P R I M A R Y;
    K_QUERY : Q U E R Y;
    K_RAISE : R A I S E;
    K_RECURSIVE : R E C U R S I V E;
    K_REFERENCES : R E F E R E N C E S;
    K_REGEXP : R E G E X P;
    K_REINDEX : R E I N D E X;
    K_RELEASE : R E L E A S E;
    K_RENAME : R E N A M E;
    K_REPLACE : R E P L A C E;
    K_RESTRICT : R E S T R I C T;
    K_RIGHT : R I G H T;
    K_ROLLBACK : R O L L B A C K;
    K_ROW : R O W;
    K_SAVEPOINT : S A V E P O I N T;
    K_PICK : P I C K;
    K_SET : S E T;
    K_STREAM : S T R E A M ;
    K_TEMP : T E M P;
    K_TEMPORARY : T E M P O R A R Y;
    K_THEN : T H E N;
    K_TO : T O;
    K_TRANSACTION : T R A N S A C T I O N;
    K_TRIGGER : T R I G G E R;
    K_UNION : U N I O N;
    K_UNIQUE : U N I Q U E;
    K_UPDATE : U P D A T E;
    K_USING : U S I N G;
    K_VACUUM : V A C U U M;
    K_VALUES : V A L U E S;
    K_VIEW : V I E W;
    K_VIRTUAL : V I R T U A L;
    K_WHEN : W H E N;
    K_WHERE : W H E R E;
    K_WITH : W I T H;
    K_WITHOUT : W I T H O U T;

    IDENTIFIER
     : [a-zA-Z_] [a-zA-Z_0-9]* 
     ;

    NUMERIC_LITERAL
     : DIGIT+ ( '.' DIGIT* )? ( E [-+]? DIGIT+ )?
     | '.' DIGIT+ ( E [-+]? DIGIT+ )?
     ;

    STRING_LITERAL
     : '\'' ( ~'\'' | '\'\'' )* '\''
     ;

    SINGLE_LINE_COMMENT
     : '--' ~[\r\n]* -> channel(HIDDEN)
     ;

    SPACES
     : [ \u000B\t\r\n] -> channel(HIDDEN)
     ;

    UNEXPECTED_CHAR
     : .
     ;

    fragment DIGIT : [0-9];

    fragment A : [A];
    fragment B : [B];
    fragment C : [C];
    fragment D : [D];
    fragment E : [E];
    fragment F : [F];
    fragment G : [G];
    fragment H : [H];
    fragment I : [I];
    fragment J : [J];
    fragment K : [K];
    fragment L : [L];
    fragment M : [M];
    fragment N : [N];
    fragment O : [O];
    fragment P : [P];
    fragment Q : [Q];
    fragment R : [R];
    fragment S : [S];
    fragment T : [T];
    fragment U : [U];
    fragment V : [V];
    fragment W : [W];
    fragment X : [X];
    fragment Y : [Y];
    fragment Z : [Z];

======语法结束==============

0 个答案:

没有答案