Skip to content

double-quoted regular expression extensions of posix lex #540

Open
@ratmice

Description

@ratmice

While I was considering looking into #417 it caught my eye that "{foo}" match the string {foo} literally rather than a substitution string.
This one also goes under the banner of behavior where lrlex passes regular expressions directly to the rust regex crate.

Currently for the following lex file:

%%
"hello" "hello"
"[abc]" "x"
[\n\ ] ;

When we run it through lrlex, it treats the first case as matching "hello" including the quotes,
and it treats the second case, as matching the characters "a", "b", ... including the quotes.

$ echo \"a\" \"hello\" | lrlex test.l -
x "a"
hello "hello"

According to POSIX:
"..."
Any string enclosed in double-quotes shall represent the characters within the double-quotes as themselves, except that -escapes (which appear in the following table) shall be recognized. Any -escape sequence shall be terminated by the closing quote. For example, "\01" "1" represents a single string: the octal value 1 followed by the character '1'.

So the expected matching input should probably be something along the lines of:

$ echo '[abc] hello' | lrlex test.l -
x "[abc]"
hello "hello"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions