Skip to content

Instantly share code, notes, and snippets.

@Kimundi
Last active December 17, 2015 03:29
Show Gist options
  • Select an option

  • Save Kimundi/5543809 to your computer and use it in GitHub Desktop.

Select an option

Save Kimundi/5543809 to your computer and use it in GitHub Desktop.
Notes about how to best implement the re!() syntax extension in terms of syntax, behavior, and underlying api.

Full syntax:

re!(re_str
    [, engine 
        [(force|error on|warn on) runtime (compile|parse)]*
        [, engine_flags]
    ]
) -> CompiledRe

re!()'s contract: Accept static and non-static strings, any engine implementing either ReAstCompiler or ReStrCompiler, with compiletime guarantees degrading depending on inputs:

  • static re_str, build-in engine -> compiletime syntax check, compiletime compiled
  • static re_str, user supplied compilation engine -> compiletime syntax check, compiletime parsed, runtime compilation
  • static re_str, user supplied parsing engine or non-static re_str, build-in engine or non-static re_str, user supplied compilation engine or non-static re_str, user supplied parsing engine -> runtime parsed re, runtime compilation

parse failure: Could just use conditions (because it's generally unexpected unless enduser provided, and then you might probably want an custom validator anyway.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment