Skip to content

Instantly share code, notes, and snippets.

@omega

omega/Grammar.pm Secret

Created January 7, 2011 14:19
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 omega/6765af670a7371835a3a to your computer and use it in GitHub Desktop.
Save omega/6765af670a7371835a3a to your computer and use it in GitHub Desktop.
The problem is that the test of paragraph ends up in a never ending loop, and I don't really understand why..
use v6;
grammar JIRA::Formater::Wiki::Grammar {
token TOP {
<?DEBUG(1)>
<paragraph>*
}
regex blankline { \s* <.eol> }
regex pline { <?DEBUG(1)> (.*) <.eol> }
regex eof { $ }
regex eol { [ \n | <.eof> ] }
regex paragraph { <pline>+ } #[ <.blankline> | <.eof> ] }
}
use v6;
use Test;
BEGIN { push @*INC, './lib';}
use JIRA::Formater::Wiki::Grammar;
plan *;
my @strings =
"This is the first\nparagraph",
"This is the first\nparagraph\n\nAnd this is another one",
"This is the first\nparagraph\n\n* list\n\nAnd this is another one",
;
for @strings {
#my $match = JIRA::Formater::Wiki::Grammar.parse($_);
#isa_ok $match, Match, "the parser works for a full text";
#diag($match.perl);
}
ok JIRA::Formater::Wiki::Grammar.parse("", :rule<eol>), "empty string matches <eol>";
ok JIRA::Formater::Wiki::Grammar.parse("\n", :rule<eol>), "single new line matches <eol>";
ok JIRA::Formater::Wiki::Grammar.parse("This is a line", :rule<pline>), "single line matches pline";
ok JIRA::Formater::Wiki::Grammar.parse("This is a line", :rule<paragraph>), "single line matches paragraph";
#is($f->convert('* list'), "\\begin{itemize}\n\\item list\n\\end{itemize}");
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment