Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 323bbee16a
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (35 sloc) 2.027 kb
grammar Canopy.PEG
grammar <- space* grammar_name
rules:(space* grammar_rule)+ space*
grammar_name <- "grammar " object_identifier
grammar_rule <- identifier assignment parsing_expression
assignment <- space+ "<-" space+
parsing_expression <- choice_expression / choice_part
parenthesised_expression <- "(" space* parsing_expression space* ")"
choice_expression <- first_part:choice_part
rest:(space+ "/" space+ expression:choice_part)+
choice_part <- (sequence_expression / sequence_part)
(space+ type_expression)?
type_expression <- "<" object_identifier ">"
sequence_expression <- first_part:sequence_part
rest:(space+ expression:sequence_part)+
sequence_part <- label? expression:(quantified_atom / atom)
quantified_atom <- atom quantifier
atom <- parenthesised_expression
/ predicated_atom
/ reference_expression
/ string_expression
/ ci_string_expression
/ any_char_expression
/ char_class_expression
predicated_atom <- predicate:("&" / "!") atom
reference_expression <- identifier !assignment
string_expression <- "\"" ("\\" . / [^"])* "\""
ci_string_expression <- "`" ("\\" . / [^`])* "`"
any_char_expression <- "."
char_class_expression <- "[" "^"? ("\\" . / [^\]])+ "]"
label <- identifier ":"
object_identifier <- identifier ("." identifier)*
identifier <- [a-zA-Z_$] [a-zA-Z0-9_$]*
quantifier <- "?" / "*" / "+"
space <- [\s\n\r\t]
Jump to Line
Something went wrong with that request. Please try again.