+++ /dev/null
-VPATH = ..
-
-SRC_RST = \
- src/examples/examples.rst \
- src/examples/06_braille.utf8.txt.rst \
- src/examples/example_05.rst \
- src/examples/example_02.rst \
- src/examples/home.rst \
- src/examples/example_01.rst \
- src/examples/example_03.rst \
- src/examples/example_07.rst \
- src/examples/example_04.rst \
- src/examples/example_06.rst \
- src/contents.rst \
- src/home.rst \
- src/manual/syntax/syntax.rst \
- src/manual/warnings/undefined_control_flow/default_vs_any.rst \
- src/manual/warnings/undefined_control_flow/real_world.rst \
- src/manual/warnings/undefined_control_flow/how_it_works.rst \
- src/manual/warnings/undefined_control_flow/simple_example.rst \
- src/manual/warnings/undefined_control_flow/wundefined_control_flow.rst \
- src/manual/warnings/swapped_range/wswapped_range.rst \
- src/manual/warnings/condition_order/real_world.rst \
- src/manual/warnings/condition_order/how_it_works.rst \
- src/manual/warnings/condition_order/simple_example.rst \
- src/manual/warnings/condition_order/wcondition_order.rst \
- src/manual/warnings/home.rst \
- src/manual/warnings/useless_escape/real_world.rst \
- src/manual/warnings/useless_escape/how_it_works.rst \
- src/manual/warnings/useless_escape/simple_example.rst \
- src/manual/warnings/useless_escape/wuseless_escape.rst \
- src/manual/warnings/warnings.rst \
- src/manual/warnings/warnings_list.rst \
- src/manual/warnings/empty_character_class/wempty_character_class.rst \
- src/manual/warnings/unreachable_rules/real_world.rst \
- src/manual/warnings/unreachable_rules/infinite_rules.rst \
- src/manual/warnings/unreachable_rules/how_it_works.rst \
- src/manual/warnings/unreachable_rules/simple_example.rst \
- src/manual/warnings/unreachable_rules/wunreachable_rules.rst \
- src/manual/warnings/warnings_general.rst \
- src/manual/warnings/match_empty_string/real_world.rst \
- src/manual/warnings/match_empty_string/wmatch_empty_string.rst \
- src/manual/warnings/match_empty_string/simple_example.rst \
- src/manual/warnings/match_empty_string/false_alarm.rst \
- src/manual/home.rst \
- src/manual/features/generic_api/generic_api.rst \
- src/manual/features/features.rst \
- src/manual/features/conditions/conditions.rst \
- src/manual/features/state/state.rst \
- src/manual/features/skeleton/skeleton.rst \
- src/manual/features/home.rst \
- src/manual/features/dot/dot.rst \
- src/manual/features/encodings/encodings.rst \
- src/manual/features/reuse/reuse.rst \
- src/manual/manual.rst \
- src/manual/options/options.rst \
- src/manual/options/home.rst \
- src/manual/options/options_list.rst \
- src/news/news.rst \
- src/news/changelog/changelog.rst \
- src/news/changelog/0_16.rst \
- src/news/changelog/0_15_list.rst \
- src/news/changelog/0_15.rst \
- src/news/changelog/0_14.rst \
- src/news/changelog/0_13.rst \
- src/news/changelog/0_12.rst \
- src/news/changelog/0_11.rst \
- src/news/changelog/0_10.rst \
- src/news/changelog/0_09.rst \
- src/news/changelog/beginning.rst \
- src/news/release_notes/0_15.rst \
- src/news/release_notes/0_15_1.rst \
- src/news/release_notes/0_15_2.rst \
- src/news/release_notes/0_15_3.rst \
- src/news/release_notes/0_16.rst \
- src/news/home.rst \
- src/about/about.rst \
- src/install/install.rst \
- src/index.rst
-
-SRC_CSS = src/css/default.css
-
-SRC_TPL = src/template.html
-
-SRC_OTH = \
- src/CNAME \
- src/examples/06_braille.utf8.txt \
- src/examples/05_parsing_integers_conditions.re \
- src/examples/06_braille.utf32.txt \
- src/examples/06_braille.re \
- src/examples/07_cxx98.re \
- src/examples/01_recognizing_integers.re \
- src/examples/04_parsing_integers_blocks.re \
- src/examples/06_braille.ucs2.txt \
- src/examples/06_braille.utf16.txt \
- src/examples/03_arbitrary_large_input.re \
- src/examples/02_recognizing_strings.re \
- src/favicon.ico \
- src/feed/feed.png \
- src/feed/atom.xml \
- src/manual/warnings/condition_order/wcondition_order.re \
- src/manual/warnings/match_empty_string/wmatch_empty_string.re \
- src/manual/features/dot/php_json_dot.png \
- src/manual/features/dot/utf8_any.png \
- src/manual/features/dot/php_json_neato.png \
- src/manual/features/dot/utf8_any.re \
- src/manual/features/dot/php_json.re \
- src/manual/features/skeleton/example.c \
- src/manual/features/skeleton/example.c.line4.input \
- src/manual/features/skeleton/example.c.line4.keys \
- src/manual/features/skeleton/example.png \
- src/manual/features/skeleton/example_next.png \
- src/manual/features/skeleton/gen.sh \
- src/manual/features/skeleton/hex2.re \
- src/manual/features/skeleton/plot.png \
- src/about/1994_bumbulis_cowan_re2c_a_more_versatile_scanner_generator.pdf
-
-OBJ_RST = $(SRC_RST:%.rst=%.html)
-
-all: $(OBJ_RST)
- @ for f in $(SRC_OTH) $(SRC_CSS); do { mkdir -p "`dirname $$f`"; cp "$(VPATH)/$$f" "$$f"; } done
-
--include $(SRC_RST:%.rst=%.d)
-
-# Option '--stylesheet' to 'rst2html' is used only to override dependency
-# from default stylesheet; the real stylesheet is linked in template file.
-# We have to manually insert dependency from template file.
-.rst.html:
- @ mkdir -p "`dirname $@`"
- @ rst2html.py --stylesheet="$(VPATH)/$(SRC_CSS)" --template="$(VPATH)/$(SRC_TPL)" --record-dependencies="$*.dd" $< $@
- @ echo $@: "$(VPATH)/$(SRC_TPL)" `cat $*.dd` > $*.d && rm $*.dd
- @ echo $@
-
-clean:
- rm $(OBJ_RST)
-
-.SUFFIXES: .rst .html
-
-.POSIX:
-
$ Snap.setAccessLog Snap.ConfigNoLog
$ Snap.setErrorLog Snap.ConfigNoLog
$ Snap.emptyConfig
- in Snap.httpServe config $ Snap.serveDirectory "obj/src"
+ in Snap.httpServe config $ Snap.serveDirectory "obj"
#!/bin/sh
-objdir="obj" \
- && cd "$objdir" \
- && make -f ../Makefile -j5 \
- && cd ..
+sphinx-build -b html src obj
runhaskell launch.hs
<feed xmlns="http://www.w3.org/2005/Atom">
<title>re2c</title>
- <link rel="self" href="http://re2c.org/feed/atom.xml"/>
+ <link rel="self" href="http://re2c.org/_static/feed/atom.xml"/>
<id>http://re2c.org/</id>
<updated>2016-01-21T00:00:00Z</updated>
--- /dev/null
+{% extends "basic/layout.html" %}
+
+{% block linktags %}
+ <link rel="alternate" type="application/atom+xml" href="{{ pathto('_static/feed/atom.xml', 1) }}" title="Atom 1.0" />
+ {{ linktags }}
+{% endblock %}
+
+{# remove navigation header and footer #}
+{% block relbar1 %}{% endblock %}
+{% block relbar2 %}{% endblock %}
+
+{# put the sidebar before the body #}
+{% block sidebar1 %}{{ sidebar() }}{% endblock %}
+{% block sidebar2 %}{% endblock %}
--- /dev/null
+<div class="re2c-logo">
+ re2c-{{ version }}
+</div>
+
+<h3><a href="{{ pathto(master_doc) }}">Sitemap</a></h3>
+{{ toctree(includehidden=True, maxdepth=1) }}
+
+<h3>Community</h3>
+<div class="re2c-toc-local">
+ {{ toc }}
+</div>
+
--- /dev/null
+<div class="re2c-logo">
+ re2c-{{ version }}
+</div>
+
+<h3><a href="{{ pathto(master_doc) }}">Home</a></h3>
+{{ toctree(includehidden=True, maxdepth=-1) }}
+
+{%- if display_toc %}
+ <h3>{{ title }}</h3>
+ <div class="re2c-toc-local">
+ {{ toc }}
+ </div>
+{%- endif %}
+
About
=====
-.. include:: ../home.rst
-.. include:: ../contents.rst
+.. toctree::
+ :hidden:
Authors
-------
Version
-------
-This page describes ``re2c`` version 0.16 packaged on 21 January 2016.
+This page describes re2c version |version|.
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# re2c documentation build configuration file, created by
+# sphinx-quickstart on Sun Feb 28 16:21:14 2016.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+import shlex
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.pngmath',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+# source_suffix = ['.rst', '.md']
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u're2c'
+copyright = u'2016, re2c devs'
+author = u're2c devs'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.16'
+# The full version, including alpha/beta/rc tags.
+release = '0.16'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = [
+ 'examples/06_braille.utf8.txt.rst',
+ 'manual/features/skeleton/example.rst',
+ 'manual/features/skeleton/failures.rst',
+ 'manual/features/skeleton/generating_data.rst',
+ 'manual/features/skeleton/use.rst',
+ 'manual/options/options_list.rst',
+ 'manual/warnings/condition_order/how_it_works.rst',
+ 'manual/warnings/condition_order/real_world.rst',
+ 'manual/warnings/condition_order/simple_example.rst',
+ 'manual/warnings/match_empty_string/false_alarm.rst',
+ 'manual/warnings/match_empty_string/real_world.rst',
+ 'manual/warnings/match_empty_string/simple_example.rst',
+ 'manual/warnings/undefined_control_flow/default_vs_any.rst',
+ 'manual/warnings/undefined_control_flow/how_it_works.rst',
+ 'manual/warnings/undefined_control_flow/real_world.rst',
+ 'manual/warnings/undefined_control_flow/simple_example.rst',
+ 'manual/warnings/unreachable_rules/how_it_works.rst',
+ 'manual/warnings/unreachable_rules/infinite_rules.rst',
+ 'manual/warnings/unreachable_rules/real_world.rst',
+ 'manual/warnings/unreachable_rules/simple_example.rst',
+ 'manual/warnings/useless_escape/how_it_works.rst',
+ 'manual/warnings/useless_escape/real_world.rst',
+ 'manual/warnings/useless_escape/simple_example.rst',
+ 'manual/warnings/warnings_general.rst',
+ 'manual/warnings/warnings_list.rst',
+ 'news/changelog/0_09.rst',
+ 'news/changelog/0_10.rst',
+ 'news/changelog/0_11.rst',
+ 'news/changelog/0_12.rst',
+ 'news/changelog/0_13.rst',
+ 'news/changelog/0_14.rst',
+ 'news/changelog/0_15.rst',
+ 'news/changelog/0_15_list.rst',
+ 'news/changelog/0_16.rst',
+ 'news/changelog/beginning.rst'
+]
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+#pygments_style = 'default'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+# If true, `todo` and `todoList` produce output, else they produce nothing.
+todo_include_todos = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'theme-re2c'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+html_theme_path = ["."]
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+html_favicon = '_static/favicon.ico'
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+html_extra_path = ['CNAME']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+html_sidebars = {
+ 'index': ['sidebar-home.html'],
+ '*/**': ['sidebar.html']
+}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+html_show_sourcelink = False
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+html_show_sphinx = False
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+html_show_copyright = False
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Language to be used for generating the HTML full-text search index.
+# Sphinx supports the following languages:
+# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
+# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
+#html_search_language = 'en'
+
+# A dictionary with options for the search language support, empty by default.
+# Now only 'ja' uses this config value
+#html_search_options = {'type': 'default'}
+
+# The name of a javascript file (relative to the configuration directory) that
+# implements a search results scorer. If empty, the default will be used.
+#html_search_scorer = 'scorer.js'
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 're2cdoc'
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+
+# Latex figure (float) alignment
+#'figure_align': 'htbp',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
+latex_documents = [
+ (master_doc, 're2c.tex', u're2c Documentation',
+ u're2c devs', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ (master_doc, 're2c', u're2c Documentation',
+ [author], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ (master_doc, 're2c', u're2c Documentation',
+ author, 're2c', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
+++ /dev/null
-.. contents:: ★
- :backlinks: none
- :depth: 2
+++ /dev/null
-body {
- text-align: justify;
- margin-top: 1%;
- margin-right: auto;
- margin-bottom: 1%;
- margin-left: auto;
- width: 85%;
- font-family: sans-serif;
-}
-
-h1, h2, h3, h4, h5, h6 {
- color: #557799;
- font-weight: normal;
-}
-h1 {
- border-bottom: groove gray;
- padding-top: 1em;
-}
-h1.title {
- font-size: 2.5em;
- text-align: center;
- border: none;
-}
-
-a {
- color: #557799;
-}
-a:focus {
- outline: none;
-}
-
-table, tr, td, th {
- border: none;
- padding: 0em 0.2em 0em 0.2em;
-}
-
-pre.code {
- color: black;
- padding: 1em 1em 1em 1em;
- margin: 0 0 0 0;
-
- border: 1px solid #557799;
- border-left: 8px solid #557799;
-
- background-color: #f3f3f3;
- display: block;
- white-space: pre;
- overflow: auto;
-}
-
-pre.code .ln { color: grey; } /* line numbers */
-pre.code .comment, code .comment { color: #004488; }
-pre.code .keyword, code .keyword { color: #003399; font-weight: bold; }
-pre.code .keyword.type, code .keyword.type { color: #aa3300; }
-pre.code .operator, code .operator { color: #000066; }
-pre.code .punctuation, code .punctuation { color: #000066; font-weight: bold; }
-pre.code .literal.string, code .literal.string { color: #ff5500; }
-pre.code .literal.number, code .literal.number { color: #ff5500; font-weight: bold; }
-pre.code .name.builtin, code .name.builtin { color: #352B84 }
-pre.code .deleted, code .deleted { background-color: #DEB0A1}
-pre.code .inserted, code .inserted { background-color: #A3D289}
-
-img {
- display: block;
- border: 1px dotted #557799;
- margin: auto;
-}
-
-img.feed {
- display: inline;
- border: none;
- vertical-align: middle;
-}
+++ /dev/null
-⠠⠁⠇⠇⠀⠓⠥⠍⠁⠝⠀⠃⠑⠊⠝⠛⠎⠀⠁⠗⠑⠀⠃⠕⠗⠝⠀⠋⠗⠑⠑⠀⠁⠝⠙⠀⠑⠟⠥⠁⠇⠀⠊⠝⠀⠙⠊⠛⠝⠊⠞⠽⠀⠁⠝⠙⠀⠗⠊⠛⠓⠞⠎⠲⠀
-⠠⠞⠓⠑⠽⠀⠁⠗⠑⠀⠑⠝⠙⠕⠺⠑⠙⠀⠺⠊⠞⠓⠀⠗⠑⠁⠎⠕⠝⠀⠁⠝⠙⠀⠉⠕⠝⠎⠉⠊⠑⠝⠉⠑⠀⠁⠝⠙⠀⠎⠓⠕⠥⠇⠙⠀⠁⠉⠞⠀⠞⠕⠺⠁⠗⠙⠎⠀
-⠕⠝⠑⠀⠁⠝⠕⠞⠓⠑⠗⠀⠊⠝⠀⠁⠀⠎⠏⠊⠗⠊⠞⠀⠕⠋⠀⠃⠗⠕⠞⠓⠑⠗⠓⠕⠕⠙⠲
-
Recognizing integers: the sentinel method
-----------------------------------------
-.. include:: home.rst
-
This example is very simple, yet practical.
We assume that the input is small (fits in one continuous piece of memory).
We also assume that some characters never occur in well-formed input (but may occur in ill-formed input).
binary, octal, decimal and hexadecimal integer literals.
The numbers are not *parsed* (their numeric value is not retrieved), they are merely *recognized*.
-`[01_recognizing_integers.re] <01_recognizing_integers.re>`_
+:download:`[01_recognizing_integers.re] <01_recognizing_integers.re.txt>`
-.. include:: 01_recognizing_integers.re
- :code: cpp
- :number-lines:
+.. literalinclude:: 01_recognizing_integers.re.txt
+ :language: cpp
+ :linenos:
A couple of things should be noted:
Recognizing strings: the need for YYMAXFILL
-------------------------------------------
-.. include:: home.rst
-
This example is about recognizing strings.
Strings (in generic sense) are different from other kinds of lexemes: they can contain *arbitrary* characters.
It makes them a way more difficult to lex: unlike `Recognizing integers: the sentinel method <example_01.html>`_ example,
The length of padding depends on the maximal argument to ``YYFILL``
(this value is called ``YYMAXFILL`` and can be generated using ``/*!max:re2c*/`` directive).
-`[02_recognizing_strings.re] <02_recognizing_strings.re>`_
+:download:`[02_recognizing_strings.re] <02_recognizing_strings.re.txt>`
-.. include:: 02_recognizing_strings.re
- :code: cpp
- :number-lines:
+.. literalinclude:: 02_recognizing_strings.re.txt
+ :language: cpp
+ :linenos:
Notes:
Arbitrary large input and YYFILL
--------------------------------
-.. include:: home.rst
-
In this example we suppose that input cannot be mapped in memory at once:
either it's too large or its size cannot be determined in advance.
The usual thing to do in such case is to allocate a buffer and lex input in chunks that fit into buffer.
Our example program reads ``stdin`` in chunks of 16 bytes (in real word buffer size is usually ~4Kb)
and tries to lex numbers separated by newlines.
-`[03_arbitrary_large_input.re] <03_arbitrary_large_input.re>`_
+:download:`[03_arbitrary_large_input.re] <03_arbitrary_large_input.re.txt>`
-.. include:: 03_arbitrary_large_input.re
- :code: cpp
- :number-lines:
+.. literalinclude:: 03_arbitrary_large_input.re.txt
+ :language: cpp
+ :linenos:
Notes:
Parsing integers (multiple re2c blocks)
---------------------------------------
-.. include:: home.rst
-
This example is based on `Recognizing integers: the sentinel method <example_01.html>`_ example,
only now integer literals are parsed rather than simply recognized.
Parsing integers is simple: one can easily do it by hand.
However, re2c-generated code *does* look like a simple handwritten parser:
a couple of dereferences and conditional jumps. No overhead. ``:)``
-`[04_parsing_integers_blocks.re] <04_parsing_integers_blocks.re>`_
+:download:`[04_parsing_integers_blocks.re] <04_parsing_integers_blocks.re.txt>`
-.. include:: 04_parsing_integers_blocks.re
- :code: cpp
- :number-lines:
+.. literalinclude:: 04_parsing_integers_blocks.re.txt
+ :language: cpp
+ :linenos:
Notes:
Parsing integers (conditions)
-----------------------------
-.. include:: home.rst
-
This example does exactly the same as `Parsing integers (multiple re2c blocks) <example_04.html>`_ example,
but in a slightly different manner: it uses re2c conditions instead of blocks.
Conditions allow to encode multiple interconnected lexers within a single re2c block.
-`[05_parsing_integers_conditions.re] <05_parsing_integers_conditions.re>`_
+:download:`[05_parsing_integers_conditions.re] <05_parsing_integers_conditions.re.txt>`
-.. include:: 05_parsing_integers_conditions.re
- :code: cpp
- :number-lines:
+.. literalinclude:: 05_parsing_integers_conditions.re.txt
+ :language: cpp
+ :linenos:
Notes:
Braille patterns (encodings)
----------------------------
-.. include:: home.rst
-
This example is about encoding support in re2c.
It's a partial decoder from Grade-1 (uncontracted) Unicode English Braille to plain English.
The input may be encoded in UTF-8, UTF-16, UTF-32 or UCS-2:
.. include:: 06_braille.utf8.txt
-It appears to be UTF-8 encoded `[06_braille.utf8.txt] <06_braille.utf8.txt.html>`_.
+It appears to be UTF-8 encoded :download:`[06_braille.utf8.txt] <06_braille.utf8.txt>`.
Convert it into UTF-16, UTF-32 or UCS-2:
.. code-block:: bash
Grade-2 Braille allows contractions; they obey complex rules (like those of a natural language)
and are much harder to implement.
-`[06_braille.re] <06_braille.re>`_
+:download:`[06_braille.re] <06_braille.re.txt>`
-.. include:: 06_braille.re
- :code: cpp
- :number-lines:
+.. literalinclude:: 06_braille.re.txt
+ :language: cpp
+ :linenos:
Notes:
C++98 lexer
-----------
-.. include:: home.rst
-
This is an example of a big real-world re2c program: C++98 lexer.
It confirms to the C++98 standard (except for a couple of hacks to simulate preprocessor).
All nontrivial lexemes (integers, floating-point constants, strings and character literals)
Some additional checks described in standard (e.g. overflows in integer literals) are also done.
In fact, C++ is an easy language to lex: unlike many other languages, lexer can proceed without feedback from parser.
-`[07_cxx98.re] <07_cxx98.re>`_
+:download:`[07_cxx98.re] <07_cxx98.re.txt>`
-.. include:: 07_cxx98.re
- :code: cpp
- :number-lines:
+.. literalinclude:: 07_cxx98.re.txt
+ :language: cpp
+ :linenos:
Notes:
Examples
========
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
-★
-
-* `Recognizing integers: the sentinel method <example_01.html>`_
-* `Recognizing strings: the need for YYMAXFILL <example_02.html>`_
-* `Arbitrary large input and YYFILL <example_03.html>`_
-* `Parsing integers (multiple re2c blocks) <example_04.html>`_
-* `Parsing integers (conditions) <example_05.html>`_
-* `Braille patterns (encodings) <example_06.html>`_
-* `C++98 lexer <example_07.html>`_
+ Recognizing integers: the sentinel method <example_01>
+ Recognizing strings: the need for YYMAXFILL <example_02>
+ Arbitrary large input and YYFILL <example_03>
+ Parsing integers (multiple re2c blocks) <example_04>
+ Parsing integers (conditions) <example_05>
+ Braille patterns (encodings) <example_06>
+ C++98 lexer <example_07>
All examples are written in C++-98.
`Do let me know <skvadik@gmail.com>`_ if you notice any obvious lies and errors.
+++ /dev/null
-.. |[examples_home]| replace:: [home]
-.. _[examples_home]: ../index.html
-.. header:: |[examples_home]|_ `[Examples] <examples.html>`_
-.. footer:: |[examples_home]|_ `[Examples] <examples.html>`_
+++ /dev/null
-.. header:: `[home] <../index.html>`_
-.. footer:: `[home] <../index.html>`_
re2c
====
-re2c is a lexer generator for C/C++.
-The generated code is fast (direct-coded DFA, as good as handwritten)
-and flexible (easy to embed into existing environment).
+.. toctree::
+ :hidden:
---------------------------------------------------------------------------------
+ About <about/about>
+ Install <install/install>
+ Manual <manual/manual>
+ Examples <examples/examples>
+ News <news/news>
-★ `About <about/about.html>`_
-★ `Install <install/install.html>`_
+re2c is a lexer generator for C/C++.
+It has two key features:
-★ `Manual <manual/manual.html>`_
+* Very fast lexers. The generated code is like a carefully tuned hand-crafted C/C++ lexer.
+ It's because re2c generates minimalistic hard-coded DFA
+ (as opposed to full-featured table based lexers).
-★ `Examples <examples/examples.html>`_
+* Very flexible lexers. The generated code can be wired into virtually any environment.
+ Instead of exposing a traditional API, re2c gives you access to its internals,
+ so that you can mess with the guts of your lexer as much as you need.
+ Of course, this can lead to all sorts of bad things.
+ With great flexibility comes great responsibility. ;)
+ Be sure to take a look at `examples <examples/examples.html>`_,
+ they cover a lot of real-world cases and
+ shed some light on dark corners of re2c API.
-★ `News <news/news.html>`_ |feed|
-.. |feed| image:: feed/feed.png
- :target: feed/atom.xml
- :class: feed
- :width: 25px
---------------------------------------------------------------------------------
+Bugs & feedback
+---------------
Please send feedback to `re2c-devel <re2c-devel@lists.sourceforge.net>`_ and
`re2c-general <re2c-general@lists.sourceforge.net>`_ mailing lists
+(search `mail archieves <https://sourceforge.net/p/re2c/mailman/>`_ for old threads)
or `report a bug <https://github.com/skvadrik/re2c/issues>`_.
-Consider adding your lexer to re2c test suite: real-world tests are the best.
-Feel free to strip out all non-re2c code if you must keep it secret.
-In return re2c will not break your code. ``:)``
-Contributors welcome!
+
+Note that re2c is hosted both on `github <https://github.com/skvadrik/re2c>`_
+and on `sourceforge <https://sourceforge.net/p/re2c>`_ for redundancy.
+Currently github serves as main repository, bugtracker and binary hosting.
+Sourceforge is used as backup repository and to host mail
+(so please don't send bugs or feedback to sourceforge).
+
+
+News & updates
+--------------
+
+.. |feed| image:: _static/feed/feed.png
+ :target: _static/feed/atom.xml
+ :class: feed
+ :width: 2em
+
+Subscribe to receive latest news and updates: |feed|
+
+
+
+Projects that use re2c
+----------------------
+
+* `PHP <http://php.net/>`_ (general-purpose scripting language)
+* `ninja <https://ninja-build.org/>`_ (a small build system with a focus on speed)
+* `yasm <http://yasm.tortall.net/>`_ (assembler)
+* `spamasassin <https://spamassassin.apache.org/>`_ (anti-spam platform)
+* `BLR-CAD <http://brlcad.org/>`_ (cross-platform solid modeling system)
+* ... last but not least, `re2c <http://re2c.org>`_
+
+This list is by no means complete;
+these are only the most well-known and open source projects.
+
+
+
+Contribute
+----------
+
+Contributions come in various forms:
+
+* Tests: a very easy and valuable contribution is to add your lexer to re2c test suite.
+ Real-world tests are the best.
+ Feel free to strip out all non-re2c code if you must keep it secret.
+ In return re2c will not break your code (re2c developers strive to never break existing tests).
+
+* Ideas: new features and new ways to use re2c.
+
+* Development: bugfixes, features, ports to other languages.
+
+Everyone is welcome!
Install
=======
-.. include:: ../home.rst
-.. include:: ../contents.rst
+.. toctree::
+ :hidden:
Download
========
* `re2c-0.13.6.tar.gz <https://github.com/skvadrik/re2c/releases/download/0.13.6/re2c-0.13.6.tar.gz>`_
* `re2c-0.13.5.tar.gz <http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download>`_
+You can find other releases `here <https://sourceforge.net/projects/re2c/files/old/>`_
+(but be aware that they are hidden for a good reason:
+most of them contain bugs that have been fixed in the next minor release).
+
Sources
-------
Conditions
----------
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
You can preceed regular expressions with a list of condition names when
using the ``-c`` switch. In this case ``re2c`` generates scanner blocks for
.dot
----
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
With ``-D, --emit-dot`` option re2c does not generate C/C++ code.
Instead, it dumps the generated DFA in `DOT format <https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29>`_.
One can convert this dump to an image of DFA using `graphviz <http://www.graphviz.org/>`_ or another library.
-Say we want a picture of DFA that accepts any UTF-8 code point:
+Say we want a picture of DFA that accepts any UTF-8 code point, ``utf8_any.re``:
-.. include:: utf8_any.re
- :code: cpp
- :number-lines:
+.. literalinclude:: utf8_any.re.txt
+ :language: cpp
Generate and render :
-.. code-block::
+.. code-block:: none
$ re2c -D8 -o utf8_any.dot utf8_any.re
$ dot -Tpng -o utf8_any.png utf8_any.dot
During the transformations it splits certain states and adds lambda transitions.
Lambda transitions correspond to the unlabeled edges on the picture.
-A real-world example (JSON lexer, all non-re2c code stripped out):
+A real-world example (JSON lexer, all non-re2c code stripped out), ``php_json.re``:
-.. include:: php_json.re
- :code: cpp
- :number-lines:
+.. literalinclude:: php_json.re.txt
+ :language: cpp
Generate .dot file:
-.. code-block::
+.. code-block:: none
$ re2c -Dc -o php_json.dot php_json.re
Render with ```dot -Gratio=0.3 -Tpng -o php_json_dot.png php_json.dot```:
.. image:: php_json_dot.png
- :width: 80%
+ :width: 100%
Render with ```neato -Elen=4 -Tpng -o php_json_neato.png php_json.dot```:
.. image:: php_json_neato.png
- :width: 50%
+ :width: 70%
The generated graph is sometimes very large and requires careful tuning of rendering paratemeters.
Encodings
---------
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
``re2c`` supports the following encodings: ASCII (default), EBCDIC (``-e``),
UCS-2 (``-w``), UTF-16 (``-x``), UTF-32 (``-u``) and UTF-8 (``-8``).
Features
========
-.. include:: ../home.rst
-
-★
-
-* `Conditions <conditions/conditions.html>`_
-* `State <state/state.html>`_
-* `Reuse <reuse/reuse.html>`_
-* `Encodings <encodings/encodings.html>`_
-* `Generic API <generic_api/generic_api.html>`_
-* `Skeleton <skeleton/skeleton.html>`_
-* `.dot <dot/dot.html>`_
+.. toctree::
+ :hidden:
+
+ Conditions <conditions/conditions>
+ State <state/state>
+ Reuse <reuse/reuse>
+ Encodings <encodings/encodings>
+ Generic API <generic_api/generic_api>
+ Skeleton <skeleton/skeleton>
+ .dot <dot/dot>
Generic API
-----------
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
``re2c`` usually operates on input using pointer-like primitives
``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER`` and ``YYLIMIT``.
+++ /dev/null
-.. |[manual_features_home]| replace:: [home]
-.. _[manual_features_home]: ../../../index.html
-.. header:: |[manual_features_home]|_ `[Manual] <../../manual.html>`_ `[Features] <../features.html>`_
-.. footer:: |[manual_features_home]|_ `[Manual] <../../manual.html>`_ `[Features] <../features.html>`_
Reuse
-----
-.. include:: ../home.rst
-
Reuse mode is controlled by ``-r --reusable`` option.
Allows reuse of scanner definitions with ``/*!use:re2c */`` after ``/*!rules:re2c */``.
In this mode no ``/*!re2c */`` block and exactly one ``/*!rules:re2c */`` must be present.
Example
~~~~~~~
-`[hex2.re] <hex2.re>`_
+:download:`[hex2.re] <hex2.re.txt>`
-.. include:: hex2.re
- :code: c
- :number-lines:
+.. literalinclude:: hex2.re.txt
+ :language: c
Here is a very simple program (it tries to match two-digit hexadecimal numbers).
We can see the generated DFA using ```re2c -D hex2.re | dot -Gratio=0.5 -Tpng -o example.png```:
.. image:: example.png
- :width: 40%
+ :width: 50%
Given this program, ```re2c -S -o example.c hex2.re``` generates three files:
``example.c`` (main program), ``example.c.line4.input`` (input data) and ``example.c.line4.keys`` (expected match results).
First, let's look at the generated strings:
-`[example.c.line4.input] <example.c.line4.input>`_
+:download:`[example.c.line4.input] <example.c.line4.input>`
.. code-block:: bash
All strings are glued together, so it's hard to tell where is the end of one string and the beginning of another.
For that re2c generates keys:
-`[example.c.line4.keys] <example.c.line4.keys>`_
+:download:`[example.c.line4.keys] <example.c.line4.keys>`
.. code-block:: bash
And finally, the program itself:
-`[example.c] <example.c>`_
+:download:`[example.c] <example.c.txt>`
-.. include:: example.c
- :code: c
- :number-lines:
+.. literalinclude:: example.c.txt
+ :language: c
+ :linenos:
re2c generated two auxilary functions: ``read_file`` and ``action_line4``.
``read_file`` is used to map ``.input`` and ``.keys`` files into memory (this function is shared between all lexers).
Suppose, for example, that we forgot to handle default case in the example above:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
[0-9a-fA-F]{2} {}
We can study the algorithm simply alternating repetition counter in the example above:
.. code-block:: cpp
- :number-lines:
/*!re2c
* {}
Compare the following pictures of DFA with one, two and three repetitions:
.. image:: example_next.png
- :width: 70%
+ :width: 80%
We will use a simple script that dumps re2c source file,
generates skeleton program and measures the size of ``.input`` and ``.keys`` files:
-`[gen.sh] <gen.sh>`_
+:download:`[gen.sh] <gen.sh.txt>`
-.. include:: gen.sh
- :code: bash
- :number-lines:
+.. literalinclude:: gen.sh.txt
+ :language: bash
+ :linenos:
Script runs in a loop and expects two arguments:
lower and upped bounds of the iteration counter.
-.. code-block::
+.. code-block:: none
$ ./gen.sh 1 16
iters edges input keys
Skeleton
--------
-.. include:: ../home.rst
-.. include:: ../../../contents.rst
-
+.. toctree::
+ :hidden:
With ``-S, --skeleton`` option re2c ignores all non-re2c code and generates a self-contained C program
that can be further compiled and executed.
State
-----
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
When the ``-f`` flag is specified, ``re2c`` generates a scanner that can
store its current state, return to the caller, and later resume
+++ /dev/null
-.. |[manual_home]| replace:: [home]
-.. _[manual_home]: ../../index.html
-.. header:: |[manual_home]|_ `[Manual] <../manual.html>`_
-.. footer:: |[manual_home]|_ `[Manual] <../manual.html>`_
Manual
======
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
-★
-
-* `Options <options/options.html>`_
-* `Warnings <warnings/warnings.html>`_
-* `Syntax <syntax/syntax.html>`_
-* `Features <features/features.html>`_
+ Options <options/options>
+ Warnings <warnings/warnings>
+ Syntax <syntax/syntax>
+ Features <features/features>
+++ /dev/null
-.. |[manual_warnings_home]| replace:: [home]
-.. _[manual_warnings_home]: ../../index.html
-.. header:: |[manual_warnings_home]|_ `[Manual] <../manual.html>`_ `[Options] <options.html>`_
-.. footer:: |[manual_warnings_home]|_ `[Manual] <../manual.html>`_ `[Options] <options.html>`_
Options
=======
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
.. include:: options_list.rst
Syntax
======
-.. include:: ../home.rst
-.. include:: ../../contents.rst
-
-
+.. toctree::
+ :hidden:
Code for ``re2c`` consists of a set of `rules`_, `definitions`_ and
`configurations`_.
Here is the carcass of this program:
.. code-block:: cpp
- :number-lines:
+ :linenos:
#define NORMAL 0
#define PRE_RAW 1
Nothing special, except that instead of generating condition names with ``/*!types:re2c*/`` directive
or ``-t, --type-header`` option we hardcoded them manually:
-`[wcondition_order.re] <wcondition_order.re>`_
+:download:`[wcondition_order.re] <wcondition_order.re.txt>`
-.. include:: wcondition_order.re
- :code: cpp
- :number-lines:
+.. literalinclude:: wcondition_order.re.txt
+ :language: cpp
+ :linenos:
Condition order is controlled by ``REVERSED_CONDITION_ORDER`` define.
Let's compile and run it:
-.. code-block::
+.. code-block:: none
$ re2c -c -o example.c -Wcondition-order wcondition_order.re
$
Everything works fine: we get ``aaaa,bbb!`` in both cases.
However, if we use ``-s`` re2c option, lexer becomes sensitive to condition order:
-.. code-block::
+.. code-block:: none
$ re2c -cs -o example.c -Wcondition-order wcondition_order.re
re2c: warning: line 31: looks like you use hardcoded numbers instead of autogenerated condition names: better add
[-Wcondition-order]
-------------------
-.. include:: ../home.rst
-.. include:: ../../../contents.rst
+.. toctree::
+ :hidden:
.. include:: simple_example.rst
.. include:: how_it_works.rst
[-Wempty-character-class]
--------------------------
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
This warning is complementary to ``--empty-class`` option.
The option expects a single argument, one of the following:
Note that empty character class can be constructed in many ways:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
[] { return 0; }
Given this code, ```re2c -i -Wempty-character-class``` generates:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/* Generated by re2c 0.14.1.dev on Wed Nov 11 11:42:00 2015*/
And warns:
-.. code-block::
+.. code-block:: none
re2c: warning: line 2: empty character class [-Wempty-character-class]
re2c: warning: line 3: empty character class [-Wempty-character-class]
+++ /dev/null
-.. |[manual_warnings_home]| replace:: [home]
-.. _[manual_warnings_home]: ../../../index.html
-.. header:: |[manual_warnings_home]|_ `[Manual] <../../manual.html>`_ `[Warnings] <../warnings.html>`_
-.. footer:: |[manual_warnings_home]|_ `[Manual] <../../manual.html>`_ `[Warnings] <../warnings.html>`_
Here is the skeleton of REXX lexer (the very lexer which motivated Peter to write re2c ``:)``).
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
all = [\000-\377];
```re2c -Wmatch-empty-string``` warns:
-.. code-block::
+.. code-block:: none
re2c: warning: line 133: rule matches empty string [-Wmatch-empty-string]
Skipping uninteresting stuff
............................
-Like spaces.
-One often needs to skip variable number of them:
+One often needs to skip variable number of, say, spaces:
.. code-block:: cpp
- :number-lines:
/*!re2c
TABS_AND_SPACES = [ \t]*;
This definition is ok when used inside of another (non-nullable) rule:
.. code-block:: cpp
- :number-lines:
/*!re2c
TABS_AND_SPACES = [ \t]*;
``[-Wmatch-empty-string]`` warns when a rule is nullable (matches empty string).
It was intended to prevent hitting eternal loop in cases like this:
-`[wmatch_empty_string.re] <wmatch_empty_string.re>`_
+:download:`[wmatch_empty_string.re] <wmatch_empty_string.re.txt>`
-.. include:: wmatch_empty_string.re
- :code: cpp
- :number-lines:
+.. literalinclude:: wmatch_empty_string.re.txt
+ :language: cpp
+ :linenos:
The program loops over its arguments (the outer ``for`` loop)
and tries to lex each argument (the inner ``for`` loop).
Arguments must consist of lowercase letters only.
Generate, compile and run:
-.. code-block::
+.. code-block:: none
$ re2c -o example.c -Wmatch-empty-string wmatch_empty_string.re
re2c: warning: line 11: rule matches empty string [-Wmatch-empty-string]
[-Wmatch-empty-string]
--------------------------
-.. include:: ../home.rst
-.. include:: ../../../contents.rst
+.. toctree::
+ :hidden:
.. include:: simple_example.rst
.. include:: false_alarm.rst
[-Wswapped-range]
--------------------------
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
This warning is very simple.
It warns you in cases when character class contains a range which lower bound is greater than upper bound.
it simply swaps range bounds and goes on.
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
* { return "*"; }
Given this code, ```re2c -i -Wswapped-range``` generates the following:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/* Generated by re2c 0.14.1.dev on Tue Nov 10 22:07:31 2015*/
And reports a warning:
-.. code-block::
+.. code-block:: none
re2c: warning: line 3: range lower bound (0x61) is greater than upper bound (0x5A), swapping [-Wswapped-range]
everyone used ``[^]`` as default rule:
.. code-block:: cpp
- :number-lines:
/*!re2c
// ... normal rules ...
The example above compiles without warnings with any fixed-width encoding (ASCII by default).
However, with UTF-8 encoding ```re2c -i8 -Wundefined-control-flow``` says:
-.. code-block::
+.. code-block:: none
re2c: warning: line 4: control flow is undefined for strings that match
'[\x80-\xC1\xF5-\xFF]'
This is because by default re2c treats Unicode surrogates as normal code points (for backwards compatibility reasons).
If we tell re2c to exclude surrogates, ```re2c -ix --encoding-policy fail -Wundefined-control-flow``` will warn:
-.. code-block::
+.. code-block:: none
re2c: warning: line 4: control flow is undefined for strings that match
'[\xDC00-\xDFFF]'
Say, we want to match ``'a'``:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
"a" { return 'a'; }
```re2c -i -Wundefined-control-flow```:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/* Generated by re2c 0.14.1.dev on Thu Nov 5 14:35:46 2015*/
Clearly this is not what we want: this code matches any letter, not only ``'a'``.
re2c grumbles something about undefined control flow and says that default ``*`` rule won't hurt:
-.. code-block::
+.. code-block:: none
re2c: warning: line 3: control flow is undefined for strings that match '[\x0-\x60\x62-\xFF]', use default rule '*' [-Wundefined-control-flow]
Let's add it:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
* { return '*'; }
Now that's better:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/* Generated by re2c 0.14.1.dev on Thu Nov 5 14:35:08 2015*/
[-Wundefined-control-flow]
--------------------------
-.. include:: ../home.rst
-.. include:: ../../../contents.rst
+.. toctree::
+ :hidden:
.. include:: simple_example.rst
.. include:: default_vs_any.rst
A rule may be unreachable all by itself, without being shadowed by other rules:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
[^]* { return "greeedy"; }
It will continue eating input until ``YYFILL`` finally fails (```re2c -i -Wunreachable-rules```):
.. code-block:: cpp
- :number-lines:
+ :linenos:
/* Generated by re2c 0.14.1.dev on Fri Nov 6 21:36:56 2015*/
(unless you use ``--input-api custom`` and do some magic to stop it).
And re2c warns us:
-.. code-block::
+.. code-block:: none
re2c: warning: line 2: unreachable rule [-Wunreachable-rules]
Here is an example of a real-world lexer (all the non-re2c code has beed removed):
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
re2c:yyfill:check = 0;
```re2c -cF -Wunreachable-rules``` says:
-.. code-block::
+.. code-block:: none
re2c: warning: line 54: unreachable rule in condition 'ST_DOUBLE_QUOTES' (shadowed by rules at lines 47, 48) [-Wunreachable-rules]
re2c: warning: line 49: unreachable rule in condition 'ST_OFFSET' (shadowed by rule at line 45) [-Wunreachable-rules]
The interesting part is the unreachable rule on line 49 in conditions ``ST_OFFSET`` and ``ST_SECTION_VALUE``.
The rule is ``{WHITESPACE}``:
-.. code-block::
+.. code-block:: none
WHITESPACE [ \t]+
re2c claims that it is shadowed by the rule on line 45, which is ``{SECTION_VALUE_CHARS}+``:
-.. code-block::
+.. code-block:: none
ANY_CHAR (.|[\n\t])
LITERAL_DOLLAR ("$"([^{\000]|("\\"{ANY_CHAR})))
~~~~~~~~~~~~~~~~
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
"" { return ""; }
Given this strange code, ```re2c -i -Wunreachable-rules``` says:
-.. code-block::
+.. code-block:: none
re2c: warning: line 2: unreachable rule (shadowed by rules at lines 4, 6) [-Wunreachable-rules]
re2c: warning: line 5: unreachable rule (shadowed by rule at line 4) [-Wunreachable-rules]
A look at the generated code suggests that re2c was right:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/* Generated by re2c 0.14.1.dev on Fri Nov 6 15:21:36 2015*/
[-Wunreachable-rules]
--------------------------
-.. include:: ../home.rst
-.. include:: ../../../contents.rst
+.. toctree::
+ :hidden:
.. include:: simple_example.rst
.. include:: infinite_rules.rst
~~~~~~~~~~~~~~~~
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
* {}
Given this code, ```re2c -Wuseless-escape``` reports a bunch of warnings:
-.. code-block::
+.. code-block:: none
re2c: warning: line 3: column 11: escape has no effect: '\A' [-Wuseless-escape]
re2c: warning: line 3: column 15: escape has no effect: '\'' [-Wuseless-escape]
The above example should be fixed as follows:
.. code-block:: cpp
- :number-lines:
+ :linenos:
/*!re2c
* {}
[-Wuseless-escape]
--------------------------
-.. include:: ../home.rst
-.. include:: ../../../contents.rst
+.. toctree::
+ :hidden:
.. include:: simple_example.rst
.. include:: how_it_works.rst
Warnings
========
-.. include:: ../home.rst
+.. toctree::
+ :hidden:
-★
-
-* `[-Wundefined-control-flow] <undefined_control_flow/wundefined_control_flow.html>`_
-* `[-Wunreachable-rules] <unreachable_rules/wunreachable_rules.html>`_
-* `[-Wcondition-order] <condition_order/wcondition_order.html>`_
-* `[-Wuseless-escape] <useless_escape/wuseless_escape.html>`_
-* `[-Wswapped-range] <swapped_range/wswapped_range.html>`_
-* `[-Wempty-character-class] <empty_character_class/wempty_character_class.html>`_
-* `[-Wmatch-empty-string] <match_empty_string/wmatch_empty_string.html>`_
+ [-Wundefined-control-flow] <undefined_control_flow/wundefined_control_flow>
+ [-Wunreachable-rules] <unreachable_rules/wunreachable_rules>
+ [-Wcondition-order] <condition_order/wcondition_order>
+ [-Wuseless-escape] <useless_escape/wuseless_escape>
+ [-Wswapped-range] <swapped_range/wswapped_range>
+ [-Wempty-character-class] <empty_character_class/wempty_character_class>
+ [-Wmatch-empty-string] <match_empty_string/wmatch_empty_string>
.. include:: warnings_general.rst
Changelog
=========
-.. include:: ../home.rst
-.. include:: ../../contents.rst
+.. toctree::
+ :hidden:
.. include:: 0_16.rst
.. include:: 0_15.rst
+++ /dev/null
-.. |[news_home]| replace:: [home]
-.. _[news_home]: ../../index.html
-.. header:: |[news_home]|_ `[News] <../news.html>`_
-.. footer:: |[news_home]|_ `[News] <../news.html>`_
News
====
-.. include:: ../home.rst
-
-★
-
-* `Release 0.16 <release_notes/0_16.html>`_
-* `Release 0.15.3 <release_notes/0_15_3.html>`_
-* `Release 0.15.2 <release_notes/0_15_2.html>`_
-* `Release 0.15.1 <release_notes/0_15_1.html>`_
-* `Release 0.15 <release_notes/0_15.html>`_
-* `Changelog <changelog/changelog.html>`_
+.. toctree::
+ :hidden:
+
+ Release 0.16 <release_notes/0_16>
+ Release 0.15.3 <release_notes/0_15_3>
+ Release 0.15.2 <release_notes/0_15_2>
+ Release 0.15.1 <release_notes/0_15_1>
+ Release 0.15 <release_notes/0_15>
+ Changelog <changelog/changelog>
Release 0.15
============
-.. include:: ../home.rst
-
This release started out in spring 2015 as a relatively simple code cleanup.
I focused on the following problem: re2c used to repeat the whole generation process multiple times.
Release 0.15.1
==============
-.. include:: ../home.rst
-
-
This release fixes an error in the testing script:
it used locale-sensitive ``sort`` utility,
which resulted in different order of files on different platforms.
Release 0.15.2
==============
-.. include:: ../home.rst
-
-
This release fixes a bug in build system (`reported <https://bugs.gentoo.org/show_bug.cgi?id=566620>`_ on Gentoo bugtracker).
Fix adds missing dependency (lexer depends on bison-generated header).
It seems that the dependency has always been missing, build order just happened to be correct.
Release 0.15.3
==============
-.. include:: ../home.rst
-
-
This release fixes multiple build-time and run-time failures on OS X, FreeBSD and Windows.
Most of the problems were reported and fixed by Oleksii Taran (on OS X)
and Sergei Trofimovich (on FreeBSD and Windows).
Release 0.16
==============
-.. include:: ../home.rst
-
This release adds a very important step in the process of code generation:
minimization of the underlying DFA (deterministic finite automaton).
Simply speaking, this means that re2c now generates less code
+++ /dev/null
-%(head_prefix)s
-%(head)s
-<link rel="stylesheet" type="text/css" href="/css/default.css" />
-<link rel="alternate" type="application/atom+xml" href="/feed/atom.xml" title="Atom 1.0" />
-<link rel="icon" href="/favicon.ico" />
-%(body_prefix)s
-%(body_pre_docinfo)s
-%(docinfo)s
-%(body)s
-%(body_suffix)s
--- /dev/null
+
+.highlighttable td.code { width: 100%; }
+
+.linenos {
+ color: darkgray;
+ font-size: 14px; /* must be in sync with .highlight */
+}
+
+.highlight {
+ border: 1px solid darkgray;
+ border-left: 4px solid darkgray;
+ padding: 0 1em 0 1em;
+ background-color: aliceblue;
+ display: block;
+ overflow: auto;
+ font-size: 14px; /* must be in sync with .linenos */
+ color: dimgray;
+}
+
+.highlight .c { color: rosybrown; } /* Comment */
+.highlight .cm { color: rosybrown; } /* Comment.Multiline */
+.highlight .c1 { color: rosybrown; } /* Comment.Single */
+.highlight .cp { color: rosybrown; } /* Comment.Preproc */
+
+.highlight .k { color: steelblue; } /* Keyword */
+.highlight .kt { color: midnightblue; } /* Keyword.Type */
+
+.highlight .m { color: slategray; } /* Literal.Number */
+.highlight .mf { color: slategray; } /* Literal.Number.Float */
+.highlight .mh { color: slategray; } /* Literal.Number.Hex */
+.highlight .mi { color: slategray; } /* Literal.Number.Integer */
+.highlight .mo { color: slategray; } /* Literal.Number.Oct */
+.highlight .il { color: slategray; } /* Literal.Number.Integer.Long */
+
+.highlight .s { color: lightsalmon; } /* Literal.String */
+.highlight .sb { color: lightsalmon; } /* Literal.String.Backtick */
+.highlight .sc { color: lightsalmon; } /* Literal.String.Char */
+.highlight .sd { color: lightsalmon; } /* Literal.String.Doc */
+.highlight .s2 { color: lightsalmon; } /* Literal.String.Double */
+.highlight .se { color: lightsalmon; } /* Literal.String.Escape */
+.highlight .sh { color: lightsalmon; } /* Literal.String.Heredoc */
+.highlight .si { color: lightsalmon; } /* Literal.String.Interpol */
+.highlight .sx { color: lightsalmon; } /* Literal.String.Other */
+.highlight .sr { color: lightsalmon; } /* Literal.String.Regex */
+.highlight .s1 { color: lightsalmon; } /* Literal.String.Single */
+.highlight .ss { color: lightsalmon; } /* Literal.String.Symbol */
+
+/*.highlight .o { } /* Operator */
+/*.highlight .ow { } /* Operator.Word */
+
+/*.highlight .ge { } /* Generic.Emph */
+
+/*.highlight .gd { } /* Generic.Deleted */
+/*.highlight .gi { } /* Generic.Inserted */
+
+/*.highlight .na { } /* Name.Attribute */
+/*.highlight .nb { } /* Name.Builtin */
+/*.highlight .nc { } /* Name.Class */
+/*.highlight .no { } /* Name.Constant */
+/*.highlight .nd { } /* Name.Decorator */
+/*.highlight .ni { } /* Name.Entity */
+/*.highlight .ne { } /* Name.Exception */
+/*.highlight .nf { } /* Name.Function */
+/*.highlight .nl { } /* Name.Label */
+/*.highlight .nn { } /* Name.Namespace */
+/*.highlight .nt { } /* Name.Tag */
+/*.highlight .nv { } /* Name.Variable */
+/*.highlight .bp { } /* Name.Builtin.Pseudo */
+/*.highlight .vc { } /* Name.Variable.Class */
+/*.highlight .vg { } /* Name.Variable.Global */
+/*.highlight .vi { } /* Name.Variable.Instance */
+
--- /dev/null
+
+
+
+body {
+ font-family: sans-serif;
+ margin: 0;
+}
+
+
+
+div.document {
+ margin: 0 0 0 20%;
+ padding: 1em;
+ text-align: justify;
+ color: darkslategray;
+}
+div.document a { color: steelblue; }
+div.document h1,
+div.document h2,
+div.document h3,
+div.document h4,
+div.document h5,
+div.document h6 {
+ font-weight: normal;
+ padding: 1em 0 0 0;
+}
+div.document h1 { text-align: center; }
+div.document h2 { border-bottom: 1px solid; }
+div.document h3 { border-bottom: 1px dotted; }
+div.document table, tr, td, th {
+ border: none;
+ padding: 0em 0.2em 0em 0.2em;
+}
+div.document img {
+ display: block;
+ border: 1px dotted;
+ margin: auto;
+}
+
+div.document img.feed {
+ display: inline;
+ border: none;
+ width: 2em;
+ vertical-align: middle;
+}
+div.document code {
+ font-size: 14px;
+ padding: 1px;
+ border: 1px solid gainsboro;
+ background-color: aliceblue;
+}
+/* :download: role; should look like a normal link rather than inline code block */
+div.document a code.download {
+ font-family: sans;
+ font-size: 1em;
+ padding: none;
+ border: none;
+ background-color: transparent;
+}
+
+
+div.footer {
+ margin: 0 0 0 20%;
+ padding: 1em;
+ float: right;
+ font-style: italic;
+ color: gainsboro;
+}
+
+
+
+div.sphinxsidebar {
+ border-right: 1px solid darkgray;
+ width: 20%;
+ text-align: left;
+ position: fixed;
+ background-color: gainsboro;
+ overflow: auto;
+ height: 100%;
+ color: midnightblue;
+}
+div.sphinxsidebar a { color: midnightblue; }
+div.sphinxsidebarwrapper { padding: 1em; }
+div.sphinxsidebarwrapper ul {
+ list-style-type: disc;
+ padding: 0 0 0 1em;
+ font-size: 0.95em;
+ color: darkgray;
+}
+div.sphinxsidebarwrapper h1,
+div.sphinxsidebarwrapper h2,
+div.sphinxsidebarwrapper h3,
+div.sphinxsidebarwrapper h4,
+div.sphinxsidebarwrapper h5,
+div.sphinxsidebarwrapper h6 {
+ padding: 0 0 0.1em 0;
+ border-bottom: 1px solid;
+}
+div.sphinxsidebarwrapper div.re2c-logo {
+ background-color: silver;
+ font-family: Courier;
+ font-size: 1.5em;
+ text-align: center;
+ border: 1px solid darkgray;
+ overflow: hidden;
+}
+div.re2c-toc-local {
+ padding: 0.5em;
+ background-color: linen;
+ border: 1px solid darkgray;
+ overflow: auto;
+}
+
+
+
+.headerlink { display: none; }
+
+a:focus { outline: none; }
--- /dev/null
+[theme]
+inherit = basic
+stylesheet = theme-re2c.css