Skip to content

SQL standard constant strings #700

Answered by zesterer
jennykwan asked this question in Q&A
Discussion options

You must be logged in to vote

So, I think there are two steps here.

  1. Recognising a valid 'string chain' (or whatever terminology SQL uses)

  2. Turning the string chain into the final string

The first step is usually to start off with the simplest case and then build up from there. Assuming your lexer/parser takes strings as inputs, the simplest case - matching just strings like 'foo' - might look something like this:

// Matches any character that is *not* the end of the string
let str_char = any().and_is(just('\'').not());
// Matches many string characters, delimited on both ends by `'`
// (`to_slice` is used to extract the inner characters only as the parser's output)
let str = str_char.repeated().to_slice().delimit…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jennykwan
Comment options

Answer selected by jennykwan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants