More work on grammar, starting parboiled implementation.

This commit is contained in:
Jonathan Bernard 2011-08-25 07:47:01 -05:00
parent 48eee1ca43
commit 303f8839fd
2 changed files with 31 additions and 6 deletions

View File

@ -1,7 +1,7 @@
CodePage -> CodeBlock | DocBlock | CodePage
CodePage -> (CodeBlock | DocBlock)*
// lookahead 2 needed here
DocBlock -> DirectiveBlock | MarkdownBlock | DocBlock
DocBlock -> (DirectiveBlock | MarkdownBlock)+
DirectiveBlock ->
<DOC_START> <DIRECTIVE_START> "author" RemainingLine EOL MarkdownBlock? |
@ -15,11 +15,17 @@ MarkdownLine ->
<DOC_START> NOT_DIRECTIVE_START RemainingLine <EOL>
RemainingLine -> NOT_EOL*
OrgString ->
(<ORG_ID> <SLASH>)* <ORG_ID> <SLASH>?
Tokens
------
DOC_START -> "%%"
DOC_START -> "%% "
EOL -> "\n"
NOT_EOL -> ~"\n"
DIRECTIVE_START -> "@"
NOT_DIRECTIVE_START -> ~"@"
SLASH -> "/"
ORG_ID -> ~"[/\n]"

View File

@ -0,0 +1,19 @@
package com.jdblabs.jlp
@BuildParseTree
public class JLPPegParser extends BaseParser<Object> {
Rule CodePage() {
return ZeroOrMore(FirstOf(
DocBlock(),
CodeBlock())) }
Rule DocBlock() {
return OneOrMore(FirstOf(
DirectiveBlock(),
MarkdownBlock())) }
Rule DirectiveBlock() {
return FirstOf(
Sequence("%% "
}