Skip to content

Instantly share code, notes, and snippets.

@derdewey
Created November 9, 2010 23:38
Show Gist options
  • Save derdewey/670054 to your computer and use it in GitHub Desktop.
Save derdewey/670054 to your computer and use it in GitHub Desktop.
Spits out tag/value pairs inside of package_list > package trees
grammar Debian
rule package_list
(package "\n"?)+
end
rule package
(tag / value)+ <DebianSyntaxNode::Package>
end
rule tag
tag_value tag_stop
end
rule tag_value
[\w\-]+ <DebianSyntaxNode::Tag>
end
rule tag_stop
": "
end
rule value
value_line value_stop
end
rule value_line
([\w \. " , \- ' : / < > @ ( ) = | \[ \] + ;])+ <DebianSyntaxNode::Value>
end
rule value_stop
"\n"?
end
# I should post to the mailing list about why this didn't work.
#rule entry_value
# ([\w \n\.",\-'":])+
#end
#rule entry
# entry_value entry_stop
#end
#rule entry_stop
# "\n" &tag
#end
#rule tag
# "\n"? tag_value tag_stop
#end
#rule tag_value
# ([\w\-])+
#end
#rule tag_stop
# ": "
#end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment