antlr - How to get terminals using ANTLR4 -


I just use ANTRR4 to write some grammar After writing the Java code in the input code, the ANLR generates the pers tree for me. However, after checking the syntax, I just need a terminal and I can not find any method that only returns to me every terminal. Grammar is listed below:

  Grammar XPR; Pram: State; State: (createSQL | insertSQL) ';' State * | (CreateSQL | insertSQL) ';' ?; CreateSQL: Create table name '(' et_f ')'; InsertSQL: The name ('(att_names)') in INSERT? Value '(' att_values ​​')'; Att_names: NAME ',' att_names | | NAME; Att_values: (NUM | str) (',' (NUM | str)) *; Str: '\' '. *? '\' '; Att_def: NAME ATTTYPE PRIMARYKEY | Name unpublished PRIMARYKEY ',' subatt_def | Name ATTTYPE ',' et_def | 'Name unpublished; Subatt_def: NAME ATTTYPE ',' subatt_def | 'Name unpublished; PRIMARYKEY: [PP] [RR] [Ii] [MM] [AA] [RR] [YAY] '' [KK] [EE] [yay]; ATTTYPE: 'varchar' '(' [1-3] INT ')' | 'Varchar' '(' [1- 9] ')' | 'Varchar' ('' 40 '') '| 'Int'; INSERT: [Ii] [NN] [SS] [EE] [RR] [TT]; INTO: [Ii] [NN] [TT] [OO]; Price: [VV] [AA] [LL] [UU] [EE] [SS]; NUM: [0-9] +; INT: [0- 9]; Make: [CC] [RR] [EE] [AA] [TT] [EE] ;; Table: [TT] [AA] [BB] [LL] [EE]; NAME: [a-zA-Z] ([a-z-A-z] | '_' | '-') *; NEWLINE: ['\ r'? '\ N'] - & gt; leave; TAB: [\ t];  

Input:

Table person (person_id varchar (25) primary key, year int, age int); Person (person_id, year, age) value ('i super man_line', 1988,25); Java code: Public class ANTLRDMO {Public Static Zero Main (string [] args) Exception {String inputfile = "T.XP.") throws; InputStream = New FileInputStream (inputFile); ANTLRInputStream input = new ANTLRInputStream (is); ExprLexer lexer = new ExprLexer (Input); Common Token Stream Token = New Common Token Stream (Lexer); ExprParser parser = new ExprParser (token); ParseTree tree = parser.prog (); System.out.println (tree.toStringTree (parser)}}

Can anyone help me? I just want to get a string array containing all the terminals ('' '' '' '' ',', '.)

Presterty:

  / ** Return the combined text of all the leaf nodes. If any * off-channel token (if any) does not receive it, it will not return white space and * comments when sent to parsed on hidden channels. * / String getText ();  

Ter


Comments

Popular posts from this blog

Editing Python Class in Shell and SQLAlchemy -

import - Python ImportError: No module named wmi -

uislider - In a MATLAB GUI, how does one implement a continuously varying slider from a GUIDE created .m file? -