Skip to content

Instantly share code, notes, and snippets.

@bryan-ash
Created January 6, 2010 01:17
Show Gist options
  • Save bryan-ash/269915 to your computer and use it in GitHub Desktop.
Save bryan-ash/269915 to your computer and use it in GitHub Desktop.
Treetop rules for optional and mandatory spaces (thanks Clifford Heath)
rule s # Optional space
S?
end
rule S # Mandatory space
(white / comment_to_eol / comment_c_style)+
end
rule white
[ \t\n\r]+
end
rule comment_to_eol
'//' (!"\n" .)+
end
rule comment_c_style
'/*' (!'*/' . )* '*/'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment