Skip to content
Browse files

some small refactoring

  • Loading branch information...
1 parent 087a060 commit 2ba570036ef2c302c036af1d38331ed3bd711b57 @moritz committed
Showing with 11 additions and 8 deletions.
  1. +11 −8 lib/Mowyw/Grammar.pm
View
19 lib/Mowyw/Grammar.pm
@@ -1,34 +1,37 @@
grammar Mowyw::Grammar;
+our $open = '[%';
+our $close = '%]';
+
token TOP { ^ <chunk>* $ }
token chunk { <literal> | <directive> }
token literal {
- [<!before '[%' > .]+
+ [<!before $open > .]+
}
token directive {
- '[%' ~ '%]'
+ $open ~ $close
[<.ws> <command> <.ws> ]
}
-token arg { [<!before '%]'> \S]+ }
+token arg { [<!before $close> \S]+ }
-token slurpy_arg { [<!before '%]'> .]+ }
+token slurpy_arg { [<!before $close> .]+ }
token name { <alpha> \w* }
proto token command { <...> }
-token command:sym<comment> { <sym> [ <!before '%]'> .]* }
+token command:sym<comment> { <sym> [ <!before $close> .]* }
token command:sym<include> { <sym> <.ws> <arg> }
rule command:sym<setvar> { <sym> <name> '='? <slurpy_arg> }
rule command:sym<readvar> { <sym> <name> }
regex command:sym<verbatim> {
<sym>
- <.ws> '%]' :
- (.*?) '[%'
+ <.ws> $close :
+ (.*?) $open
<.ws> 'endverbatim'
- <.ws> <?before '%]'>
+ <.ws> <?before $close>
# the final %] is parsed by token directive
}

0 comments on commit 2ba5700

Please sign in to comment.
Something went wrong with that request. Please try again.