You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An issue came up recently regarding the capability to enforce specific syntaxes for duration and time units literals.
An example of the latter is the time_agg function which requires a time unit parameter.
The commented-out TIME_UNITlexer rule conflicts with the IDENTIFIER rule as to restrict some single-letter identifiers like A, D, M, Q, H.
This could be alleviated by changing a list of parser rules (i.e. alias, varID, simpleComponentID, ...) to include both IDENTIFIER and TIME_UNIT, but this change might require an engine adaptation, or otherwise force the user to single-quote the identifier (and us to perform a broad revision of grammar tests).
Another possibility is to use double-quoted time units, but this again conflicts with the STRING_CONSTANT rule and has a much larger impact.
For duration literals like P1Y6M, the reasoning is the same, though the conclusion could be different, because the duration literals can be restricted not to be valid identifiers (the number of conflicts is much less than with the TIME_UNIT rule).
These are my proposals for TIME_UNIT and DURATION lexer rules:
lexer grammar VtlTokens;
TIME_UNIT: A | S | Q | M | W | D;
fragment DUR_D: (0-9)+D
fragment DUR_W: (0-9)+ W DUR_D? | DUR_D
fragment DUR_M: (0-9)+ M DUR_W? | DUR_W
fragment DUR_Q: (0-9)+ Q DUR_M? | DUR_M
fragment DUR_S: (0-9)+ S DUR_Q? | DUR_Q
DURATION: P (0-9)+ Y DUR_S? | P DUR_S
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
An issue came up recently regarding the capability to enforce specific syntaxes for duration and time units literals.
An example of the latter is the time_agg function which requires a time unit parameter.
The commented-out
TIME_UNIT
lexer rule conflicts with theIDENTIFIER
rule as to restrict some single-letter identifiers like A, D, M, Q, H.This could be alleviated by changing a list of parser rules (i.e.
alias
,varID
,simpleComponentID
, ...) to include bothIDENTIFIER
andTIME_UNIT
, but this change might require an engine adaptation, or otherwise force the user to single-quote the identifier (and us to perform a broad revision of grammar tests).Another possibility is to use double-quoted time units, but this again conflicts with the
STRING_CONSTANT
rule and has a much larger impact.For duration literals like
P1Y6M
, the reasoning is the same, though the conclusion could be different, because the duration literals can be restricted not to be valid identifiers (the number of conflicts is much less than with theTIME_UNIT
rule).These are my proposals for
TIME_UNIT
andDURATION
lexer rules:Beta Was this translation helpful? Give feedback.
All reactions