Skip to content

Instantly share code, notes, and snippets.

@jakubkulhan
Created April 7, 2010 17:57
Show Gist options
  • Save jakubkulhan/359200 to your computer and use it in GitHub Desktop.
Save jakubkulhan/359200 to your computer and use it in GitHub Desktop.
toplevel = ys:element
(eol y:element -> { $ys = array_merge($ys, $y); } )*
-> $ys
block = ys:element
(eol samedent y:element -> { $ys = array_merge($ys, $y); } )*
-> $ys
element = n:name ":" spaces? eol indent b:block -> {
array_pop($this->indent);
return array($n => $b);
}
/ n:name ":" spaces? v:value -> array($n => $v)
samedent = s:spaces ?$s === implode("", $this->indent)
indent = s:spaces ?{
$prev = implode("", $this->indent);
if (strncmp($prev, $s, $l = strlen($prev)) === 0) {
array_push($this->indent, substr($s, $l));
return TRUE;
}
return FALSE;
}
eol = "\r\n" / "\n" / "\r"
spaces = [ \t]+
name = [a-zA-Z][a-zA-Z0-9_-]*
value = (!eol .)*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment