More work on grammar, starting parboiled implementation.
This commit is contained in:
parent
48eee1ca43
commit
303f8839fd
@ -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 -> "%%"
|
||||
EOL -> "\n"
|
||||
NOT_EOL -> ~"\n"
|
||||
DIRECTIVE_START -> "@"
|
||||
DOC_START -> "%% "
|
||||
EOL -> "\n"
|
||||
NOT_EOL -> ~"\n"
|
||||
DIRECTIVE_START -> "@"
|
||||
NOT_DIRECTIVE_START -> ~"@"
|
||||
SLASH -> "/"
|
||||
ORG_ID -> ~"[/\n]"
|
||||
|
19
src/com/jdblabs/jlp/JLPPegParser.groovy
Normal file
19
src/com/jdblabs/jlp/JLPPegParser.groovy
Normal 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("%% "
|
||||
}
|
Loading…
Reference in New Issue
Block a user