Class: RDoc::RD::InlineParser
- Inherits:
-
Racc::Parser
- Object
- Racc::Parser
- RDoc::RD::InlineParser
- Defined in:
- lib/rdoc/rd/inline_parser.rb
Overview
RD format parser for inline markup such as emphasis, links, footnotes, etc.
Constant Summary collapse
- EM_OPEN =
:stopdoc:
'((*'
- EM_OPEN_RE =
/\A#{Regexp.quote(EM_OPEN)}/
- EM_CLOSE =
'*))'
- EM_CLOSE_RE =
/\A#{Regexp.quote(EM_CLOSE)}/
- CODE_OPEN =
'(({'
- CODE_OPEN_RE =
/\A#{Regexp.quote(CODE_OPEN)}/
- CODE_CLOSE =
'}))'
- CODE_CLOSE_RE =
/\A#{Regexp.quote(CODE_CLOSE)}/
- VAR_OPEN =
'((|'
- VAR_OPEN_RE =
/\A#{Regexp.quote(VAR_OPEN)}/
- VAR_CLOSE =
'|))'
- VAR_CLOSE_RE =
/\A#{Regexp.quote(VAR_CLOSE)}/
- KBD_OPEN =
'((%'
- KBD_OPEN_RE =
/\A#{Regexp.quote(KBD_OPEN)}/
- KBD_CLOSE =
'%))'
- KBD_CLOSE_RE =
/\A#{Regexp.quote(KBD_CLOSE)}/
- INDEX_OPEN =
'((:'
- INDEX_OPEN_RE =
/\A#{Regexp.quote(INDEX_OPEN)}/
- INDEX_CLOSE =
':))'
- INDEX_CLOSE_RE =
/\A#{Regexp.quote(INDEX_CLOSE)}/
- REF_OPEN =
'((<'
- REF_OPEN_RE =
/\A#{Regexp.quote(REF_OPEN)}/
- REF_CLOSE =
'>))'
- REF_CLOSE_RE =
/\A#{Regexp.quote(REF_CLOSE)}/
- FOOTNOTE_OPEN =
'((-'
- FOOTNOTE_OPEN_RE =
/\A#{Regexp.quote(FOOTNOTE_OPEN)}/
- FOOTNOTE_CLOSE =
'-))'
- FOOTNOTE_CLOSE_RE =
/\A#{Regexp.quote(FOOTNOTE_CLOSE)}/
- VERB_OPEN =
"(('"
- VERB_OPEN_RE =
/\A#{Regexp.quote(VERB_OPEN)}/
- VERB_CLOSE =
"'))"
- VERB_CLOSE_RE =
/\A#{Regexp.quote(VERB_CLOSE)}/
- BAR =
"|"
- BAR_RE =
/\A#{Regexp.quote(BAR)}/
- QUOTE =
'"'
- QUOTE_RE =
/\A#{Regexp.quote(QUOTE)}/
- SLASH =
"/"
- SLASH_RE =
/\A#{Regexp.quote(SLASH)}/
- BACK_SLASH =
"\\"
- BACK_SLASH_RE =
/\A#{Regexp.quote(BACK_SLASH)}/
- URL =
"URL:"
- URL_RE =
/\A#{Regexp.quote(URL)}/
- OTHER_RE =
Regexp.new( "\\A.+?(?=#{Regexp.quote(EM_OPEN)}|#{Regexp.quote(EM_CLOSE)}| #{Regexp.quote(CODE_OPEN)}|#{Regexp.quote(CODE_CLOSE)}| #{Regexp.quote(VAR_OPEN)}|#{Regexp.quote(VAR_CLOSE)}| #{Regexp.quote(KBD_OPEN)}|#{Regexp.quote(KBD_CLOSE)}| #{Regexp.quote(INDEX_OPEN)}|#{Regexp.quote(INDEX_CLOSE)}| #{Regexp.quote(REF_OPEN)}|#{Regexp.quote(REF_CLOSE)}| #{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}| #{Regexp.quote(VERB_OPEN)}|#{Regexp.quote(VERB_CLOSE)}| #{Regexp.quote(BAR)}| #{Regexp.quote(QUOTE)}| #{Regexp.quote(SLASH)}| #{Regexp.quote(BACK_SLASH)}| #{Regexp.quote(URL)})", other_re_mode)
- Racc_arg =
[ racc_action_table, racc_action_check, racc_action_default, racc_action_pointer, racc_goto_table, racc_goto_check, racc_goto_default, racc_goto_pointer, racc_nt_base, racc_reduce_table, racc_token_table, racc_shift_n, racc_reduce_n, racc_use_result_var ]
- Racc_token_to_s_table =
[ "$end", "error", "EX_LOW", "QUOTE", "BAR", "SLASH", "BACK_SLASH", "URL", "OTHER", "REF_OPEN", "FOOTNOTE_OPEN", "FOOTNOTE_CLOSE", "EX_HIGH", "EM_OPEN", "EM_CLOSE", "CODE_OPEN", "CODE_CLOSE", "VAR_OPEN", "VAR_CLOSE", "KBD_OPEN", "KBD_CLOSE", "INDEX_OPEN", "INDEX_CLOSE", "REF_CLOSE", "VERB_OPEN", "VERB_CLOSE", "$start", "content", "elements", "element", "emphasis", "code", "var", "keyboard", "index", "reference", "footnote", "verb", "normal_str_ele", "substitute", "ref_label", "ref_label2", "ref_url_strings", "filename", "element_label", "element_label2", "ref_subst_content", "ref_subst_content_q", "ref_subst_strings_q", "ref_subst_strings_first", "ref_subst_ele2", "ref_subst_eles", "ref_subst_str_ele_first", "ref_subst_eles_q", "ref_subst_ele", "ref_subst_ele_q", "ref_subst_str_ele", "ref_subst_str_ele_q", "ref_subst_strings", "ref_subst_string3", "ref_subst_string", "ref_subst_string_q", "ref_subst_string2", "ref_url_string", "verb_strings", "normal_string", "normal_strings", "verb_string", "verb_normal_string" ]
- Racc_debug_parser =
false
Constants inherited from Racc::Parser
Racc::Parser::Racc_Runtime_Core_Version_R, Racc::Parser::Racc_Runtime_Version
Instance Method Summary collapse
-
#_reduce_101(val, _values, result) ⇒ Object
reduce 100 omitted.
- #_reduce_102(val, _values, result) ⇒ Object
-
#_reduce_109(val, _values, result) ⇒ Object
reduce 108 omitted.
-
#_reduce_111(val, _values, result) ⇒ Object
reduce 110 omitted.
-
#_reduce_113(val, _values, result) ⇒ Object
reduce 112 omitted.
- #_reduce_114(val, _values, result) ⇒ Object
- #_reduce_115(val, _values, result) ⇒ Object
-
#_reduce_13(val, _values, result) ⇒ Object
reduce 12 omitted.
-
#_reduce_136(val, _values, result) ⇒ Object
reduce 135 omitted.
- #_reduce_14(val, _values, result) ⇒ Object
- #_reduce_15(val, _values, result) ⇒ Object
- #_reduce_16(val, _values, result) ⇒ Object
- #_reduce_17(val, _values, result) ⇒ Object
- #_reduce_18(val, _values, result) ⇒ Object
- #_reduce_19(val, _values, result) ⇒ Object
-
#_reduce_2(val, _values, result) ⇒ Object
reduce 1 omitted.
- #_reduce_20(val, _values, result) ⇒ Object
- #_reduce_21(val, _values, result) ⇒ Object
- #_reduce_22(val, _values, result) ⇒ Object
- #_reduce_23(val, _values, result) ⇒ Object
- #_reduce_24(val, _values, result) ⇒ Object
- #_reduce_25(val, _values, result) ⇒ Object
- #_reduce_26(val, _values, result) ⇒ Object
- #_reduce_27(val, _values, result) ⇒ Object
-
#_reduce_29(val, _values, result) ⇒ Object
reduce 28 omitted.
- #_reduce_3(val, _values, result) ⇒ Object
- #_reduce_30(val, _values, result) ⇒ Object
- #_reduce_31(val, _values, result) ⇒ Object
- #_reduce_32(val, _values, result) ⇒ Object
- #_reduce_33(val, _values, result) ⇒ Object
- #_reduce_34(val, _values, result) ⇒ Object
-
#_reduce_36(val, _values, result) ⇒ Object
reduce 35 omitted.
- #_reduce_37(val, _values, result) ⇒ Object
- #_reduce_38(val, _values, result) ⇒ Object
- #_reduce_39(val, _values, result) ⇒ Object
- #_reduce_40(val, _values, result) ⇒ Object
- #_reduce_41(val, _values, result) ⇒ Object
-
#_reduce_43(val, _values, result) ⇒ Object
reduce 42 omitted.
- #_reduce_44(val, _values, result) ⇒ Object
- #_reduce_45(val, _values, result) ⇒ Object
- #_reduce_46(val, _values, result) ⇒ Object
-
#_reduce_57(val, _values, result) ⇒ Object
reduce 56 omitted.
- #_reduce_58(val, _values, result) ⇒ Object
- #_reduce_59(val, _values, result) ⇒ Object
- #_reduce_60(val, _values, result) ⇒ Object
-
#_reduce_62(val, _values, result) ⇒ Object
reduce 61 omitted.
-
#_reduce_64(val, _values, result) ⇒ Object
reduce 63 omitted.
-
#_reduce_78(val, _values, result) ⇒ Object
reduce 77 omitted.
-
#_reduce_none(val, _values, result) ⇒ Object
reduce 137 omitted.
-
#initialize(block_parser) ⇒ InlineParser
constructor
Creates a new parser for inline markup in the rd format.
-
#inline(rdoc, reference = rdoc) ⇒ Object
Creates a new RDoc::RD::Inline for the
rdoc
markup and the rawreference
. -
#next_token ⇒ Object
Returns the next token from the inline text.
-
#next_words_on_error ⇒ Object
Returns words following an error.
-
#on_error(et, ev, values) ⇒ Object
Raises a ParseError when invalid formatting is found.
-
#parse(inline) ⇒ Object
Parses the
inline
text from RD format into RDoc format. -
#prev_words_on_error(ev) ⇒ Object
Returns words before the error.
Methods inherited from Racc::Parser
#_racc_do_parse_rb, #_racc_do_reduce, #_racc_evalact, #_racc_init_sysvars, #_racc_setup, #_racc_yyparse_rb, #racc_accept, #racc_e_pop, #racc_next_state, #racc_print_stacks, #racc_print_states, #racc_read_token, #racc_reduce, racc_runtime_type, #racc_shift, #racc_token2str, #token_to_str, #yyaccept, #yyerrok, #yyerror
Constructor Details
#initialize(block_parser) ⇒ InlineParser
Creates a new parser for inline markup in the rd format. The block_parser
is used to for footnotes and labels in the inline text.
738 739 740 |
# File 'lib/rdoc/rd/inline_parser.rb', line 738 def initialize block_parser @block_parser = block_parser end |
Instance Method Details
#_reduce_101(val, _values, result) ⇒ Object
reduce 100 omitted
1750 1751 1752 1753 1754 1755 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1750 def _reduce_101(val, _values, result) index = @block_parser.add_footnote val[1].rdoc result = "{*#{index}}[rdoc-label:foottext-#{index}:footmark-#{index}]" result end |
#_reduce_102(val, _values, result) ⇒ Object
1757 1758 1759 1760 1761 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1757 def _reduce_102(val, _values, result) result = inline "<tt>#{val[1]}</tt>", val[1] result end |
#_reduce_109(val, _values, result) ⇒ Object
reduce 108 omitted
1775 1776 1777 1778 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1775 def _reduce_109(val, _values, result) result << val[1] result end |
#_reduce_111(val, _values, result) ⇒ Object
reduce 110 omitted
1782 1783 1784 1785 1786 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1782 def _reduce_111(val, _values, result) result = inline val[0] result end |
#_reduce_113(val, _values, result) ⇒ Object
reduce 112 omitted
1790 1791 1792 1793 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1790 def _reduce_113(val, _values, result) result = val[1] result end |
#_reduce_114(val, _values, result) ⇒ Object
1795 1796 1797 1798 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1795 def _reduce_114(val, _values, result) result = val[1] result end |
#_reduce_115(val, _values, result) ⇒ Object
1800 1801 1802 1803 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1800 def _reduce_115(val, _values, result) result = val[1] result end |
#_reduce_13(val, _values, result) ⇒ Object
reduce 12 omitted
1413 1414 1415 1416 1417 1418 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1413 def _reduce_13(val, _values, result) content = val[1] result = inline "<em>#{content}</em>", content result end |
#_reduce_136(val, _values, result) ⇒ Object
reduce 135 omitted
1845 1846 1847 1848 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1845 def _reduce_136(val, _values, result) result << val[1] result end |
#_reduce_14(val, _values, result) ⇒ Object
1420 1421 1422 1423 1424 1425 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1420 def _reduce_14(val, _values, result) content = val[1] result = inline "<code>#{content}</code>", content result end |
#_reduce_15(val, _values, result) ⇒ Object
1427 1428 1429 1430 1431 1432 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1427 def _reduce_15(val, _values, result) content = val[1] result = inline "+#{content}+", content result end |
#_reduce_16(val, _values, result) ⇒ Object
1434 1435 1436 1437 1438 1439 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1434 def _reduce_16(val, _values, result) content = val[1] result = inline "<tt>#{content}</tt>", content result end |
#_reduce_17(val, _values, result) ⇒ Object
1441 1442 1443 1444 1445 1446 1447 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1441 def _reduce_17(val, _values, result) label = val[1] @block_parser.add_label label.reference result = "<span id=\"label-#{label}\">#{label}</span>" result end |
#_reduce_18(val, _values, result) ⇒ Object
1449 1450 1451 1452 1453 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1449 def _reduce_18(val, _values, result) result = "{#{val[1]}}[#{val[2].join}]" result end |
#_reduce_19(val, _values, result) ⇒ Object
1455 1456 1457 1458 1459 1460 1461 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1455 def _reduce_19(val, _values, result) scheme, inline = val[1] result = "{#{inline}}[#{scheme}#{inline.reference}]" result end |
#_reduce_2(val, _values, result) ⇒ Object
reduce 1 omitted
1385 1386 1387 1388 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1385 def _reduce_2(val, _values, result) result.append val[1] result end |
#_reduce_20(val, _values, result) ⇒ Object
1463 1464 1465 1466 1467 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1463 def _reduce_20(val, _values, result) result = [nil, inline(val[1])] result end |
#_reduce_21(val, _values, result) ⇒ Object
1469 1470 1471 1472 1473 1474 1475 1476 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1469 def _reduce_21(val, _values, result) result = [ 'rdoc-label:', inline("#{val[0].reference}/#{val[1].reference}") ] result end |
#_reduce_22(val, _values, result) ⇒ Object
1478 1479 1480 1481 1482 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1478 def _reduce_22(val, _values, result) result = ['rdoc-label:', val[0].reference] result end |
#_reduce_23(val, _values, result) ⇒ Object
1484 1485 1486 1487 1488 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1484 def _reduce_23(val, _values, result) result = ['rdoc-label:', "#{val[0].reference}/"] result end |
#_reduce_24(val, _values, result) ⇒ Object
1490 1491 1492 1493 1494 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1490 def _reduce_24(val, _values, result) result = [nil, inline(val[1])] result end |
#_reduce_25(val, _values, result) ⇒ Object
1496 1497 1498 1499 1500 1501 1502 1503 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1496 def _reduce_25(val, _values, result) result = [ 'rdoc-label:', inline("#{val[0].reference}/#{val[1].reference}") ] result end |
#_reduce_26(val, _values, result) ⇒ Object
1505 1506 1507 1508 1509 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1505 def _reduce_26(val, _values, result) result = ['rdoc-label:', val[0]] result end |
#_reduce_27(val, _values, result) ⇒ Object
1511 1512 1513 1514 1515 1516 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1511 def _reduce_27(val, _values, result) ref = val[0].reference result = ['rdoc-label:', inline(ref, "#{ref}/")] result end |
#_reduce_29(val, _values, result) ⇒ Object
reduce 28 omitted
1520 1521 1522 1523 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1520 def _reduce_29(val, _values, result) result = val[1] result end |
#_reduce_3(val, _values, result) ⇒ Object
1390 1391 1392 1393 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1390 def _reduce_3(val, _values, result) result = val[0] result end |
#_reduce_30(val, _values, result) ⇒ Object
1525 1526 1527 1528 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1525 def _reduce_30(val, _values, result) result = val[1] result end |
#_reduce_31(val, _values, result) ⇒ Object
1530 1531 1532 1533 1534 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1530 def _reduce_31(val, _values, result) result = inline val[0] result end |
#_reduce_32(val, _values, result) ⇒ Object
1536 1537 1538 1539 1540 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1536 def _reduce_32(val, _values, result) result = inline "\"#{val[1]}\"" result end |
#_reduce_33(val, _values, result) ⇒ Object
1542 1543 1544 1545 1546 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1542 def _reduce_33(val, _values, result) result = inline val[0] result end |
#_reduce_34(val, _values, result) ⇒ Object
1548 1549 1550 1551 1552 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1548 def _reduce_34(val, _values, result) result = inline "\"#{val[1]}\"" result end |
#_reduce_36(val, _values, result) ⇒ Object
reduce 35 omitted
1556 1557 1558 1559 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1556 def _reduce_36(val, _values, result) result = val[1] result end |
#_reduce_37(val, _values, result) ⇒ Object
1561 1562 1563 1564 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1561 def _reduce_37(val, _values, result) result = inline val[1] result end |
#_reduce_38(val, _values, result) ⇒ Object
1566 1567 1568 1569 1570 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1566 def _reduce_38(val, _values, result) result = val[0].append val[1] result end |
#_reduce_39(val, _values, result) ⇒ Object
1572 1573 1574 1575 1576 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1572 def _reduce_39(val, _values, result) result = val[0].append val[1] result end |
#_reduce_40(val, _values, result) ⇒ Object
1578 1579 1580 1581 1582 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1578 def _reduce_40(val, _values, result) result = val[0] result end |
#_reduce_41(val, _values, result) ⇒ Object
1584 1585 1586 1587 1588 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1584 def _reduce_41(val, _values, result) result = inline val[0] result end |
#_reduce_43(val, _values, result) ⇒ Object
reduce 42 omitted
1592 1593 1594 1595 1596 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1592 def _reduce_43(val, _values, result) result = val[0].append val[1] result end |
#_reduce_44(val, _values, result) ⇒ Object
1598 1599 1600 1601 1602 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1598 def _reduce_44(val, _values, result) result = inline val[0] result end |
#_reduce_45(val, _values, result) ⇒ Object
1604 1605 1606 1607 1608 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1604 def _reduce_45(val, _values, result) result = val[0].append val[1] result end |
#_reduce_46(val, _values, result) ⇒ Object
1610 1611 1612 1613 1614 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1610 def _reduce_46(val, _values, result) result = val[0] result end |
#_reduce_57(val, _values, result) ⇒ Object
reduce 56 omitted
1636 1637 1638 1639 1640 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1636 def _reduce_57(val, _values, result) result = val[0] result end |
#_reduce_58(val, _values, result) ⇒ Object
1642 1643 1644 1645 1646 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1642 def _reduce_58(val, _values, result) result = inline val[0] result end |
#_reduce_59(val, _values, result) ⇒ Object
1648 1649 1650 1651 1652 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1648 def _reduce_59(val, _values, result) result = inline val[0] result end |
#_reduce_60(val, _values, result) ⇒ Object
1654 1655 1656 1657 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1654 def _reduce_60(val, _values, result) result << val[1] result end |
#_reduce_62(val, _values, result) ⇒ Object
reduce 61 omitted
1661 1662 1663 1664 1665 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1661 def _reduce_62(val, _values, result) result << val[1] result end |
#_reduce_64(val, _values, result) ⇒ Object
reduce 63 omitted
1669 1670 1671 1672 1673 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1669 def _reduce_64(val, _values, result) result << val[1] result end |
#_reduce_78(val, _values, result) ⇒ Object
reduce 77 omitted
1701 1702 1703 1704 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1701 def _reduce_78(val, _values, result) result << val[1] result end |
#_reduce_none(val, _values, result) ⇒ Object
reduce 137 omitted
1852 1853 1854 |
# File 'lib/rdoc/rd/inline_parser.rb', line 1852 def _reduce_none(val, _values, result) val[0] end |
#inline(rdoc, reference = rdoc) ⇒ Object
Creates a new RDoc::RD::Inline for the rdoc
markup and the raw reference
887 888 889 |
# File 'lib/rdoc/rd/inline_parser.rb', line 887 def inline rdoc, reference = rdoc RDoc::RD::Inline.new rdoc, reference end |
#next_token ⇒ Object
Returns the next token from the inline text
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 |
# File 'lib/rdoc/rd/inline_parser.rb', line 756 def next_token return [false, false] if @src.eos? # p @src.rest if @yydebug if ret = @src.scan(EM_OPEN_RE) @pre << ret [:EM_OPEN, ret] elsif ret = @src.scan(EM_CLOSE_RE) @pre << ret [:EM_CLOSE, ret] elsif ret = @src.scan(CODE_OPEN_RE) @pre << ret [:CODE_OPEN, ret] elsif ret = @src.scan(CODE_CLOSE_RE) @pre << ret [:CODE_CLOSE, ret] elsif ret = @src.scan(VAR_OPEN_RE) @pre << ret [:VAR_OPEN, ret] elsif ret = @src.scan(VAR_CLOSE_RE) @pre << ret [:VAR_CLOSE, ret] elsif ret = @src.scan(KBD_OPEN_RE) @pre << ret [:KBD_OPEN, ret] elsif ret = @src.scan(KBD_CLOSE_RE) @pre << ret [:KBD_CLOSE, ret] elsif ret = @src.scan(INDEX_OPEN_RE) @pre << ret [:INDEX_OPEN, ret] elsif ret = @src.scan(INDEX_CLOSE_RE) @pre << ret [:INDEX_CLOSE, ret] elsif ret = @src.scan(REF_OPEN_RE) @pre << ret [:REF_OPEN, ret] elsif ret = @src.scan(REF_CLOSE_RE) @pre << ret [:REF_CLOSE, ret] elsif ret = @src.scan(FOOTNOTE_OPEN_RE) @pre << ret [:FOOTNOTE_OPEN, ret] elsif ret = @src.scan(FOOTNOTE_CLOSE_RE) @pre << ret [:FOOTNOTE_CLOSE, ret] elsif ret = @src.scan(VERB_OPEN_RE) @pre << ret [:VERB_OPEN, ret] elsif ret = @src.scan(VERB_CLOSE_RE) @pre << ret [:VERB_CLOSE, ret] elsif ret = @src.scan(BAR_RE) @pre << ret [:BAR, ret] elsif ret = @src.scan(QUOTE_RE) @pre << ret [:QUOTE, ret] elsif ret = @src.scan(SLASH_RE) @pre << ret [:SLASH, ret] elsif ret = @src.scan(BACK_SLASH_RE) @pre << ret [:BACK_SLASH, ret] elsif ret = @src.scan(URL_RE) @pre << ret [:URL, ret] elsif ret = @src.scan(OTHER_RE) @pre << ret [:OTHER, ret] else ret = @src.rest @pre << ret @src.terminate [:OTHER, ret] end end |
#next_words_on_error ⇒ Object
Returns words following an error
876 877 878 879 880 881 882 |
# File 'lib/rdoc/rd/inline_parser.rb', line 876 def next_words_on_error if n = @src.rest.index("\n") @src.rest[0 .. (n-1)] else @src.rest end end |
#on_error(et, ev, values) ⇒ Object
Raises a ParseError when invalid formatting is found
836 837 838 839 840 841 842 843 844 845 846 847 848 |
# File 'lib/rdoc/rd/inline_parser.rb', line 836 def on_error(et, ev, values) lines_of_rest = @src.rest.lines.to_a.length prev_words = prev_words_on_error(ev) at = 4 + prev_words.length = <<-MSG RD syntax error: line #{@block_parser.line_index - lines_of_rest}: ...#{prev_words} #{(ev||'')} #{next_words_on_error()} ... MSG << " " * at + "^" * (ev ? ev.length : 0) + "\n" raise ParseError, end |
#parse(inline) ⇒ Object
Parses the inline
text from RD format into RDoc format.
745 746 747 748 749 750 751 |
# File 'lib/rdoc/rd/inline_parser.rb', line 745 def parse inline @inline = inline @src = StringScanner.new inline @pre = "".dup @yydebug = true do_parse.to_s end |
#prev_words_on_error(ev) ⇒ Object
Returns words before the error
853 854 855 856 857 858 859 |
# File 'lib/rdoc/rd/inline_parser.rb', line 853 def prev_words_on_error(ev) pre = @pre if ev and /#{Regexp.quote(ev)}$/ =~ pre pre = $` end last_line(pre) end |