Skip to content

Instantly share code, notes, and snippets.

@Varriount
Created July 24, 2018 05:59
Show Gist options
  • Save Varriount/0cabcc4998f6f784b554bbe31ea16f37 to your computer and use it in GitHub Desktop.
Save Varriount/0cabcc4998f6f784b554bbe31ea16f37 to your computer and use it in GitHub Desktop.
import pegs
let p = peg"""
function_call <- \ident '(' parameters ')'
parameters <- (parens / string / [^)] )*
parens <- '(' parameters ')'
string <- dq_string / sq_string
dq_string <- DQUOTE (BSLASH . / [^DQUOTE])* DQUOTE
sq_string <- SQUOTE (BSLASH . / [^SQUOTE])* SQUOTE
DQUOTE <- '"'
SQUOTE <- "'"
BSLASH <- "\\"
"""
echo match("hello(a b c)", p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment