antlr / grammars-v4

Grammars written for ANTLR v4; expectation that the grammars are free of actions.
MIT License
10.26k stars 3.72k forks source link

PL/SQL:can't support `if var not member of var then` #4346

Open Dark-Athena opened 2 days ago

Dark-Athena commented 2 days ago
create type ty_a is object (b VARCHAR2(10));
/
CREATE TYPE TYT_a IS TABLE OF TY_A;
/
CREATE TYPE TYT_VARCHAR2 IS TABLE OF VARCHAR2(10);
/
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 
Connected as testuser@localhost:1531/oracledb

SQL> set serveroutput on
SQL> 
SQL> declare
  2  l_ty_a ty_a;
  3  L_TYT_A TYT_a:=TYT_a();
  4  L_TYT_VARCHAR2 TYT_VARCHAR2:=TYT_VARCHAR2();
  5  L INT;
  6  begin
  7    l_ty_a:=ty_a(1);
  8    L_TYT_A.EXTEND;
  9    L_TYT_A(1):=l_ty_a;
 10    L_TYT_VARCHAR2:=TYT_VARCHAR2('1');
 11  if L_TYT_A(1).B not member of L_TYT_VARCHAR2 then
 12    dbms_output.put_line('Y');
 13    else
 14    dbms_output.put_line('N');
 15  end if;
 16  L:=CASE WHEN L_TYT_A(1).B not member of L_TYT_VARCHAR2 THEN 1 END;
 17  end;
 18  /
N

PL/SQL procedure successfully completed

SQL> 

