I know we can identify if a token is a string literal.
But, can we identify if that string literal has a specific value? How?
goal:
I want to highlight the 2nd parameter of TO_DATE if and only if the value is 'DD-MON-RR'.
(Preferred goal: match against a regular expression)
I can identify the second parameter but I can't figure out how to match it to 'DD-MON-RR'.
TwoDigitYear: -- modified from https://community.oracle.com/thread/4272273
( [td^) function_call
| [td^) datetime_literal
| [td^) function_expression
) & ?td = 'TO_DATE'
& [node) string_literal
&(-- for function_call
( -- case 1 : node is identified as part of an arg_list
( [node^) arg_list | [node^^) arg_list )
& ( [node^^) paren_expr_list | [node^^^) paren_expr_list )
& ! [node-1-1) arg_list
)
| ( -- case 2 : node is identified as part of something else
[node-1) ',' & [node-1-1) string_literal & [node-1-1-1) '('
)
)
& td^ < node
-- ?node = '''DD-MON-RR''' -- did not work
;
Test Code
declare
d date;
begin
d := to_date( '12:12:45', 'HH24:MI:SS' );
d := to_date( '5-may-19', 'DD-MON-RR' );
d := to_date( abc, 'HH24:MI:SS' );
d := to_date( defg, 'DD-MON-RR' );
d := to_date( f('xyh'), 'DD-mon-yyyy', 'nls setting' );
d := to_date( f('xyh'), 'DD-MON-RR', 'nls setting' );
commit;
end;
/
Thanks
MK