Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7444155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:27:02+00:00 2026-05-29T11:27:02+00:00

For my own interests I am writing an ANSI SQL Lexer. Specifically, I am

  • 0

For my own interests I am writing an ANSI SQL Lexer. Specifically, I am trying to conform to ISO/IEC 9075-2:2003(E). I ran into a problem in the token stage with some ambiguity.

The lexical elements section define an interval string as follows:

<interval string> ::= <quote> <unquoted interval string> <quote>
<unquoted interval string> ::= [ <sign> ] { <year-month literal> | <day-time literal> }
<year-month literal> ::= <years value> [ <minus sign> <months value> ]  | <months value>
<years value> ::= <datetime value>
<months value> ::= <datetime value>
<datetime value> ::= <unsigned integer>
<unsigned integer> ::= <digit>...
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

Example:
’30’

Is the 30 a <years value> without the option
or is it a <months value>?

In theory I could write:
SELECT ’30’

I created a YearsValue token and a MonthsValue token (classes). However, the ambiguity is an issue, it matches both. I don’t see anything specifically dealing with multiple matches in part 1 or part 2 of ISO/IEC 9075.

Can someone point out where in the spec this is handled or is it just assumed left to right?

Before anyone asks, I am doing this because I want to write a SQL lexer. Its not for school its just something to educate myself. I don’t want to use GOLD or ANTLR either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:27:04+00:00Added an answer on May 29, 2026 at 11:27 am

    Is the 30 a <years value> without the option or is it a <months value>?

    Based on my reading of a draft of SQL 2003, it is left ambiguous in a way that doesn’t matter. Yes, the grammar does not specify whether the 1 in INTERVAL '1' YEAR is a <years value> or a <months value>, or even perhaps a <days value>, but it really does not matter. The description of how YEAR is interpreted is clear that 1 is a number of years, even if it is parsed as a <months value>. The standard says that the first component in the value is mapped to the first field type in the interval type:

    5.3 <literal>

    General Rules

    7) The i-th datetime component in a <datetime literal> or <interval literal> assigns the value of the datetime component to the i-th <primary datetime field> in the <datetime literal> or <interval literal>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking into writing an Android game, tough I don't curerntly own an Android
I am writing my own Firebird database browser using the ibpp library. Is there
I am writing my own programming language just for the fun of it. Currently
I am interested in writing my own internet ad server. I want to serve
I want to take an interest in writing my own simple emulator for the
I'm writing this question in the spirit of answering your own questions, since I
I'm trying to learn xpath by writing a simple program that will list the
Before I dive into writing a validator to check if a URL is actually
I'm writing a weak event factory - code which converts any Delegate into a
I'm interested in setting up my own website-based game (PBBG) as a hobby. Traffic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.