From 5894bf2affa3bb7cada6d5aaec7c6b43283a8c73 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Thu, 25 Sep 2014 23:09:49 +0400 Subject: Add generated parser, lexer and some tests. --- .../jetbrains/markdown/MarkdownElementTypes.java | 40 + gen/org/jetbrains/markdown/MarkdownParser.java | 1379 ++++++++++++++++++++ gen/org/jetbrains/markdown/lexer/JFlex.jar | Bin 0 -> 193380 bytes .../jetbrains/markdown/lexer/MarkdownLexer.java | 9 + .../jetbrains/markdown/lexer/_MarkdownLexer.java | 495 +++++++ .../jetbrains/markdown/lexer/idea-flex.skeleton | 251 ++++ src/Markdown/MarkdownLexer.java | 10 - src/Markdown/MarkdownProcessor.kt | 2 +- src/Markdown/_MarkdownLexer.flex | 14 +- src/Markdown/markdown.bnf | 43 +- test/src/markdown/ParserTest.kt | 32 + 11 files changed, 2237 insertions(+), 38 deletions(-) create mode 100644 gen/org/jetbrains/markdown/MarkdownElementTypes.java create mode 100644 gen/org/jetbrains/markdown/MarkdownParser.java create mode 100644 gen/org/jetbrains/markdown/lexer/JFlex.jar create mode 100644 gen/org/jetbrains/markdown/lexer/MarkdownLexer.java create mode 100644 gen/org/jetbrains/markdown/lexer/_MarkdownLexer.java create mode 100644 gen/org/jetbrains/markdown/lexer/idea-flex.skeleton delete mode 100644 src/Markdown/MarkdownLexer.java diff --git a/gen/org/jetbrains/markdown/MarkdownElementTypes.java b/gen/org/jetbrains/markdown/MarkdownElementTypes.java new file mode 100644 index 00000000..48c423eb --- /dev/null +++ b/gen/org/jetbrains/markdown/MarkdownElementTypes.java @@ -0,0 +1,40 @@ +// This is a generated file. Not intended for manual editing. +package org.jetbrains.markdown; + +import com.intellij.psi.tree.IElementType; +import org.jetbrains.dokka.Markdown.MarkdownTokenType; + +public interface MarkdownElementTypes { + + IElementType BLANK_LINE = new IElementType("BLANK_LINE", null); + IElementType BLOCK = new IElementType("BLOCK", null); + IElementType BULLET = new IElementType("BULLET", null); + IElementType BULLET_LIST = new IElementType("BULLET_LIST", null); + IElementType EMPH = new IElementType("EMPH", null); + IElementType END_LINE = new IElementType("END_LINE", null); + IElementType ENUMERATOR = new IElementType("ENUMERATOR", null); + IElementType HORIZONTAL_RULE = new IElementType("HORIZONTAL_RULE", null); + IElementType HREF = new IElementType("HREF", null); + IElementType INLINE = new IElementType("INLINE", null); + IElementType LINK = new IElementType("LINK", null); + IElementType LIST_BLOCK = new IElementType("LIST_BLOCK", null); + IElementType LIST_BLOCK_LINE = new IElementType("LIST_BLOCK_LINE", null); + IElementType LIST_CONTINUATION_BLOCK = new IElementType("LIST_CONTINUATION_BLOCK", null); + IElementType LIST_ITEM = new IElementType("LIST_ITEM", null); + IElementType ORDERED_LIST = new IElementType("ORDERED_LIST", null); + IElementType PARA = new IElementType("PARA", null); + IElementType STRONG = new IElementType("STRONG", null); + IElementType STRONG_STAR = new IElementType("STRONG_STAR", null); + IElementType STRONG_UNDERSCORE = new IElementType("STRONG_UNDERSCORE", null); + IElementType TARGET = new IElementType("TARGET", null); + IElementType WHITESPACE = new IElementType("WHITESPACE", null); + + IElementType ANYCHAR = new MarkdownTokenType("AnyChar"); + IElementType BOM = new MarkdownTokenType("\\357\\273\\277"); + IElementType EOL = new MarkdownTokenType("\"\\r\"|\"\\n\"|\"\\r\\n\""); + IElementType LINE_WS = new MarkdownTokenType("LINE_WS"); + IElementType NEWLINE = new MarkdownTokenType("Newline"); + IElementType NUMBER = new MarkdownTokenType("Number"); + IElementType SPACECHAR = new MarkdownTokenType("Spacechar"); + IElementType STRING = new MarkdownTokenType("String"); +} diff --git a/gen/org/jetbrains/markdown/MarkdownParser.java b/gen/org/jetbrains/markdown/MarkdownParser.java new file mode 100644 index 00000000..ef1d8375 --- /dev/null +++ b/gen/org/jetbrains/markdown/MarkdownParser.java @@ -0,0 +1,1379 @@ +// This is a generated file. Not intended for manual editing. +package org.jetbrains.markdown; + +import com.intellij.lang.PsiBuilder; +import com.intellij.lang.PsiBuilder.Marker; +import static org.jetbrains.markdown.MarkdownElementTypes.*; +import static org.jetbrains.dokka.Markdown.GeneratedParserUtilBase.*; +import com.intellij.psi.tree.IElementType; +import com.intellij.lang.ASTNode; +import com.intellij.psi.tree.TokenSet; +import com.intellij.lang.PsiParser; + +@SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"}) +public class MarkdownParser implements PsiParser { + + public ASTNode parse(IElementType root_, PsiBuilder builder_) { + parse_only_(root_, builder_); + return builder_.getTreeBuilt(); + } + + public void parse_only_(IElementType root_, PsiBuilder builder_) { + boolean result_; + builder_ = adapt_builder_(root_, builder_, this, null); + Marker marker_ = enter_section_(builder_, 0, _COLLAPSE_, null); + if (root_ == BLANK_LINE) { + result_ = BlankLine(builder_, 0); + } + else if (root_ == BLOCK) { + result_ = Block(builder_, 0); + } + else if (root_ == BULLET) { + result_ = Bullet(builder_, 0); + } + else if (root_ == BULLET_LIST) { + result_ = BulletList(builder_, 0); + } + else if (root_ == EMPH) { + result_ = Emph(builder_, 0); + } + else if (root_ == END_LINE) { + result_ = EndLine(builder_, 0); + } + else if (root_ == ENUMERATOR) { + result_ = Enumerator(builder_, 0); + } + else if (root_ == HORIZONTAL_RULE) { + result_ = HorizontalRule(builder_, 0); + } + else if (root_ == HREF) { + result_ = Href(builder_, 0); + } + else if (root_ == INLINE) { + result_ = Inline(builder_, 0); + } + else if (root_ == LINK) { + result_ = Link(builder_, 0); + } + else if (root_ == LIST_BLOCK) { + result_ = ListBlock(builder_, 0); + } + else if (root_ == LIST_BLOCK_LINE) { + result_ = ListBlockLine(builder_, 0); + } + else if (root_ == LIST_CONTINUATION_BLOCK) { + result_ = ListContinuationBlock(builder_, 0); + } + else if (root_ == LIST_ITEM) { + result_ = ListItem(builder_, 0); + } + else if (root_ == ORDERED_LIST) { + result_ = OrderedList(builder_, 0); + } + else if (root_ == PARA) { + result_ = Para(builder_, 0); + } + else if (root_ == STRONG) { + result_ = Strong(builder_, 0); + } + else if (root_ == STRONG_STAR) { + result_ = StrongStar(builder_, 0); + } + else if (root_ == STRONG_UNDERSCORE) { + result_ = StrongUnderscore(builder_, 0); + } + else if (root_ == TARGET) { + result_ = Target(builder_, 0); + } + else if (root_ == WHITESPACE) { + result_ = Whitespace(builder_, 0); + } + else { + result_ = parse_root_(root_, builder_, 0); + } + exit_section_(builder_, 0, marker_, root_, result_, true, TRUE_CONDITION); + } + + protected boolean parse_root_(IElementType root_, PsiBuilder builder_, int level_) { + return Document(builder_, level_ + 1); + } + + /* ********************************************************** */ + // OptionalSpace Newline + public static boolean BlankLine(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "BlankLine")) return false; + if (!nextTokenIs(builder_, "", NEWLINE, SPACECHAR)) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, NEWLINE); + exit_section_(builder_, level_, marker_, BLANK_LINE, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // BlankLine* ( + // Para + // | Plain + // | OrderedList + // | BulletList + // ) + public static boolean Block(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Block")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = Block_0(builder_, level_ + 1); + result_ = result_ && Block_1(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, BLOCK, result_, false, null); + return result_; + } + + // BlankLine* + private static boolean Block_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Block_0")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!BlankLine(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "Block_0", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + // Para + // | Plain + // | OrderedList + // | BulletList + private static boolean Block_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Block_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Para(builder_, level_ + 1); + if (!result_) result_ = Plain(builder_, level_ + 1); + if (!result_) result_ = OrderedList(builder_, level_ + 1); + if (!result_) result_ = BulletList(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // !HorizontalRule NonindentSpace ('+' | '*' | '-') Spacechar+ + public static boolean Bullet(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Bullet")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = Bullet_0(builder_, level_ + 1); + result_ = result_ && NonindentSpace(builder_, level_ + 1); + result_ = result_ && Bullet_2(builder_, level_ + 1); + result_ = result_ && Bullet_3(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, BULLET, result_, false, null); + return result_; + } + + // !HorizontalRule + private static boolean Bullet_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Bullet_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !HorizontalRule(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // '+' | '*' | '-' + private static boolean Bullet_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Bullet_2")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, "+"); + if (!result_) result_ = consumeToken(builder_, "*"); + if (!result_) result_ = consumeToken(builder_, "-"); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // Spacechar+ + private static boolean Bullet_3(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Bullet_3")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, SPACECHAR); + int pos_ = current_position_(builder_); + while (result_) { + if (!consumeToken(builder_, SPACECHAR)) break; + if (!empty_element_parsed_guard_(builder_, "Bullet_3", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // &Bullet List + public static boolean BulletList(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "BulletList")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = BulletList_0(builder_, level_ + 1); + result_ = result_ && List(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, BULLET_LIST, result_, false, null); + return result_; + } + + // &Bullet + private static boolean BulletList_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "BulletList_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _AND_, null); + result_ = Bullet(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // BOM? ( Block )* + static boolean Document(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Document")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Document_0(builder_, level_ + 1); + result_ = result_ && Document_1(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // BOM? + private static boolean Document_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Document_0")) return false; + consumeToken(builder_, BOM); + return true; + } + + // ( Block )* + private static boolean Document_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Document_1")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!Document_1_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "Document_1", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + // ( Block ) + private static boolean Document_1_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Document_1_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Block(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // EmphStar | EmphUnderscore + public static boolean Emph(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Emph")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = EmphStar(builder_, level_ + 1); + if (!result_) result_ = EmphUnderscore(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, EMPH, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // '*' !Whitespace (!'*' Inline)+ '*' + static boolean EmphStar(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphStar")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, "*"); + result_ = result_ && EmphStar_1(builder_, level_ + 1); + result_ = result_ && EmphStar_2(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "*"); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !Whitespace + private static boolean EmphStar_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphStar_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !Whitespace(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // (!'*' Inline)+ + private static boolean EmphStar_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphStar_2")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = EmphStar_2_0(builder_, level_ + 1); + int pos_ = current_position_(builder_); + while (result_) { + if (!EmphStar_2_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "EmphStar_2", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !'*' Inline + private static boolean EmphStar_2_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphStar_2_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = EmphStar_2_0_0(builder_, level_ + 1); + result_ = result_ && Inline(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !'*' + private static boolean EmphStar_2_0_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphStar_2_0_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !consumeToken(builder_, "*"); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // '_' !Whitespace (!'_' Inline)+ '_' + static boolean EmphUnderscore(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphUnderscore")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, "_"); + result_ = result_ && EmphUnderscore_1(builder_, level_ + 1); + result_ = result_ && EmphUnderscore_2(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "_"); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !Whitespace + private static boolean EmphUnderscore_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphUnderscore_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !Whitespace(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // (!'_' Inline)+ + private static boolean EmphUnderscore_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphUnderscore_2")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = EmphUnderscore_2_0(builder_, level_ + 1); + int pos_ = current_position_(builder_); + while (result_) { + if (!EmphUnderscore_2_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "EmphUnderscore_2", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !'_' Inline + private static boolean EmphUnderscore_2_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphUnderscore_2_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = EmphUnderscore_2_0_0(builder_, level_ + 1); + result_ = result_ && Inline(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !'_' + private static boolean EmphUnderscore_2_0_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EmphUnderscore_2_0_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !consumeToken(builder_, "_"); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // TerminalEndline | NormalEndline + public static boolean EndLine(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "EndLine")) return false; + if (!nextTokenIs(builder_, "", NEWLINE, SPACECHAR)) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = TerminalEndline(builder_, level_ + 1); + if (!result_) result_ = NormalEndline(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, END_LINE, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // NonindentSpace Number '.' Spacechar+ + public static boolean Enumerator(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Enumerator")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = NonindentSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, NUMBER); + result_ = result_ && consumeToken(builder_, "."); + result_ = result_ && Enumerator_3(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, ENUMERATOR, result_, false, null); + return result_; + } + + // Spacechar+ + private static boolean Enumerator_3(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Enumerator_3")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, SPACECHAR); + int pos_ = current_position_(builder_); + while (result_) { + if (!consumeToken(builder_, SPACECHAR)) break; + if (!empty_element_parsed_guard_(builder_, "Enumerator_3", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // NonindentSpace + // ( '*' OptionalSpace '*' OptionalSpace '*' (OptionalSpace '*')* + // | '-' OptionalSpace '-' OptionalSpace '-' (OptionalSpace '-')* + // | '_' OptionalSpace '_' OptionalSpace '_' (OptionalSpace '_')*) + // OptionalSpace Newline BlankLine+ + public static boolean HorizontalRule(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = NonindentSpace(builder_, level_ + 1); + result_ = result_ && HorizontalRule_1(builder_, level_ + 1); + result_ = result_ && OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, NEWLINE); + result_ = result_ && HorizontalRule_4(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, HORIZONTAL_RULE, result_, false, null); + return result_; + } + + // '*' OptionalSpace '*' OptionalSpace '*' (OptionalSpace '*')* + // | '-' OptionalSpace '-' OptionalSpace '-' (OptionalSpace '-')* + // | '_' OptionalSpace '_' OptionalSpace '_' (OptionalSpace '_')* + private static boolean HorizontalRule_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = HorizontalRule_1_0(builder_, level_ + 1); + if (!result_) result_ = HorizontalRule_1_1(builder_, level_ + 1); + if (!result_) result_ = HorizontalRule_1_2(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // '*' OptionalSpace '*' OptionalSpace '*' (OptionalSpace '*')* + private static boolean HorizontalRule_1_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, "*"); + result_ = result_ && OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "*"); + result_ = result_ && OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "*"); + result_ = result_ && HorizontalRule_1_0_5(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // (OptionalSpace '*')* + private static boolean HorizontalRule_1_0_5(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1_0_5")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!HorizontalRule_1_0_5_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "HorizontalRule_1_0_5", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + // OptionalSpace '*' + private static boolean HorizontalRule_1_0_5_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1_0_5_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "*"); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // '-' OptionalSpace '-' OptionalSpace '-' (OptionalSpace '-')* + private static boolean HorizontalRule_1_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, "-"); + result_ = result_ && OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "-"); + result_ = result_ && OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "-"); + result_ = result_ && HorizontalRule_1_1_5(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // (OptionalSpace '-')* + private static boolean HorizontalRule_1_1_5(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1_1_5")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!HorizontalRule_1_1_5_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "HorizontalRule_1_1_5", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + // OptionalSpace '-' + private static boolean HorizontalRule_1_1_5_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1_1_5_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "-"); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // '_' OptionalSpace '_' OptionalSpace '_' (OptionalSpace '_')* + private static boolean HorizontalRule_1_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1_2")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, "_"); + result_ = result_ && OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "_"); + result_ = result_ && OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "_"); + result_ = result_ && HorizontalRule_1_2_5(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // (OptionalSpace '_')* + private static boolean HorizontalRule_1_2_5(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1_2_5")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!HorizontalRule_1_2_5_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "HorizontalRule_1_2_5", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + // OptionalSpace '_' + private static boolean HorizontalRule_1_2_5_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_1_2_5_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "_"); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // BlankLine+ + private static boolean HorizontalRule_4(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HorizontalRule_4")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = BlankLine(builder_, level_ + 1); + int pos_ = current_position_(builder_); + while (result_) { + if (!BlankLine(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "HorizontalRule_4", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // String + public static boolean Href(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Href")) return false; + if (!nextTokenIs(builder_, STRING)) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, STRING); + exit_section_(builder_, marker_, HREF, result_); + return result_; + } + + /* ********************************************************** */ + // '[' Target ']' '(' Href ')' + static boolean HrefLink(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "HrefLink")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, "["); + result_ = result_ && Target(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "]"); + result_ = result_ && consumeToken(builder_, "("); + result_ = result_ && Href(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, ")"); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // "\t" | " " + static boolean Indent(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Indent")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, "\t"); + if (!result_) result_ = consumeToken(builder_, " "); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // String | Number | EndLine | Spacechar+ | Strong | Emph | Link + public static boolean Inline(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inline")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = consumeToken(builder_, STRING); + if (!result_) result_ = consumeToken(builder_, NUMBER); + if (!result_) result_ = EndLine(builder_, level_ + 1); + if (!result_) result_ = Inline_3(builder_, level_ + 1); + if (!result_) result_ = Strong(builder_, level_ + 1); + if (!result_) result_ = Emph(builder_, level_ + 1); + if (!result_) result_ = Link(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, INLINE, result_, false, null); + return result_; + } + + // Spacechar+ + private static boolean Inline_3(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inline_3")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, SPACECHAR); + int pos_ = current_position_(builder_); + while (result_) { + if (!consumeToken(builder_, SPACECHAR)) break; + if (!empty_element_parsed_guard_(builder_, "Inline_3", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // (!EndLine Inline | EndLine &Inline )+ EndLine? + static boolean Inlines(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inlines")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Inlines_0(builder_, level_ + 1); + result_ = result_ && Inlines_1(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // (!EndLine Inline | EndLine &Inline )+ + private static boolean Inlines_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inlines_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Inlines_0_0(builder_, level_ + 1); + int pos_ = current_position_(builder_); + while (result_) { + if (!Inlines_0_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "Inlines_0", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !EndLine Inline | EndLine &Inline + private static boolean Inlines_0_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inlines_0_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Inlines_0_0_0(builder_, level_ + 1); + if (!result_) result_ = Inlines_0_0_1(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !EndLine Inline + private static boolean Inlines_0_0_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inlines_0_0_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Inlines_0_0_0_0(builder_, level_ + 1); + result_ = result_ && Inline(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !EndLine + private static boolean Inlines_0_0_0_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inlines_0_0_0_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !EndLine(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // EndLine &Inline + private static boolean Inlines_0_0_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inlines_0_0_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = EndLine(builder_, level_ + 1); + result_ = result_ && Inlines_0_0_1_1(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // &Inline + private static boolean Inlines_0_0_1_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inlines_0_0_1_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _AND_, null); + result_ = Inline(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // EndLine? + private static boolean Inlines_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Inlines_1")) return false; + EndLine(builder_, level_ + 1); + return true; + } + + /* ********************************************************** */ + // HrefLink | ReferenceLink + public static boolean Link(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Link")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = HrefLink(builder_, level_ + 1); + if (!result_) result_ = ReferenceLink(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, LINK, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // (ListItem BlankLine*)+ + static boolean List(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "List")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = List_0(builder_, level_ + 1); + int pos_ = current_position_(builder_); + while (result_) { + if (!List_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "List", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // ListItem BlankLine* + private static boolean List_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "List_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = ListItem(builder_, level_ + 1); + result_ = result_ && List_0_1(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // BlankLine* + private static boolean List_0_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "List_0_1")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!BlankLine(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "List_0_1", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + /* ********************************************************** */ + // !BlankLine Plain ( ListBlockLine )* + public static boolean ListBlock(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlock")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = ListBlock_0(builder_, level_ + 1); + result_ = result_ && Plain(builder_, level_ + 1); + result_ = result_ && ListBlock_2(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, LIST_BLOCK, result_, false, null); + return result_; + } + + // !BlankLine + private static boolean ListBlock_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlock_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !BlankLine(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // ( ListBlockLine )* + private static boolean ListBlock_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlock_2")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!ListBlock_2_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "ListBlock_2", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + // ( ListBlockLine ) + private static boolean ListBlock_2_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlock_2_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = ListBlockLine(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // !BlankLine !(Indent? (Bullet | Enumerator)) !HorizontalRule Indent? Plain + public static boolean ListBlockLine(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlockLine")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = ListBlockLine_0(builder_, level_ + 1); + result_ = result_ && ListBlockLine_1(builder_, level_ + 1); + result_ = result_ && ListBlockLine_2(builder_, level_ + 1); + result_ = result_ && ListBlockLine_3(builder_, level_ + 1); + result_ = result_ && Plain(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, LIST_BLOCK_LINE, result_, false, null); + return result_; + } + + // !BlankLine + private static boolean ListBlockLine_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlockLine_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !BlankLine(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // !(Indent? (Bullet | Enumerator)) + private static boolean ListBlockLine_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlockLine_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !ListBlockLine_1_0(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // Indent? (Bullet | Enumerator) + private static boolean ListBlockLine_1_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlockLine_1_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = ListBlockLine_1_0_0(builder_, level_ + 1); + result_ = result_ && ListBlockLine_1_0_1(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // Indent? + private static boolean ListBlockLine_1_0_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlockLine_1_0_0")) return false; + Indent(builder_, level_ + 1); + return true; + } + + // Bullet | Enumerator + private static boolean ListBlockLine_1_0_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlockLine_1_0_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Bullet(builder_, level_ + 1); + if (!result_) result_ = Enumerator(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !HorizontalRule + private static boolean ListBlockLine_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlockLine_2")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !HorizontalRule(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // Indent? + private static boolean ListBlockLine_3(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListBlockLine_3")) return false; + Indent(builder_, level_ + 1); + return true; + } + + /* ********************************************************** */ + // BlankLine* (Indent ListBlock)+ + public static boolean ListContinuationBlock(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListContinuationBlock")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = ListContinuationBlock_0(builder_, level_ + 1); + result_ = result_ && ListContinuationBlock_1(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, LIST_CONTINUATION_BLOCK, result_, false, null); + return result_; + } + + // BlankLine* + private static boolean ListContinuationBlock_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListContinuationBlock_0")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!BlankLine(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "ListContinuationBlock_0", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + // (Indent ListBlock)+ + private static boolean ListContinuationBlock_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListContinuationBlock_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = ListContinuationBlock_1_0(builder_, level_ + 1); + int pos_ = current_position_(builder_); + while (result_) { + if (!ListContinuationBlock_1_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "ListContinuationBlock_1", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // Indent ListBlock + private static boolean ListContinuationBlock_1_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListContinuationBlock_1_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Indent(builder_, level_ + 1); + result_ = result_ && ListBlock(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // (Bullet | Enumerator) ListBlock ( ListContinuationBlock )* + public static boolean ListItem(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListItem")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = ListItem_0(builder_, level_ + 1); + result_ = result_ && ListBlock(builder_, level_ + 1); + result_ = result_ && ListItem_2(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, LIST_ITEM, result_, false, null); + return result_; + } + + // Bullet | Enumerator + private static boolean ListItem_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListItem_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Bullet(builder_, level_ + 1); + if (!result_) result_ = Enumerator(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // ( ListContinuationBlock )* + private static boolean ListItem_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListItem_2")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!ListItem_2_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "ListItem_2", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + // ( ListContinuationBlock ) + private static boolean ListItem_2_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ListItem_2_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = ListContinuationBlock(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // (" " | " " | " ")? + static boolean NonindentSpace(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "NonindentSpace")) return false; + NonindentSpace_0(builder_, level_ + 1); + return true; + } + + // " " | " " | " " + private static boolean NonindentSpace_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "NonindentSpace_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, " "); + if (!result_) result_ = consumeToken(builder_, " "); + if (!result_) result_ = consumeToken(builder_, " "); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // OptionalSpace Newline !BlankLine + static boolean NormalEndline(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "NormalEndline")) return false; + if (!nextTokenIs(builder_, "", NEWLINE, SPACECHAR)) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, NEWLINE); + result_ = result_ && NormalEndline_2(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !BlankLine + private static boolean NormalEndline_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "NormalEndline_2")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !BlankLine(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // Spacechar* + static boolean OptionalSpace(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "OptionalSpace")) return false; + int pos_ = current_position_(builder_); + while (true) { + if (!consumeToken(builder_, SPACECHAR)) break; + if (!empty_element_parsed_guard_(builder_, "OptionalSpace", pos_)) break; + pos_ = current_position_(builder_); + } + return true; + } + + /* ********************************************************** */ + // &Enumerator List + public static boolean OrderedList(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "OrderedList")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = OrderedList_0(builder_, level_ + 1); + result_ = result_ && List(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, ORDERED_LIST, result_, false, null); + return result_; + } + + // &Enumerator + private static boolean OrderedList_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "OrderedList_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _AND_, null); + result_ = Enumerator(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // NonindentSpace Inlines (BlankLine+ | TerminalEndline) + public static boolean Para(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Para")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = NonindentSpace(builder_, level_ + 1); + result_ = result_ && Inlines(builder_, level_ + 1); + result_ = result_ && Para_2(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, PARA, result_, false, null); + return result_; + } + + // BlankLine+ | TerminalEndline + private static boolean Para_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Para_2")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = Para_2_0(builder_, level_ + 1); + if (!result_) result_ = TerminalEndline(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // BlankLine+ + private static boolean Para_2_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Para_2_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = BlankLine(builder_, level_ + 1); + int pos_ = current_position_(builder_); + while (result_) { + if (!BlankLine(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "Para_2_0", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // Inlines + static boolean Plain(PsiBuilder builder_, int level_) { + return Inlines(builder_, level_ + 1); + } + + /* ********************************************************** */ + // '[' Target ']' + static boolean ReferenceLink(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "ReferenceLink")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, "["); + result_ = result_ && Target(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "]"); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // Spacechar+ + static boolean RequiredSpace(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "RequiredSpace")) return false; + if (!nextTokenIs(builder_, SPACECHAR)) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, SPACECHAR); + int pos_ = current_position_(builder_); + while (result_) { + if (!consumeToken(builder_, SPACECHAR)) break; + if (!empty_element_parsed_guard_(builder_, "RequiredSpace", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // StrongStar | StrongUnderscore + public static boolean Strong(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Strong")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = StrongStar(builder_, level_ + 1); + if (!result_) result_ = StrongUnderscore(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, STRONG, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // '**' !Whitespace (!'**' Inline)+ '**' + public static boolean StrongStar(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongStar")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = consumeToken(builder_, "**"); + result_ = result_ && StrongStar_1(builder_, level_ + 1); + result_ = result_ && StrongStar_2(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "**"); + exit_section_(builder_, level_, marker_, STRONG_STAR, result_, false, null); + return result_; + } + + // !Whitespace + private static boolean StrongStar_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongStar_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !Whitespace(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // (!'**' Inline)+ + private static boolean StrongStar_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongStar_2")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = StrongStar_2_0(builder_, level_ + 1); + int pos_ = current_position_(builder_); + while (result_) { + if (!StrongStar_2_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "StrongStar_2", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !'**' Inline + private static boolean StrongStar_2_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongStar_2_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = StrongStar_2_0_0(builder_, level_ + 1); + result_ = result_ && Inline(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !'**' + private static boolean StrongStar_2_0_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongStar_2_0_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !consumeToken(builder_, "**"); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // '__' !Whitespace (!'__' Inline)+ '__' + public static boolean StrongUnderscore(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongUnderscore")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = consumeToken(builder_, "__"); + result_ = result_ && StrongUnderscore_1(builder_, level_ + 1); + result_ = result_ && StrongUnderscore_2(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, "__"); + exit_section_(builder_, level_, marker_, STRONG_UNDERSCORE, result_, false, null); + return result_; + } + + // !Whitespace + private static boolean StrongUnderscore_1(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongUnderscore_1")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !Whitespace(builder_, level_ + 1); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + // (!'__' Inline)+ + private static boolean StrongUnderscore_2(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongUnderscore_2")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = StrongUnderscore_2_0(builder_, level_ + 1); + int pos_ = current_position_(builder_); + while (result_) { + if (!StrongUnderscore_2_0(builder_, level_ + 1)) break; + if (!empty_element_parsed_guard_(builder_, "StrongUnderscore_2", pos_)) break; + pos_ = current_position_(builder_); + } + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !'__' Inline + private static boolean StrongUnderscore_2_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongUnderscore_2_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = StrongUnderscore_2_0_0(builder_, level_ + 1); + result_ = result_ && Inline(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + // !'__' + private static boolean StrongUnderscore_2_0_0(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "StrongUnderscore_2_0_0")) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NOT_, null); + result_ = !consumeToken(builder_, "__"); + exit_section_(builder_, level_, marker_, null, result_, false, null); + return result_; + } + + /* ********************************************************** */ + // String + public static boolean Target(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Target")) return false; + if (!nextTokenIs(builder_, STRING)) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = consumeToken(builder_, STRING); + exit_section_(builder_, marker_, TARGET, result_); + return result_; + } + + /* ********************************************************** */ + // OptionalSpace Newline <> + static boolean TerminalEndline(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "TerminalEndline")) return false; + if (!nextTokenIs(builder_, "", NEWLINE, SPACECHAR)) return false; + boolean result_; + Marker marker_ = enter_section_(builder_); + result_ = OptionalSpace(builder_, level_ + 1); + result_ = result_ && consumeToken(builder_, NEWLINE); + result_ = result_ && eof(builder_, level_ + 1); + exit_section_(builder_, marker_, null, result_); + return result_; + } + + /* ********************************************************** */ + // Spacechar | Newline + public static boolean Whitespace(PsiBuilder builder_, int level_) { + if (!recursion_guard_(builder_, level_, "Whitespace")) return false; + if (!nextTokenIs(builder_, "", NEWLINE, SPACECHAR)) return false; + boolean result_; + Marker marker_ = enter_section_(builder_, level_, _NONE_, ""); + result_ = consumeToken(builder_, SPACECHAR); + if (!result_) result_ = consumeToken(builder_, NEWLINE); + exit_section_(builder_, level_, marker_, WHITESPACE, result_, false, null); + return result_; + } + +} diff --git a/gen/org/jetbrains/markdown/lexer/JFlex.jar b/gen/org/jetbrains/markdown/lexer/JFlex.jar new file mode 100644 index 00000000..8bef2fdb Binary files /dev/null and b/gen/org/jetbrains/markdown/lexer/JFlex.jar differ diff --git a/gen/org/jetbrains/markdown/lexer/MarkdownLexer.java b/gen/org/jetbrains/markdown/lexer/MarkdownLexer.java new file mode 100644 index 00000000..40728972 --- /dev/null +++ b/gen/org/jetbrains/markdown/lexer/MarkdownLexer.java @@ -0,0 +1,9 @@ +package org.jetbrains.markdown.lexer; + +import com.intellij.lexer.FlexAdapter; + +public class MarkdownLexer extends FlexAdapter { + public MarkdownLexer() { + super(new _MarkdownLexer()); + } +} diff --git a/gen/org/jetbrains/markdown/lexer/_MarkdownLexer.java b/gen/org/jetbrains/markdown/lexer/_MarkdownLexer.java new file mode 100644 index 00000000..0052e3ea --- /dev/null +++ b/gen/org/jetbrains/markdown/lexer/_MarkdownLexer.java @@ -0,0 +1,495 @@ +/* The following code was generated by JFlex 1.4.3 on 9/25/14 10:26 PM */ + +package org.jetbrains.markdown.lexer; + +import com.intellij.lexer.*; +import com.intellij.psi.tree.IElementType; +import static org.jetbrains.markdown.MarkdownElementTypes.*; + + +/** + * This class is a scanner generated by + * JFlex 1.4.3 + * on 9/25/14 10:26 PM from the specification file + * /Users/orangy/Projects/dokka/src/Markdown/_MarkdownLexer.flex + */ +public class _MarkdownLexer implements FlexLexer { + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int YYINITIAL = 0; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0 + }; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\7\1\2\1\0\1\3\1\1\22\0\1\7\1\6\1\0"+ + "\1\6\2\0\1\6\1\0\3\6\3\0\1\5\1\0\2\4\1\14"+ + "\1\11\1\4\1\12\1\4\1\13\2\4\2\0\1\6\36\0\1\6"+ + "\1\10\1\6\1\0\2\6\35\0\1\6\uff81\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\1\0\1\1\2\2\1\3\1\4\1\5\1\3\1\5"+ + "\1\4\12\0\1\6"; + + private static int [] zzUnpackAction() { + int [] result = new int[21]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\15\0\32\0\47\0\15\0\64\0\47\0\47"+ + "\0\101\0\116\0\133\0\150\0\165\0\202\0\217\0\234"+ + "\0\251\0\266\0\303\0\320\0\47"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[21]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\2\1\3\1\4\1\5\1\6\1\2\1\7\1\10"+ + "\1\11\4\6\1\2\2\0\3\2\3\0\4\2\2\0"+ + "\1\4\27\0\1\2\2\0\1\2\1\6\1\12\3\0"+ + "\4\6\11\0\1\13\3\0\1\2\2\0\1\2\1\12"+ + "\1\2\3\0\4\12\12\0\1\14\15\0\1\15\11\0"+ + "\1\16\20\0\1\17\13\0\1\20\12\0\1\21\13\0"+ + "\1\22\20\0\1\23\13\0\1\24\14\0\1\25\1\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[221]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + private static final char[] EMPTY_BUFFER = new char[0]; + private static final int YYEOF = -1; + private static java.io.Reader zzReader = null; // Fake + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\1\0\2\1\1\11\2\1\2\11\2\1\12\0\1\11"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[21]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private CharSequence zzBuffer = ""; + + /** this buffer may contains the current text array to be matched when it is cheap to acquire it */ + private char[] zzBufferArray; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the textposition at the last state to be included in yytext */ + private int zzPushbackPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /* user code: */ + public _MarkdownLexer() { + this((java.io.Reader)null); + } + + + public _MarkdownLexer(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public _MarkdownLexer(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 74) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + public final int getTokenStart(){ + return zzStartRead; + } + + public final int getTokenEnd(){ + return getTokenStart() + yylength(); + } + + public void reset(CharSequence buffer, int start, int end,int initialState){ + zzBuffer = buffer; + zzBufferArray = com.intellij.util.text.CharArrayUtil.fromSequenceWithoutCopying(buffer); + zzCurrentPos = zzMarkedPos = zzStartRead = start; + zzPushbackPos = 0; + zzAtEOF = false; + zzAtBOL = true; + zzEndRead = end; + yybegin(initialState); + } + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + return true; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final CharSequence yytext() { + return zzBuffer.subSequence(zzStartRead, zzMarkedPos); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBufferArray != null ? zzBufferArray[zzStartRead+pos]:zzBuffer.charAt(zzStartRead+pos); + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public IElementType advance() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + CharSequence zzBufferL = zzBuffer; + char[] zzBufferArrayL = zzBufferArray; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++] : zzBufferL.charAt(zzCurrentPosL++)); + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++] : zzBufferL.charAt(zzCurrentPosL++)); + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 4: + { return NUMBER; + } + case 7: break; + case 5: + { return ANYCHAR; + } + case 8: break; + case 2: + { return NEWLINE; + } + case 9: break; + case 6: + { return BOM; + } + case 10: break; + case 3: + { return SPACECHAR; + } + case 11: break; + case 1: + { return STRING; + } + case 12: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return null; + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/gen/org/jetbrains/markdown/lexer/idea-flex.skeleton b/gen/org/jetbrains/markdown/lexer/idea-flex.skeleton new file mode 100644 index 00000000..234a62c4 --- /dev/null +++ b/gen/org/jetbrains/markdown/lexer/idea-flex.skeleton @@ -0,0 +1,251 @@ + /** initial size of the lookahead buffer */ +--- private static final int ZZ_BUFFERSIZE = ...; + + /** lexical states */ +--- lexical states, charmap + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + private static final char[] EMPTY_BUFFER = new char[0]; + private static final int YYEOF = -1; + private static java.io.Reader zzReader = null; // Fake + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + +--- isFinal list + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private CharSequence zzBuffer = ""; + + /** this buffer may contains the current text array to be matched when it is cheap to acquire it */ + private char[] zzBufferArray; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the textposition at the last state to be included in yytext */ + private int zzPushbackPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + +--- user class code + +--- constructor declaration + + public final int getTokenStart(){ + return zzStartRead; + } + + public final int getTokenEnd(){ + return getTokenStart() + yylength(); + } + + public void reset(CharSequence buffer, int start, int end,int initialState){ + zzBuffer = buffer; + zzBufferArray = com.intellij.util.text.CharArrayUtil.fromSequenceWithoutCopying(buffer); + zzCurrentPos = zzMarkedPos = zzStartRead = start; + zzPushbackPos = 0; + zzAtEOF = false; + zzAtBOL = true; + zzEndRead = end; + yybegin(initialState); + } + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + return true; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final CharSequence yytext() { + return zzBuffer.subSequence(zzStartRead, zzMarkedPos); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBufferArray != null ? zzBufferArray[zzStartRead+pos]:zzBuffer.charAt(zzStartRead+pos); + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ +--- zzScanError declaration + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + +--- throws clause + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ +--- yypushback decl (contains zzScanError exception) + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + +--- zzDoEOF + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ +--- yylex declaration + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + CharSequence zzBufferL = zzBuffer; + char[] zzBufferArrayL = zzBufferArray; + char [] zzCMapL = ZZ_CMAP; + +--- local declarations + + while (true) { + zzMarkedPosL = zzMarkedPos; + +--- start admin (line, char, col count) + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + +--- start admin (lexstate etc) + + zzForAction: { + while (true) { + +--- next input, line, col, char count, next transition, isFinal action + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; +--- line count update + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; +--- char count update + +--- actions + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; +--- eofvalue + } + else { +--- no match + } + } + } + } + +--- main + +} diff --git a/src/Markdown/MarkdownLexer.java b/src/Markdown/MarkdownLexer.java deleted file mode 100644 index 3486d795..00000000 --- a/src/Markdown/MarkdownLexer.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.jetbrains.dokka.Markdown; - -import com.intellij.lexer.FlexAdapter; -import org.jetbrains.markdown.impl._MarkdownLexer; - -public class MarkdownLexer extends FlexAdapter { - public MarkdownLexer() { - super(new _MarkdownLexer()); - } -} diff --git a/src/Markdown/MarkdownProcessor.kt b/src/Markdown/MarkdownProcessor.kt index 9843eb68..4453e750 100644 --- a/src/Markdown/MarkdownProcessor.kt +++ b/src/Markdown/MarkdownProcessor.kt @@ -8,7 +8,7 @@ import com.intellij.psi.tree.IFileElementType import com.intellij.lang.LighterASTNode import com.intellij.util.diff.FlyweightCapableTreeStructure import com.intellij.openapi.util.Ref -import org.jetbrains.dokka.Markdown.MarkdownLexer +import org.jetbrains.markdown.lexer.MarkdownLexer public class MarkdownProcessor { class object { diff --git a/src/Markdown/_MarkdownLexer.flex b/src/Markdown/_MarkdownLexer.flex index 9c76da8f..0a15e41a 100644 --- a/src/Markdown/_MarkdownLexer.flex +++ b/src/Markdown/_MarkdownLexer.flex @@ -1,4 +1,4 @@ -package org.jetbrains.markdown.impl; +package org.jetbrains.markdown.lexer; import com.intellij.lexer.*; import com.intellij.psi.tree.IElementType; @@ -21,9 +21,9 @@ import static org.jetbrains.markdown.MarkdownElementTypes.*; Newline="\r"|"\n"|"\r\n" Spacechar=[\ \t\f] -NUMBER=[0-9]+(\.[0-9]*)? -STRING=[^~\*_`&\[\]()> -LineBreak ::= " " NormalEndline -Indent ::= "\t" | " " +EndLine ::= TerminalEndline | NormalEndline +private NormalEndline ::= OptionalSpace Newline !BlankLine +private TerminalEndline ::= OptionalSpace Newline <> +private Indent ::= "\t" | " " // ---- BLOCKS ---- Block ::= BlankLine* ( @@ -42,7 +44,7 @@ Block ::= BlankLine* ( ) Para ::= NonindentSpace Inlines (BlankLine+ | TerminalEndline) -Plain ::= Inlines +private Plain ::= Inlines HorizontalRule ::= NonindentSpace ( '*' OptionalSpace '*' OptionalSpace '*' (OptionalSpace '*')* @@ -51,12 +53,12 @@ HorizontalRule ::= NonindentSpace OptionalSpace Newline BlankLine+ Bullet ::= !HorizontalRule NonindentSpace ('+' | '*' | '-') Spacechar+ -Enumerator ::= NonindentSpace number '.' Spacechar+ +Enumerator ::= NonindentSpace Number '.' Spacechar+ BulletList ::= &Bullet List OrderedList ::= &Enumerator List -List ::= (ListItem BlankLine*)+ +private List ::= (ListItem BlankLine*)+ ListItem ::= (Bullet | Enumerator) ListBlock ( ListContinuationBlock )* ListBlock ::= !BlankLine Plain ( ListBlockLine )* @@ -66,18 +68,19 @@ ListContinuationBlock ::= BlankLine* (Indent ListBlock)+ // ---- INLINES ---- -Inlines ::= (!EndLine Inline | EndLine &Inline )+ EndLine? -Inline ::= String | EndLine | RequiredSpace | Strong | Emph | Link +private Inlines ::= (!EndLine Inline | EndLine &Inline )+ EndLine? +Inline ::= String | Number | EndLine | Spacechar+ | Strong | Emph | Link Emph ::= EmphStar | EmphUnderscore -EmphStar ::= '*' !Whitespace (!'*' Inline)+ '*' -EmphUnderscore ::= '_' !Whitespace (!'_' Inline)+ '_' +private EmphStar ::= '*' !Whitespace (!'*' Inline)+ '*' +private EmphUnderscore ::= '_' !Whitespace (!'_' Inline)+ '_' Strong ::= StrongStar | StrongUnderscore StrongStar ::= '**' !Whitespace (!'**' Inline)+ '**' StrongUnderscore ::= '__' !Whitespace (!'__' Inline)+ '__' -Link ::= ReferenceLink -ReferenceLink ::= ReferenceLinkSingle -ReferenceLinkSingle ::= '[' Target ']' -Target ::= String \ No newline at end of file +Link ::= HrefLink | ReferenceLink +private ReferenceLink ::= '[' Target ']' +private HrefLink ::= '[' Target ']' '(' Href ')' +Target ::= String +Href ::= String \ No newline at end of file diff --git a/test/src/markdown/ParserTest.kt b/test/src/markdown/ParserTest.kt index b4538b07..7b1522bc 100644 --- a/test/src/markdown/ParserTest.kt +++ b/test/src/markdown/ParserTest.kt @@ -14,6 +14,16 @@ public class ParserTest { println(markdown.dump()) } + Test fun link() { + val markdown = MarkdownProcessor().parse("text [links]") + println(markdown.dump()) + } + + Test fun linkWithHref() { + val markdown = MarkdownProcessor().parse("text [links](http://destination)") + println(markdown.dump()) + } + Test fun multiline() { val markdown = MarkdownProcessor().parse( """ @@ -44,6 +54,28 @@ number two println(markdown.dump()) } + Test fun bulletListWithLines() { + val markdown = MarkdownProcessor().parse( +""" +* list item 1 + continue 1 +* list item 2 + continue 2 + """) + println(markdown.dump()) + } + + Test fun bulletListStrong() { + val markdown = MarkdownProcessor().parse( +""" +* list *item* 1 + continue 1 +* list *item* 2 + continue 2 + """) + println(markdown.dump()) + } + Test fun emph() { val markdown = MarkdownProcessor().parse("*text*") println(markdown.dump()) -- cgit