Skip to content

Instantly share code, notes, and snippets.

@kalkin
Created March 12, 2016 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalkin/f0a64ff21cfbf7310d3d to your computer and use it in GitHub Desktop.
Save kalkin/f0a64ff21cfbf7310d3d to your computer and use it in GitHub Desktop.
my token tag { '%' \w+ }
my token id { '#' \w+ }
my token css-class { '.' \w+ }
my token level-token { ' ' }
my token text { .+ }
my rule element {<tag>?<id>?<css-class>*\s* }
my token line {^^ <level-token>* [<element>]* $$}
# ^ This hangsup the whole rakudo
like '%p', &line;
like '%p#asd', &line;
like '#asd', &line;
like '.foo', &line;
like '%body.asd.foo', &line;
like '%head#asd.foo', &line;
unlike '#asd#foo', &line;
unlike '%hear#asd#foo', &line, "Two id\'s on one element are not allowed";
unlike '%head%asd.foo', &line;
unlike '#head#asd%foo', &line;
unlike ' %head', &line;
like ' %head', &line;
unlike ' %head', &line;
like '%body %textsdasd', &line; # <= Trying to parse this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment