From 3609348a944723e13b02807260752ad7ef26b41c Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Thu, 5 Feb 2015 00:12:51 -0600 Subject: [PATCH] Added @param directive. --- project.properties | 6 ++-- src/main/com/jdblabs/jlp/JLPMain.groovy | 2 +- src/main/com/jdblabs/jlp/JLPPegParser.java | 31 ++++++++++++++----- .../jlp/LiterateMarkdownGenerator.groovy | 3 ++ src/main/com/jdblabs/jlp/Processor.groovy | 4 +-- src/main/com/jdblabs/jlp/ast/Directive.groovy | 7 ++++- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/project.properties b/project.properties index f1b6937..c2a8b5c 100644 --- a/project.properties +++ b/project.properties @@ -1,7 +1,7 @@ -#Tue, 13 Aug 2013 08:48:43 -0500 +#Fri, 30 May 2014 19:49:05 -0500 name=jlp -version=1.7 -build.number=25 +version=1.8 +build.number=6 lib.local=true release.dir=release main.class=com.jdblabs.jlp.JLPMain diff --git a/src/main/com/jdblabs/jlp/JLPMain.groovy b/src/main/com/jdblabs/jlp/JLPMain.groovy index 858f1e6..4306fd7 100644 --- a/src/main/com/jdblabs/jlp/JLPMain.groovy +++ b/src/main/com/jdblabs/jlp/JLPMain.groovy @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory */ public class JLPMain { - public static final String VERSION = "1.7" + public static final String VERSION = "1.8" private static Logger log = LoggerFactory.getLogger(JLPMain.class) diff --git a/src/main/com/jdblabs/jlp/JLPPegParser.java b/src/main/com/jdblabs/jlp/JLPPegParser.java index cefcd83..442abdd 100644 --- a/src/main/com/jdblabs/jlp/JLPPegParser.java +++ b/src/main/com/jdblabs/jlp/JLPPegParser.java @@ -40,8 +40,8 @@ public class JLPPegParser extends BaseParser implements JLPParser { */ /** - * #### Full constructor - * This allows the caller to specific all four of the comment delimiters + * #### Full constructor. + * This allows the caller to specify all four of the comment delimiters * recognized by the parser. */ public JLPPegParser(String mdocStart, String mdocEnd, @@ -52,6 +52,20 @@ public class JLPPegParser extends BaseParser implements JLPParser { SDOC_START = String(sdocStart).label("SDOC_START"); MDOC_LINE_START = AnyOf(mdocLineStart).label("MDOC_LINE_START"); } + /** + * #### Full constructor supporting multiple comment types. + * This allows the caller to specify all four of the comment delimiters + * recognized by the parser, supplying multiple types of comment + * delimiters. + */ + public JLPPegParser(List mdocStarts, List mdocEnds, + String mdocLineStarts, List sdocStart) { + + MDOC_START = FirstOf(mdocStarts.toArray()).label("MDOC_START"); + MDOC_END = FirstOf(mdocEnds.toArray()).label("MDOC_END"); + SDOC_START = FirstOf(sdocStarts.toArray()).label("SDOC_START"); + MDOC_LINE_START = AnyOf(mdocLineStart).label("MDOC_LINE_START"); } + /** * #### Single-line comments only constructor. * This allows the caller to easily set up the parser to only recognize @@ -292,7 +306,7 @@ public class JLPPegParser extends BaseParser implements JLPParser { * Parses the rule: * * SLongDirective = - * (API_DIR / EXAMPLE_DIR) RemainingSDocLine SDocText? + * (API_DIR / EXAMPLE_DIR / PARAM_DIR) RemainingSDocLine SDocText? * * Pushes a [`Directive`] node onto the stack. * @@ -302,8 +316,8 @@ public class JLPPegParser extends BaseParser implements JLPParser { return Sequence( push(curLineNum), - FirstOf(API_DIR, EXAMPLE_DIR), push(match()), - RemainingSDocLine(), push(match()), + FirstOf(API_DIR, EXAMPLE_DIR, PARAM_DIR), push(match()), + RemainingSDocLine(), push(match()), Optional(Sequence( SDocText(), @@ -318,7 +332,7 @@ public class JLPPegParser extends BaseParser implements JLPParser { * Parses the rule: * * MLongDirective = - * (API_DIR / EXAMPLE_DIR) RemainingMDocLine MDocText? + * (API_DIR / EXAMPLE_DIR / PARAM_DIR) RemainingMDocLine MDocText? * * Pushes a [`Directive`] node onto the stack. * @@ -328,8 +342,8 @@ public class JLPPegParser extends BaseParser implements JLPParser { return Sequence( push(curLineNum), - FirstOf(API_DIR, EXAMPLE_DIR), push(match()), - RemainingMDocLine(), push(match()), + FirstOf(API_DIR, EXAMPLE_DIR, PARAM_DIR), push(match()), + RemainingMDocLine(), push(match()), Optional(Sequence( MDocText(), @@ -497,6 +511,7 @@ public class JLPPegParser extends BaseParser implements JLPParser { Rule EXAMPLE_DIR = IgnoreCase("example"); Rule INCLUDE_DIR = IgnoreCase("include"); Rule ORG_DIR = IgnoreCase("org"); + Rule PARAM_DIR = IgnoreCase("param"); /// #### Hard-coded terminals. Rule AT = Ch('@').label("AT"); diff --git a/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy b/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy index 2a1646e..d56103b 100644 --- a/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy +++ b/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy @@ -281,6 +281,9 @@ public class LiterateMarkdownGenerator extends JLPBaseGenerator { case DirectiveType.Example: return directive.value + case DirectiveType.Param: + return "" // TODO: can we do better here, even though we're + // not understanding the source yet? // TODO: // case DirectiveType.Include: diff --git a/src/main/com/jdblabs/jlp/Processor.groovy b/src/main/com/jdblabs/jlp/Processor.groovy index c784ef6..0ef6ef8 100644 --- a/src/main/com/jdblabs/jlp/Processor.groovy +++ b/src/main/com/jdblabs/jlp/Processor.groovy @@ -438,8 +438,8 @@ public class Processor { break case 'html': case 'xml': parsers[sourceType] = Parboiled.createParser( - JLPPegParser, '', - '#$%^&*()_-+=|;:\'",<>?~`', '<', + '!#$%^&*()_-+=|;:\'",<>?~`', '<