[@0,0:6='declare',<'DECLARE'>,1:0]
[@1,7:8='\r\n',<SPACES>,channel=1,1:7]
[@2,9:14='l_ty_a',<REGULAR_ID>,2:0]
[@3,15:15=' ',<SPACES>,channel=1,2:6]
[@4,16:19='ty_a',<REGULAR_ID>,2:7]
[@5,20:20=';',<';'>,2:11]
[@6,21:22='\r\n',<SPACES>,channel=1,2:12]
[@7,23:29='L_TYT_A',<REGULAR_ID>,3:0]
[@8,30:30=' ',<SPACES>,channel=1,3:7]
[@9,31:35='TYT_a',<REGULAR_ID>,3:8]
[@10,36:37=':=',<':='>,3:13]
[@11,38:42='TYT_a',<REGULAR_ID>,3:15]
[@12,43:43='(',<'('>,3:20]
[@13,44:44=')',<')'>,3:21]
[@14,45:45=';',<';'>,3:22]
[@15,46:47='\r\n',<SPACES>,channel=1,3:23]
[@16,48:61='L_TYT_VARCHAR2',<REGULAR_ID>,4:0]
[@17,62:62=' ',<SPACES>,channel=1,4:14]
[@18,63:74='TYT_VARCHAR2',<REGULAR_ID>,4:15]
[@19,75:76=':=',<':='>,4:27]
[@20,77:88='TYT_VARCHAR2',<REGULAR_ID>,4:29]
[@21,89:89='(',<'('>,4:41]
[@22,90:90=')',<')'>,4:42]
[@23,91:91=';',<';'>,4:43]
[@24,92:93='\r\n',<SPACES>,channel=1,4:44]
[@25,94:94='L',<REGULAR_ID>,5:0]
[@26,95:95=' ',<SPACES>,channel=1,5:1]
[@27,96:98='INT',<'INT'>,5:2]
[@28,99:99=';',<';'>,5:5]
[@29,100:101='\r\n',<SPACES>,channel=1,5:6]
[@30,102:106='begin',<'BEGIN'>,6:0]
[@31,107:110='\r\n  ',<SPACES>,channel=1,6:5]
[@32,111:116='l_ty_a',<REGULAR_ID>,7:2]
[@33,117:118=':=',<':='>,7:8]
[@34,119:122='ty_a',<REGULAR_ID>,7:10]
[@35,123:123='(',<'('>,7:14]
[@36,124:124='1',<UNSIGNED_INTEGER>,7:15]
[@37,125:125=')',<')'>,7:16]
[@38,126:126=';',<';'>,7:17]
[@39,127:130='\r\n  ',<SPACES>,channel=1,7:18]
[@40,131:137='L_TYT_A',<REGULAR_ID>,8:2]
[@41,138:138='.',<'.'>,8:9]
[@42,139:144='EXTEND',<'EXTEND'>,8:10]
[@43,145:145=';',<';'>,8:16]
[@44,146:149='\r\n  ',<SPACES>,channel=1,8:17]
[@45,150:156='L_TYT_A',<REGULAR_ID>,9:2]
[@46,157:157='(',<'('>,9:9]
[@47,158:158='1',<UNSIGNED_INTEGER>,9:10]
[@48,159:159=')',<')'>,9:11]
[@49,160:161=':=',<':='>,9:12]
[@50,162:167='l_ty_a',<REGULAR_ID>,9:14]
[@51,168:168=';',<';'>,9:20]
[@52,169:172='\r\n  ',<SPACES>,channel=1,9:21]
[@53,173:186='L_TYT_VARCHAR2',<REGULAR_ID>,10:2]
[@54,187:188=':=',<':='>,10:16]
[@55,189:200='TYT_VARCHAR2',<REGULAR_ID>,10:18]
[@56,201:201='(',<'('>,10:30]
[@57,202:204=''1'',<CHAR_STRING>,10:31]
[@58,205:205=')',<')'>,10:34]
[@59,206:206=';',<';'>,10:35]
[@60,207:208='\r\n',<SPACES>,channel=1,10:36]
[@61,209:210='if',<'IF'>,11:0]
[@62,211:211=' ',<SPACES>,channel=1,11:2]
[@63,212:218='L_TYT_A',<REGULAR_ID>,11:3]
[@64,219:219='(',<'('>,11:10]
[@65,220:220='1',<UNSIGNED_INTEGER>,11:11]
[@66,221:221=')',<')'>,11:12]
[@67,222:222='.',<'.'>,11:13]
[@68,223:223='B',<REGULAR_ID>,11:14]
[@69,224:224=' ',<SPACES>,channel=1,11:15]
[@70,225:227='not',<'NOT'>,11:16]
[@71,228:228=' ',<SPACES>,channel=1,11:19]
[@72,229:234='member',<'MEMBER'>,11:20]
[@73,235:235=' ',<SPACES>,channel=1,11:26]
[@74,236:237='of',<'OF'>,11:27]
[@75,238:238=' ',<SPACES>,channel=1,11:29]
[@76,239:252='L_TYT_VARCHAR2',<REGULAR_ID>,11:30]
[@77,253:253=' ',<SPACES>,channel=1,11:44]
[@78,254:257='then',<'THEN'>,11:45]
[@79,258:262=' \r\n  ',<SPACES>,channel=1,11:49]
[@80,263:273='dbms_output',<REGULAR_ID>,12:2]
[@81,274:274='.',<'.'>,12:13]
[@82,275:282='put_line',<REGULAR_ID>,12:14]
[@83,283:283='(',<'('>,12:22]
[@84,284:286=''Y'',<CHAR_STRING>,12:23]
[@85,287:287=')',<')'>,12:26]
[@86,288:288=';',<';'>,12:27]
[@87,289:292='\r\n  ',<SPACES>,channel=1,12:28]
[@88,293:296='else',<'ELSE'>,13:2]
[@89,297:301=' \r\n  ',<SPACES>,channel=1,13:6]
[@90,302:312='dbms_output',<REGULAR_ID>,14:2]
[@91,313:313='.',<'.'>,14:13]
[@92,314:321='put_line',<REGULAR_ID>,14:14]
[@93,322:322='(',<'('>,14:22]
[@94,323:325=''N'',<CHAR_STRING>,14:23]
[@95,326:326=')',<')'>,14:26]
[@96,327:327=';',<';'>,14:27]
[@97,328:329='\r\n',<SPACES>,channel=1,14:28]
[@98,330:332='end',<'END'>,15:0]
[@99,333:333=' ',<SPACES>,channel=1,15:3]
[@100,334:335='if',<'IF'>,15:4]
[@101,336:336=';',<';'>,15:6]
[@102,337:338='\r\n',<SPACES>,channel=1,15:7]
[@103,339:339='L',<REGULAR_ID>,16:0]
[@104,340:341=':=',<':='>,16:1]
[@105,342:345='CASE',<'CASE'>,16:3]
[@106,346:346=' ',<SPACES>,channel=1,16:7]
[@107,347:350='WHEN',<'WHEN'>,16:8]
[@108,351:351=' ',<SPACES>,channel=1,16:12]
[@109,352:358='L_TYT_A',<REGULAR_ID>,16:13]
[@110,359:359='(',<'('>,16:20]
[@111,360:360='1',<UNSIGNED_INTEGER>,16:21]
[@112,361:361=')',<')'>,16:22]
[@113,362:362='.',<'.'>,16:23]
[@114,363:363='B',<REGULAR_ID>,16:24]
[@115,364:364=' ',<SPACES>,channel=1,16:25]
[@116,365:367='not',<'NOT'>,16:26]
[@117,368:368=' ',<SPACES>,channel=1,16:29]
[@118,369:374='member',<'MEMBER'>,16:30]
[@119,375:375=' ',<SPACES>,channel=1,16:36]
[@120,376:377='of',<'OF'>,16:37]
[@121,378:378=' ',<SPACES>,channel=1,16:39]
[@122,379:392='L_TYT_VARCHAR2',<REGULAR_ID>,16:40]
[@123,393:393=' ',<SPACES>,channel=1,16:54]
[@124,394:397='THEN',<'THEN'>,16:55]
[@125,398:398=' ',<SPACES>,channel=1,16:59]
[@126,399:399='1',<UNSIGNED_INTEGER>,16:60]
[@127,400:400=' ',<SPACES>,channel=1,16:61]
[@128,401:403='END',<'END'>,16:62]
[@129,404:404=';',<';'>,16:65]
[@130,405:406='\r\n',<SPACES>,channel=1,16:66]
[@131,407:409='end',<'END'>,17:0]
[@132,410:410=';',<';'>,17:3]
[@133,411:412='\r\n',<SPACES>,channel=1,17:4]
[@134,413:413='/',<'/'>,18:0]
[@135,414:415='\r\n',<SPACES>,channel=1,18:1]
[@136,416:415='<EOF>',<EOF>,19:0]
line 11:16 missing 'THEN' at 'not'
line 11:27 mismatched input 'of' expecting {'ABORT', ......}

