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
|
// lookahead 2 needed here
|
||||||
DocBlock -> DirectiveBlock | MarkdownBlock | DocBlock
|
DocBlock -> (DirectiveBlock | MarkdownBlock)+
|
||||||
|
|
||||||
DirectiveBlock ->
|
DirectiveBlock ->
|
||||||
<DOC_START> <DIRECTIVE_START> "author" RemainingLine EOL MarkdownBlock? |
|
<DOC_START> <DIRECTIVE_START> "author" RemainingLine EOL MarkdownBlock? |
|
||||||
@ -15,6 +15,10 @@ MarkdownLine ->
|
|||||||
<DOC_START> NOT_DIRECTIVE_START RemainingLine <EOL>
|
<DOC_START> NOT_DIRECTIVE_START RemainingLine <EOL>
|
||||||
|
|
||||||
RemainingLine -> NOT_EOL*
|
RemainingLine -> NOT_EOL*
|
||||||
|
|
||||||
|
OrgString ->
|
||||||
|
(<ORG_ID> <SLASH>)* <ORG_ID> <SLASH>?
|
||||||
|
|
||||||
Tokens
|
Tokens
|
||||||
------
|
------
|
||||||
|
|
||||||
@ -23,3 +27,5 @@ EOL -> "\n"
|
|||||||
NOT_EOL -> ~"\n"
|
NOT_EOL -> ~"\n"
|
||||||
DIRECTIVE_START -> "@"
|
DIRECTIVE_START -> "@"
|
||||||
NOT_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