super-quick-rb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/rdoc-8.0.0/CONTRIBUTING.md +195 -0
- data/rdoc-8.0.0/CVE-2013-0256.rdoc +49 -0
- data/rdoc-8.0.0/History.rdoc +1668 -0
- data/rdoc-8.0.0/LEGAL.rdoc +56 -0
- data/rdoc-8.0.0/LICENSE.rdoc +63 -0
- data/rdoc-8.0.0/README.md +236 -0
- data/rdoc-8.0.0/RI.md +842 -0
- data/rdoc-8.0.0/TODO.rdoc +60 -0
- data/rdoc-8.0.0/doc/markup_reference/markdown.md +659 -0
- data/rdoc-8.0.0/doc/markup_reference/rdoc.rdoc +1169 -0
- data/rdoc-8.0.0/exe/rdoc +43 -0
- data/rdoc-8.0.0/exe/ri +12 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/alias.rb +98 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/any_method.rb +387 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/attr.rb +178 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/class_module.rb +969 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/constant.rb +221 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/context/section.rb +182 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/context.rb +1238 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/extend.rb +9 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/include.rb +9 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/method_attr.rb +417 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/mixin.rb +123 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/normal_class.rb +92 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/normal_module.rb +73 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/require.rb +51 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/single_class.rb +30 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb +286 -0
- data/rdoc-8.0.0/lib/rdoc/code_object.rb +393 -0
- data/rdoc-8.0.0/lib/rdoc/code_objects.rb +5 -0
- data/rdoc-8.0.0/lib/rdoc/comment.rb +353 -0
- data/rdoc-8.0.0/lib/rdoc/cross_reference.rb +215 -0
- data/rdoc-8.0.0/lib/rdoc/encoding.rb +120 -0
- data/rdoc-8.0.0/lib/rdoc/erb_partial.rb +18 -0
- data/rdoc-8.0.0/lib/rdoc/erbio.rb +37 -0
- data/rdoc-8.0.0/lib/rdoc/generator/aliki.rb +200 -0
- data/rdoc-8.0.0/lib/rdoc/generator/darkfish.rb +824 -0
- data/rdoc-8.0.0/lib/rdoc/generator/json_index.rb +284 -0
- data/rdoc-8.0.0/lib/rdoc/generator/markup.rb +196 -0
- data/rdoc-8.0.0/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/rdoc-8.0.0/lib/rdoc/generator/pot/po.rb +84 -0
- data/rdoc-8.0.0/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/rdoc-8.0.0/lib/rdoc/generator/pot.rb +94 -0
- data/rdoc-8.0.0/lib/rdoc/generator/ri.rb +30 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_head.rhtml +43 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +5 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +17 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +17 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +16 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +21 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +32 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +6 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +15 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +39 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/class.rhtml +220 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/rdoc.css +701 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/index.rhtml +24 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/darkfish.js +140 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/search.js +120 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/page.rhtml +19 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +21 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +65 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +72 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/searcher.js +271 -0
- data/rdoc-8.0.0/lib/rdoc/generator.rb +52 -0
- data/rdoc-8.0.0/lib/rdoc/i18n/locale.rb +102 -0
- data/rdoc-8.0.0/lib/rdoc/i18n/text.rb +126 -0
- data/rdoc-8.0.0/lib/rdoc/i18n.rb +10 -0
- data/rdoc-8.0.0/lib/rdoc/known_classes.rb +74 -0
- data/rdoc-8.0.0/lib/rdoc/markdown/entities.rb +2131 -0
- data/rdoc-8.0.0/lib/rdoc/markdown/literals.kpeg +21 -0
- data/rdoc-8.0.0/lib/rdoc/markdown/literals.rb +454 -0
- data/rdoc-8.0.0/lib/rdoc/markdown.kpeg +1315 -0
- data/rdoc-8.0.0/lib/rdoc/markdown.rb +16865 -0
- data/rdoc-8.0.0/lib/rdoc/markup/blank_line.rb +29 -0
- data/rdoc-8.0.0/lib/rdoc/markup/block_quote.rb +14 -0
- data/rdoc-8.0.0/lib/rdoc/markup/document.rb +164 -0
- data/rdoc-8.0.0/lib/rdoc/markup/element.rb +21 -0
- data/rdoc-8.0.0/lib/rdoc/markup/formatter.rb +285 -0
- data/rdoc-8.0.0/lib/rdoc/markup/hard_break.rb +34 -0
- data/rdoc-8.0.0/lib/rdoc/markup/heading.rb +170 -0
- data/rdoc-8.0.0/lib/rdoc/markup/include.rb +42 -0
- data/rdoc-8.0.0/lib/rdoc/markup/indented_paragraph.rb +47 -0
- data/rdoc-8.0.0/lib/rdoc/markup/inline_parser.rb +312 -0
- data/rdoc-8.0.0/lib/rdoc/markup/list.rb +101 -0
- data/rdoc-8.0.0/lib/rdoc/markup/list_item.rb +99 -0
- data/rdoc-8.0.0/lib/rdoc/markup/paragraph.rb +28 -0
- data/rdoc-8.0.0/lib/rdoc/markup/parser.rb +585 -0
- data/rdoc-8.0.0/lib/rdoc/markup/pre_process.rb +317 -0
- data/rdoc-8.0.0/lib/rdoc/markup/raw.rb +66 -0
- data/rdoc-8.0.0/lib/rdoc/markup/rule.rb +20 -0
- data/rdoc-8.0.0/lib/rdoc/markup/table.rb +64 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_ansi.rb +144 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_bs.rb +86 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_html.rb +682 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_html_crossref.rb +261 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_html_snippet.rb +287 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_joined_paragraph.rb +41 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_label.rb +84 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_markdown.rb +215 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_rdoc.rb +421 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_table_of_contents.rb +88 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_test.rb +77 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_tt_only.rb +107 -0
- data/rdoc-8.0.0/lib/rdoc/markup/verbatim.rb +83 -0
- data/rdoc-8.0.0/lib/rdoc/markup.rb +219 -0
- data/rdoc-8.0.0/lib/rdoc/options.rb +1412 -0
- data/rdoc-8.0.0/lib/rdoc/parser/c.rb +1227 -0
- data/rdoc-8.0.0/lib/rdoc/parser/changelog.rb +379 -0
- data/rdoc-8.0.0/lib/rdoc/parser/markdown.rb +22 -0
- data/rdoc-8.0.0/lib/rdoc/parser/rbs.rb +275 -0
- data/rdoc-8.0.0/lib/rdoc/parser/rd.rb +22 -0
- data/rdoc-8.0.0/lib/rdoc/parser/ruby.rb +1266 -0
- data/rdoc-8.0.0/lib/rdoc/parser/ruby_colorizer.rb +253 -0
- data/rdoc-8.0.0/lib/rdoc/parser/simple.rb +44 -0
- data/rdoc-8.0.0/lib/rdoc/parser/text.rb +11 -0
- data/rdoc-8.0.0/lib/rdoc/parser.rb +298 -0
- data/rdoc-8.0.0/lib/rdoc/rbs_helper.rb +186 -0
- data/rdoc-8.0.0/lib/rdoc/rd/block_parser.rb +1706 -0
- data/rdoc-8.0.0/lib/rdoc/rd/block_parser.ry +643 -0
- data/rdoc-8.0.0/lib/rdoc/rd/inline.rb +71 -0
- data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.rb +1854 -0
- data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.ry +593 -0
- data/rdoc-8.0.0/lib/rdoc/rd.rb +99 -0
- data/rdoc-8.0.0/lib/rdoc/rdoc.rb +724 -0
- data/rdoc-8.0.0/lib/rdoc/ri/driver.rb +1572 -0
- data/rdoc-8.0.0/lib/rdoc/ri/formatter.rb +6 -0
- data/rdoc-8.0.0/lib/rdoc/ri/paths.rb +171 -0
- data/rdoc-8.0.0/lib/rdoc/ri/servlet.rb +452 -0
- data/rdoc-8.0.0/lib/rdoc/ri/store.rb +6 -0
- data/rdoc-8.0.0/lib/rdoc/ri/task.rb +71 -0
- data/rdoc-8.0.0/lib/rdoc/ri.rb +21 -0
- data/rdoc-8.0.0/lib/rdoc/rubygems_hook.rb +327 -0
- data/rdoc-8.0.0/lib/rdoc/server.rb +460 -0
- data/rdoc-8.0.0/lib/rdoc/stats/normal.rb +58 -0
- data/rdoc-8.0.0/lib/rdoc/stats/quiet.rb +59 -0
- data/rdoc-8.0.0/lib/rdoc/stats/verbose.rb +44 -0
- data/rdoc-8.0.0/lib/rdoc/stats.rb +484 -0
- data/rdoc-8.0.0/lib/rdoc/store.rb +1205 -0
- data/rdoc-8.0.0/lib/rdoc/task.rb +355 -0
- data/rdoc-8.0.0/lib/rdoc/text.rb +244 -0
- data/rdoc-8.0.0/lib/rdoc/token_stream.rb +104 -0
- data/rdoc-8.0.0/lib/rdoc/tom_doc.rb +257 -0
- data/rdoc-8.0.0/lib/rdoc/version.rb +10 -0
- data/rdoc-8.0.0/lib/rdoc.rb +239 -0
- data/rdoc-8.0.0/lib/rubygems_plugin.rb +14 -0
- data/rdoc-8.0.0/man/ri.1 +249 -0
- data/rdoc-8.0.0/rdoc-logo.svg +43 -0
- data/rdoc-8.0.0/rdoc.gemspec +74 -0
- data/super-quick-rb.gemspec +12 -0
- metadata +257 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'strscan'
|
|
3
|
+
|
|
4
|
+
##
|
|
5
|
+
# A recursive-descent parser for RDoc markup.
|
|
6
|
+
#
|
|
7
|
+
# The parser tokenizes an input string then parses the tokens into a Document.
|
|
8
|
+
# Documents can be converted into output formats by writing a visitor like
|
|
9
|
+
# RDoc::Markup::ToHTML.
|
|
10
|
+
#
|
|
11
|
+
# The parser only handles the block-level constructs Paragraph, List,
|
|
12
|
+
# ListItem, Heading, Verbatim, BlankLine, Rule and BlockQuote.
|
|
13
|
+
# Inline markup such as <tt>\+blah\+</tt> is handled separately by
|
|
14
|
+
# RDoc::Markup::InlineParser.
|
|
15
|
+
#
|
|
16
|
+
# To see what markup the Parser implements read RDoc. To see how to use
|
|
17
|
+
# RDoc markup to format text in your program read RDoc::Markup.
|
|
18
|
+
|
|
19
|
+
class RDoc::Markup::Parser
|
|
20
|
+
|
|
21
|
+
include RDoc::Text
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# List token types
|
|
25
|
+
|
|
26
|
+
LIST_TOKENS = [
|
|
27
|
+
:BULLET,
|
|
28
|
+
:LABEL,
|
|
29
|
+
:LALPHA,
|
|
30
|
+
:NOTE,
|
|
31
|
+
:NUMBER,
|
|
32
|
+
:UALPHA,
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
# Parser error subclass
|
|
37
|
+
|
|
38
|
+
class Error < RuntimeError; end
|
|
39
|
+
|
|
40
|
+
##
|
|
41
|
+
# Raised when the parser is unable to handle the given markup
|
|
42
|
+
|
|
43
|
+
class ParseError < Error; end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Enables display of debugging information
|
|
47
|
+
|
|
48
|
+
attr_accessor :debug
|
|
49
|
+
|
|
50
|
+
##
|
|
51
|
+
# Token accessor
|
|
52
|
+
|
|
53
|
+
attr_reader :tokens
|
|
54
|
+
|
|
55
|
+
##
|
|
56
|
+
# Parses +str+ into a Document.
|
|
57
|
+
#
|
|
58
|
+
# Use RDoc::Markup#parse instead of this method.
|
|
59
|
+
|
|
60
|
+
def self.parse(str)
|
|
61
|
+
parser = new
|
|
62
|
+
parser.tokenize str
|
|
63
|
+
doc = RDoc::Markup::Document.new
|
|
64
|
+
parser.parse doc
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
##
|
|
68
|
+
# Returns a token stream for +str+, for testing
|
|
69
|
+
|
|
70
|
+
def self.tokenize(str)
|
|
71
|
+
parser = new
|
|
72
|
+
parser.tokenize str
|
|
73
|
+
parser.tokens
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
##
|
|
77
|
+
# Creates a new Parser. See also ::parse
|
|
78
|
+
|
|
79
|
+
def initialize
|
|
80
|
+
@binary_input = nil
|
|
81
|
+
@current_token = nil
|
|
82
|
+
@debug = false
|
|
83
|
+
@s = nil
|
|
84
|
+
@tokens = []
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
##
|
|
88
|
+
# Builds a Heading of +level+
|
|
89
|
+
|
|
90
|
+
def build_heading(level)
|
|
91
|
+
type, text, = get
|
|
92
|
+
|
|
93
|
+
text = case type
|
|
94
|
+
when :TEXT then
|
|
95
|
+
skip :NEWLINE
|
|
96
|
+
text
|
|
97
|
+
else
|
|
98
|
+
unget
|
|
99
|
+
''
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
RDoc::Markup::Heading.new level, text
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
##
|
|
106
|
+
# Builds a List flush to +margin+
|
|
107
|
+
|
|
108
|
+
def build_list(margin)
|
|
109
|
+
p :list_start => margin if @debug
|
|
110
|
+
|
|
111
|
+
list = RDoc::Markup::List.new
|
|
112
|
+
label = nil
|
|
113
|
+
|
|
114
|
+
until @tokens.empty? do
|
|
115
|
+
type, data, column, = get
|
|
116
|
+
|
|
117
|
+
case type
|
|
118
|
+
when *LIST_TOKENS then
|
|
119
|
+
if column < margin || (list.type && list.type != type) then
|
|
120
|
+
unget
|
|
121
|
+
break
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
list.type = type
|
|
125
|
+
peek_type, _, column, = peek_token
|
|
126
|
+
|
|
127
|
+
case type
|
|
128
|
+
when :NOTE, :LABEL then
|
|
129
|
+
label = [] unless label
|
|
130
|
+
|
|
131
|
+
if peek_type == :NEWLINE then
|
|
132
|
+
# description not on the same line as LABEL/NOTE
|
|
133
|
+
# skip the trailing newline & any blank lines below
|
|
134
|
+
while peek_type == :NEWLINE
|
|
135
|
+
get
|
|
136
|
+
peek_type, _, column, = peek_token
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# we may be:
|
|
140
|
+
# - at end of stream
|
|
141
|
+
# - at a column < margin:
|
|
142
|
+
# [text]
|
|
143
|
+
# blah blah blah
|
|
144
|
+
# - at the same column, but with a different type of list item
|
|
145
|
+
# [text]
|
|
146
|
+
# * blah blah
|
|
147
|
+
# - at the same column, with the same type of list item
|
|
148
|
+
# [one]
|
|
149
|
+
# [two]
|
|
150
|
+
# In all cases, we have an empty description.
|
|
151
|
+
# In the last case only, we continue.
|
|
152
|
+
if peek_type.nil? || column < margin then
|
|
153
|
+
empty = true
|
|
154
|
+
elsif column == margin then
|
|
155
|
+
case peek_type
|
|
156
|
+
when type
|
|
157
|
+
empty = :continue
|
|
158
|
+
when *LIST_TOKENS
|
|
159
|
+
empty = true
|
|
160
|
+
else
|
|
161
|
+
empty = false
|
|
162
|
+
end
|
|
163
|
+
else
|
|
164
|
+
empty = false
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
if empty then
|
|
168
|
+
label << data
|
|
169
|
+
next if empty == :continue
|
|
170
|
+
break
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
else
|
|
174
|
+
data = nil
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
if label then
|
|
178
|
+
data = label << data
|
|
179
|
+
label = nil
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
list_item = RDoc::Markup::ListItem.new data
|
|
183
|
+
parse list_item, column
|
|
184
|
+
list << list_item
|
|
185
|
+
|
|
186
|
+
else
|
|
187
|
+
unget
|
|
188
|
+
break
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
p :list_end => margin if @debug
|
|
193
|
+
|
|
194
|
+
if list.empty? then
|
|
195
|
+
return nil unless label
|
|
196
|
+
return nil unless [:LABEL, :NOTE].include? list.type
|
|
197
|
+
|
|
198
|
+
list_item = RDoc::Markup::ListItem.new label, RDoc::Markup::BlankLine.new
|
|
199
|
+
list << list_item
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
list
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
##
|
|
206
|
+
# Builds a Paragraph that is flush to +margin+
|
|
207
|
+
|
|
208
|
+
def build_paragraph(margin)
|
|
209
|
+
p :paragraph_start => margin if @debug
|
|
210
|
+
|
|
211
|
+
paragraph = RDoc::Markup::Paragraph.new
|
|
212
|
+
|
|
213
|
+
until @tokens.empty? do
|
|
214
|
+
type, data, column, = get
|
|
215
|
+
|
|
216
|
+
if type == :TEXT and column == margin then
|
|
217
|
+
paragraph << data
|
|
218
|
+
|
|
219
|
+
break if peek_token.first == :BREAK
|
|
220
|
+
|
|
221
|
+
data << ' ' if skip :NEWLINE and /#{SPACE_SEPARATED_LETTER_CLASS}\z/o.match?(data)
|
|
222
|
+
else
|
|
223
|
+
unget
|
|
224
|
+
break
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
paragraph.parts.last.sub!(/ \z/, '') # cleanup
|
|
229
|
+
|
|
230
|
+
p :paragraph_end => margin if @debug
|
|
231
|
+
|
|
232
|
+
paragraph
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
##
|
|
236
|
+
# Builds a Verbatim that is indented from +margin+.
|
|
237
|
+
#
|
|
238
|
+
# The verbatim block is shifted left (the least indented lines start in
|
|
239
|
+
# column 0). Each part of the verbatim is one line of text, always
|
|
240
|
+
# terminated by a newline. Blank lines always consist of a single newline
|
|
241
|
+
# character, and there is never a single newline at the end of the verbatim.
|
|
242
|
+
|
|
243
|
+
def build_verbatim(margin)
|
|
244
|
+
p :verbatim_begin => margin if @debug
|
|
245
|
+
verbatim = RDoc::Markup::Verbatim.new
|
|
246
|
+
|
|
247
|
+
min_indent = nil
|
|
248
|
+
generate_leading_spaces = true
|
|
249
|
+
line = ''.dup
|
|
250
|
+
|
|
251
|
+
until @tokens.empty? do
|
|
252
|
+
type, data, column, = get
|
|
253
|
+
|
|
254
|
+
if type == :NEWLINE then
|
|
255
|
+
line << data
|
|
256
|
+
verbatim << line
|
|
257
|
+
line = ''.dup
|
|
258
|
+
generate_leading_spaces = true
|
|
259
|
+
next
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
if column <= margin
|
|
263
|
+
unget
|
|
264
|
+
break
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
if generate_leading_spaces then
|
|
268
|
+
indent = column - margin
|
|
269
|
+
line << ' ' * indent
|
|
270
|
+
min_indent = indent if min_indent.nil? || indent < min_indent
|
|
271
|
+
generate_leading_spaces = false
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
case type
|
|
275
|
+
when :HEADER then
|
|
276
|
+
line << '=' * data
|
|
277
|
+
_, _, peek_column, = peek_token
|
|
278
|
+
peek_column ||= column + data
|
|
279
|
+
indent = peek_column - column - data
|
|
280
|
+
line << ' ' * indent
|
|
281
|
+
when :RULE then
|
|
282
|
+
width = 2 + data
|
|
283
|
+
line << '-' * width
|
|
284
|
+
_, _, peek_column, = peek_token
|
|
285
|
+
peek_column ||= column + width
|
|
286
|
+
indent = peek_column - column - width
|
|
287
|
+
line << ' ' * indent
|
|
288
|
+
when :BREAK, :TEXT then
|
|
289
|
+
line << data
|
|
290
|
+
when :BLOCKQUOTE then
|
|
291
|
+
line << '>>>'
|
|
292
|
+
peek_type, _, peek_column = peek_token
|
|
293
|
+
if peek_type != :NEWLINE and peek_column
|
|
294
|
+
line << ' ' * (peek_column - column - 3)
|
|
295
|
+
end
|
|
296
|
+
else # *LIST_TOKENS
|
|
297
|
+
list_marker = case type
|
|
298
|
+
when :BULLET then data
|
|
299
|
+
when :LABEL then "[#{data}]"
|
|
300
|
+
when :NOTE then "#{data}::"
|
|
301
|
+
else # :LALPHA, :NUMBER, :UALPHA
|
|
302
|
+
"#{data}."
|
|
303
|
+
end
|
|
304
|
+
line << list_marker
|
|
305
|
+
peek_type, _, peek_column = peek_token
|
|
306
|
+
unless peek_type == :NEWLINE then
|
|
307
|
+
peek_column ||= column + list_marker.length
|
|
308
|
+
indent = peek_column - column - list_marker.length
|
|
309
|
+
line << ' ' * indent
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
verbatim << line << "\n" unless line.empty?
|
|
316
|
+
verbatim.parts.each { |p| p.slice!(0, min_indent) unless p == "\n" } if min_indent > 0
|
|
317
|
+
verbatim.normalize
|
|
318
|
+
|
|
319
|
+
p :verbatim_end => margin if @debug
|
|
320
|
+
|
|
321
|
+
verbatim
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
##
|
|
325
|
+
# Pulls the next token from the stream.
|
|
326
|
+
|
|
327
|
+
def get
|
|
328
|
+
@current_token = @tokens.shift
|
|
329
|
+
p :get => @current_token if @debug
|
|
330
|
+
@current_token
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
##
|
|
334
|
+
# Parses the tokens into an array of RDoc::Markup::XXX objects,
|
|
335
|
+
# and appends them to the passed +parent+ RDoc::Markup::YYY object.
|
|
336
|
+
#
|
|
337
|
+
# Exits at the end of the token stream, or when it encounters a token
|
|
338
|
+
# in a column less than +indent+ (unless it is a NEWLINE).
|
|
339
|
+
#
|
|
340
|
+
# Returns +parent+.
|
|
341
|
+
|
|
342
|
+
def parse(parent, indent = 0)
|
|
343
|
+
p :parse_start => indent if @debug
|
|
344
|
+
|
|
345
|
+
until @tokens.empty? do
|
|
346
|
+
type, data, column, = get
|
|
347
|
+
|
|
348
|
+
case type
|
|
349
|
+
when :BREAK then
|
|
350
|
+
parent << RDoc::Markup::BlankLine.new
|
|
351
|
+
skip :NEWLINE, false
|
|
352
|
+
next
|
|
353
|
+
when :NEWLINE then
|
|
354
|
+
# trailing newlines are skipped below, so this is a blank line
|
|
355
|
+
parent << RDoc::Markup::BlankLine.new
|
|
356
|
+
skip :NEWLINE, false
|
|
357
|
+
next
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# indentation change: break or verbatim
|
|
361
|
+
if column < indent then
|
|
362
|
+
unget
|
|
363
|
+
break
|
|
364
|
+
elsif column > indent then
|
|
365
|
+
unget
|
|
366
|
+
parent << build_verbatim(indent)
|
|
367
|
+
next
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
# indentation is the same
|
|
371
|
+
case type
|
|
372
|
+
when :HEADER then
|
|
373
|
+
parent << build_heading(data)
|
|
374
|
+
when :RULE then
|
|
375
|
+
parent << RDoc::Markup::Rule.new(data)
|
|
376
|
+
skip :NEWLINE
|
|
377
|
+
when :TEXT then
|
|
378
|
+
unget
|
|
379
|
+
parse_text parent, indent
|
|
380
|
+
when :BLOCKQUOTE then
|
|
381
|
+
nil while (type, = get; type) and type != :NEWLINE
|
|
382
|
+
_, _, column, = peek_token
|
|
383
|
+
bq = RDoc::Markup::BlockQuote.new
|
|
384
|
+
p :blockquote_start => [data, column] if @debug
|
|
385
|
+
parse bq, column
|
|
386
|
+
p :blockquote_end => indent if @debug
|
|
387
|
+
parent << bq
|
|
388
|
+
when *LIST_TOKENS then
|
|
389
|
+
unget
|
|
390
|
+
parent << build_list(indent)
|
|
391
|
+
else
|
|
392
|
+
type, data, column, line = @current_token
|
|
393
|
+
raise ParseError, "Unhandled token #{type} (#{data.inspect}) at #{line}:#{column}"
|
|
394
|
+
end
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
p :parse_end => indent if @debug
|
|
398
|
+
|
|
399
|
+
parent
|
|
400
|
+
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
##
|
|
404
|
+
# Small hook that is overridden by RDoc::TomDoc
|
|
405
|
+
|
|
406
|
+
def parse_text(parent, indent) # :nodoc:
|
|
407
|
+
parent << build_paragraph(indent)
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
##
|
|
411
|
+
# Returns the next token on the stream without modifying the stream
|
|
412
|
+
|
|
413
|
+
def peek_token
|
|
414
|
+
token = @tokens.first || []
|
|
415
|
+
p :peek => token if @debug
|
|
416
|
+
token
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
##
|
|
420
|
+
# A simple wrapper of StringScanner that is aware of the current column and lineno
|
|
421
|
+
|
|
422
|
+
class MyStringScanner
|
|
423
|
+
# :stopdoc:
|
|
424
|
+
|
|
425
|
+
def initialize(input)
|
|
426
|
+
@line = @column = 0
|
|
427
|
+
@s = StringScanner.new input
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
def scan(re)
|
|
431
|
+
ret = @s.scan(re)
|
|
432
|
+
@column += ret.length if ret
|
|
433
|
+
ret
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
def unscan(s)
|
|
437
|
+
@s.pos -= s.bytesize
|
|
438
|
+
@column -= s.length
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
def pos
|
|
442
|
+
[@column, @line]
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
def newline!
|
|
446
|
+
@column = 0
|
|
447
|
+
@line += 1
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def eos?
|
|
451
|
+
@s.eos?
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
def matched
|
|
455
|
+
@s.matched
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def [](i)
|
|
459
|
+
@s[i]
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
#:startdoc:
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
##
|
|
466
|
+
# Creates the StringScanner
|
|
467
|
+
|
|
468
|
+
def setup_scanner(input)
|
|
469
|
+
@s = MyStringScanner.new input
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
##
|
|
473
|
+
# Skips the next token if its type is +token_type+.
|
|
474
|
+
#
|
|
475
|
+
# Optionally raises an error if the next token is not of the expected type.
|
|
476
|
+
|
|
477
|
+
def skip(token_type, error = true)
|
|
478
|
+
type, = get
|
|
479
|
+
return unless type # end of stream
|
|
480
|
+
return @current_token if token_type == type
|
|
481
|
+
unget
|
|
482
|
+
raise ParseError, "expected #{token_type} got #{@current_token.inspect}" if error
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
##
|
|
486
|
+
# Turns text +input+ into a stream of tokens
|
|
487
|
+
|
|
488
|
+
def tokenize(input)
|
|
489
|
+
setup_scanner input
|
|
490
|
+
|
|
491
|
+
until @s.eos? do
|
|
492
|
+
pos = @s.pos
|
|
493
|
+
|
|
494
|
+
# leading spaces will be reflected by the column of the next token
|
|
495
|
+
# the only thing we loose are trailing spaces at the end of the file
|
|
496
|
+
next if @s.scan(/ +/)
|
|
497
|
+
|
|
498
|
+
# note: after BULLET, LABEL, etc.,
|
|
499
|
+
# indent will be the column of the next non-newline token
|
|
500
|
+
|
|
501
|
+
@tokens << case
|
|
502
|
+
# [CR]LF => :NEWLINE
|
|
503
|
+
when @s.scan(/\r?\n/) then
|
|
504
|
+
token = [:NEWLINE, @s.matched, *pos]
|
|
505
|
+
@s.newline!
|
|
506
|
+
token
|
|
507
|
+
# === text => :HEADER then :TEXT
|
|
508
|
+
when @s.scan(/(=+)(\s*)/) then
|
|
509
|
+
level = @s[1].length
|
|
510
|
+
header = [:HEADER, level, *pos]
|
|
511
|
+
|
|
512
|
+
if @s[2] =~ /^\r?\n/ then
|
|
513
|
+
@s.unscan(@s[2])
|
|
514
|
+
header
|
|
515
|
+
else
|
|
516
|
+
pos = @s.pos
|
|
517
|
+
@s.scan(/.*/)
|
|
518
|
+
@tokens << header
|
|
519
|
+
[:TEXT, @s.matched.sub(/\r$/, ''), *pos]
|
|
520
|
+
end
|
|
521
|
+
# --- (at least 3) and nothing else on the line => :RULE
|
|
522
|
+
when @s.scan(/(-{3,}) *\r?$/) then
|
|
523
|
+
[:RULE, @s[1].length - 2, *pos]
|
|
524
|
+
# * or - followed by white space and text => :BULLET
|
|
525
|
+
when @s.scan(/([*-]) +(\S)/) then
|
|
526
|
+
@s.unscan(@s[2])
|
|
527
|
+
[:BULLET, @s[1], *pos]
|
|
528
|
+
# A. text, a. text, 12. text => :UALPHA, :LALPHA, :NUMBER
|
|
529
|
+
when @s.scan(/([a-z]|\d+)\. +(\S)/i) then
|
|
530
|
+
# FIXME if tab(s), the column will be wrong
|
|
531
|
+
# either support tabs everywhere by first expanding them to
|
|
532
|
+
# spaces, or assume that they will have been replaced
|
|
533
|
+
# before (and provide a check for that at least in debug
|
|
534
|
+
# mode)
|
|
535
|
+
list_label = @s[1]
|
|
536
|
+
@s.unscan(@s[2])
|
|
537
|
+
list_type =
|
|
538
|
+
case list_label
|
|
539
|
+
when /[a-z]/ then :LALPHA
|
|
540
|
+
when /[A-Z]/ then :UALPHA
|
|
541
|
+
when /\d/ then :NUMBER
|
|
542
|
+
else
|
|
543
|
+
raise ParseError, "BUG token #{list_label}"
|
|
544
|
+
end
|
|
545
|
+
[list_type, list_label, *pos]
|
|
546
|
+
# [text] followed by spaces or end of line => :LABEL
|
|
547
|
+
when @s.scan(/\[(.*?)\]( +|\r?$)/) then
|
|
548
|
+
[:LABEL, @s[1], *pos]
|
|
549
|
+
# text:: followed by spaces or end of line => :NOTE
|
|
550
|
+
when @s.scan(/(.*?)::( +|\r?$)/) then
|
|
551
|
+
[:NOTE, @s[1], *pos]
|
|
552
|
+
# >>> followed by end of line => :BLOCKQUOTE
|
|
553
|
+
when @s.scan(/>>> *(\w+)?$/) then
|
|
554
|
+
if word = @s[1]
|
|
555
|
+
@s.unscan(word)
|
|
556
|
+
end
|
|
557
|
+
[:BLOCKQUOTE, word, *pos]
|
|
558
|
+
# anything else: :TEXT
|
|
559
|
+
else
|
|
560
|
+
@s.scan(/(.*?)( )?\r?$/)
|
|
561
|
+
token = [:TEXT, @s[1], *pos]
|
|
562
|
+
|
|
563
|
+
if @s[2] then
|
|
564
|
+
@tokens << token
|
|
565
|
+
[:BREAK, @s[2], pos[0] + @s[1].length, pos[1]]
|
|
566
|
+
else
|
|
567
|
+
token
|
|
568
|
+
end
|
|
569
|
+
end
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
self
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
##
|
|
576
|
+
# Returns the current token to the token stream
|
|
577
|
+
|
|
578
|
+
def unget
|
|
579
|
+
token = @current_token
|
|
580
|
+
p :unget => token if @debug
|
|
581
|
+
raise Error, 'too many #ungets' if token == @tokens.first
|
|
582
|
+
@tokens.unshift token if token
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
end
|