line 16:8 missing {<EOF>, ';'} at 'WHEN'
(sql_script (unit_statement (anonymous_block declare (seq_of_declare_specs (declare_spec (variable_declaration (identifier (id_expression (regular_id l_ty_a))) (type_spec (type_name (id_expression (regular_id ty_a)))) ;)) (declare_spec (variable_declaration (identifier (id_expression (regular_id L_TYT_A))) (type_spec (type_name (id_expression (regular_id TYT_a)))) (default_value_part := (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id TYT_a)) (function_argument ( ))))))))))))))) ;)) (declare_spec (variable_declaration (identifier (id_expression (regular_id L_TYT_VARCHAR2))) (type_spec (type_name (id_expression (regular_id TYT_VARCHAR2)))) (default_value_part 
:= (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id TYT_VARCHAR2)) (function_argument ( ))))))))))))))) ;)) (declare_spec (variable_declaration (identifier (id_expression (regular_id L))) (type_spec (datatype (native_datatype_element INT))) ;))) begin (seq_of_statements (statement (assignment_statement (general_element (general_element_part (id_expression (regular_id l_ty_a)))) := (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id ty_a)) (function_argument ( (argument (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 1))))))))))))) )))))))))))))))) ; (statement (sql_statement (collection_method_call (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id L_TYT_A)))))))))))))) . EXTEND))) ; (statement (assignment_statement (general_element (general_element_part (id_expression (regular_id L_TYT_A)) (function_argument ( (argument (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 1))))))))))))) )))) := (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id l_ty_a)))))))))))))))) ; (statement (assignment_statement (general_element (general_element_part (id_expression (regular_id L_TYT_VARCHAR2)))) := (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id TYT_VARCHAR2)) (function_argument ( (argument (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string '1'))))))))))))) )))))))))))))))) ; (statement (if_statement if (condition (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (general_element (general_element (general_element_part (id_expression (regular_id L_TYT_A)) (function_argument ( (argument (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 1))))))))))))) )))) . (general_element_part (id_expression (regular_id B))))))))))))))) <missing 'THEN'> (seq_of_statements (statement (sql_statement (collection_method_call (expression (logical_expression (unary_logical_expression not (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id (non_reserved_keywords_pre12c member))))))))))))))) of L_TYT_VARCHAR2 then dbms_output . put_line ( 'Y' )))) ;) (else_part else (seq_of_statements (statement (call_statement (routine_name (identifier (id_expression (regular_id dbms_output))) . (id_expression (regular_id put_line))) (function_argument ( (argument (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string 'N'))))))))))))) )))) ;)) end if)) ; (statement (assignment_statement (general_element (general_element_part (id_expression (regular_id L)))) := (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id (non_reserved_keywords_pre12c CASE)))))))))))))))))) WHEN L_TYT_A ( 1 ) . B not member of L_TYT_VARCHAR2 THEN 1 END)) ; end ; /)
Dark-Athena commented 2 days ago

fix : https://github.com/antlr/grammars-v4/pull/4347