Skip to content

Commit

Permalink
[CUBVEC-12] Add VECTOR to Lexer and Parser (#5693)
Browse files Browse the repository at this point in the history
http://jira.cubrid.org/browse/CUBVEC-12

* feat(parser): add VECTOR token and PT_TYPE_VECTOR to parser

Create Table succeeds

* feat(csql_grammar.y): can create vector table with arguments

* fix(csql_grammar.y): remove unnecessary container initialization for readability

* fix(csql_grammar): get rid of obscure TODO and pass vector options to parent rule

* Update src/parser/csql_grammar.y

Co-authored-by: joonmin83 <[email protected]>

* docs(csql_grammar): todo: dim and type validation later

---------

Co-authored-by: joonmin83 <[email protected]>
  • Loading branch information
vimkim and hornetmj committed Dec 24, 2024
1 parent 5cb2a55 commit d3b3b73
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/parser/csql_grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ static int g_plcsql_text_pos;
%type <c2> class_name_with_server_name
%type <c2> opt_index_with_clause
%type <c2> index_with_item_list
%type <c2> opt_vector_args


/*}}}*/
Expand Down Expand Up @@ -1468,6 +1469,7 @@ static int g_plcsql_text_pos;
%token VARIABLE_
%token VARYING
%token VCLASS
%token VECTOR
%token VIEW
%token WHEN
%token WHENEVER
Expand Down Expand Up @@ -22119,8 +22121,49 @@ primitive_type

$$ = ctn;
DBG_PRINT}}
| VECTOR opt_vector_args
{{ DBG_TRACE_GRAMMAR(data_type, | vector_type);

container_2 ctn;
SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_VECTOR), NULL);
$$ = ctn;

// TODO: The opt_vector_args are not covered in this milestone.
// Dimension and type validation for VECTOR arguments must be included
// in the milestone that checks user input for correctness.


DBG_PRINT}}
;

opt_vector_args
: /* empty */
{{ DBG_TRACE_GRAMMAR(opt_vector_args, : );

container_2 ctn;
SET_CONTAINER_2 (ctn, NULL, NULL);
$$ = ctn;

DBG_PRINT}}
| '(' unsigned_integer ')'
{{ DBG_TRACE_GRAMMAR(opt_vector_args, | '(' unsigned_integer ')' );

container_2 ctn;
SET_CONTAINER_2 (ctn, $2, NULL);
$$ = ctn;

DBG_PRINT}}
| '(' unsigned_integer ',' FLOAT_ ')'
{{ DBG_TRACE_GRAMMAR(opt_vector_args, | '(' unsigned_integer ',' FLOAT_ ')' );

container_2 ctn;
SET_CONTAINER_2 (ctn, $2, FROM_NUMBER(PT_TYPE_FLOAT));
$$ = ctn;

DBG_PRINT}}
;


opt_internal_external
: /* empty */
{{ DBG_TRACE_GRAMMAR(opt_internal_external, : );
Expand Down
1 change: 1 addition & 0 deletions src/parser/csql_lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ IDL [a-zA-Z0-9_]
return VARIANCE; }
[vV][aA][rR][yY][iI][nN][gG] { begin_token(yytext); return VARYING; }
[vV][cC][lL][aA][sS][sS] { begin_token(yytext); return VCLASS; }
[vV][eE][cC][tT][oO][rR] { begin_token(yytext); return VECTOR; }
[vV][iI][eE][wW] { begin_token(yytext); return VIEW; }
[vV][iI][sS][iI][bB][lL][eE] { begin_token(yytext);
csql_yylval.cptr = pt_makename(yytext);
Expand Down
1 change: 1 addition & 0 deletions src/parser/parse_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ enum pt_type_enum
PT_TYPE_LOGICAL,
PT_TYPE_MAYBE,
PT_TYPE_JSON,
PT_TYPE_VECTOR,

/* special values */
PT_TYPE_NA, /* in SELECT NA */
Expand Down

0 comments on commit d3b3b73

Please sign in to comment.