diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3119e646461b5d9914bc411911e37d258fb679a1 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,4 @@ +build +*.pyc +__pycache__ +doxygen-* diff --git a/doc/Doxyfile.lab1 b/doc/Doxyfile.lab1 new file mode 100644 index 0000000000000000000000000000000000000000..ac83bcd793a2b684853a6f013fda0a3f8dff170a --- /dev/null +++ b/doc/Doxyfile.lab1 @@ -0,0 +1,370 @@ +# Doxyfile 1.8.11 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = TDDD55 +PROJECT_NUMBER = +PROJECT_BRIEF = "TDDD55 Labs" +PROJECT_LOGO = +OUTPUT_DIRECTORY = doxygen-lab1 +CREATE_SUBDIRS = NO +ALLOW_UNICODE_NAMES = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 4 +ALIASES = +TCL_SUBST = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +EXTENSION_MAPPING = +MARKDOWN_SUPPORT = YES +AUTOLINK_SUPPORT = YES +BUILTIN_STL_SUPPORT = NO +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +GROUP_NESTED_COMPOUNDS = NO +SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +INLINE_SIMPLE_STRUCTS = NO +TYPEDEF_HIDES_STRUCT = NO +LOOKUP_CACHE_SIZE = 0 +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_PACKAGE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = NO +HIDE_SCOPE_NAMES = NO +HIDE_COMPOUND_REFERENCE= NO +SHOW_INCLUDE_FILES = YES +SHOW_GROUPED_MEMB_INC = NO +FORCE_LOCAL_INCLUDES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +STRICT_PROTO_MATCHING = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = +CITE_BIB_FILES = +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_AS_ERROR = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = ../lab1 +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f \ + *.for \ + *.tcl \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.as \ + *.js +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO +REFERENCES_LINK_SOURCE = YES +SOURCE_TOOLTIPS = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +CLANG_ASSISTED_PARSING = NO +CLANG_OPTIONS = +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_EXTRA_STYLESHEET = +HTML_EXTRA_FILES = +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_GAMMA = 80 +HTML_TIMESTAMP = NO +HTML_DYNAMIC_SECTIONS = NO +HTML_INDEX_NUM_ENTRIES = 100 +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_PUBLISHER_ID = org.doxygen.Publisher +DOCSET_PUBLISHER_NAME = Publisher +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +GENERATE_QHP = NO +QCH_FILE = +QHP_NAMESPACE = org.doxygen.Project +QHP_VIRTUAL_FOLDER = doc +QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = +QHG_LOCATION = +GENERATE_ECLIPSEHELP = NO +ECLIPSE_DOC_ID = org.doxygen.Project +DISABLE_INDEX = NO +GENERATE_TREEVIEW = NO +ENUM_VALUES_PER_LINE = 4 +TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +FORMULA_FONTSIZE = 10 +FORMULA_TRANSPARENT = YES +USE_MATHJAX = NO +MATHJAX_FORMAT = HTML-CSS +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_EXTENSIONS = +MATHJAX_CODEFILE = +SEARCHENGINE = YES +SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = +#--------------------------------------------------------------------------- +# Configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4 +EXTRA_PACKAGES = +LATEX_HEADER = +LATEX_FOOTER = +LATEX_EXTRA_STYLESHEET = +LATEX_EXTRA_FILES = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +LATEX_SOURCE_CODE = NO +LATEX_BIB_STYLE = plain +LATEX_TIMESTAMP = NO +#--------------------------------------------------------------------------- +# Configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +RTF_SOURCE_CODE = NO +#--------------------------------------------------------------------------- +# Configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_SUBDIR = +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# Configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = YES +XML_OUTPUT = xml +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# Configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- +GENERATE_DOCBOOK = NO +DOCBOOK_OUTPUT = docbook +DOCBOOK_PROGRAMLISTING = NO +#--------------------------------------------------------------------------- +# Configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# Configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration options related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +EXTERNAL_PAGES = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +MSCGEN_PATH = +DIA_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +DOT_NUM_THREADS = 0 +DOT_FONTNAME = Helvetica +DOT_FONTSIZE = 10 +DOT_FONTPATH = +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +UML_LIMIT_NUM_FIELDS = 10 +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = NO +DOT_PATH = +DOTFILE_DIRS = +MSCFILE_DIRS = +DIAFILE_DIRS = +PLANTUML_JAR_PATH = +PLANTUML_INCLUDE_PATH = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES diff --git a/doc/Doxyfile.lab3 b/doc/Doxyfile.lab3 new file mode 100644 index 0000000000000000000000000000000000000000..9c2c0f33bc8aed5384e1d241768946689d4de74d --- /dev/null +++ b/doc/Doxyfile.lab3 @@ -0,0 +1,370 @@ +# Doxyfile 1.8.11 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = TDDD55 +PROJECT_NUMBER = +PROJECT_BRIEF = "TDDD55 Labs" +PROJECT_LOGO = +OUTPUT_DIRECTORY = doxygen-lab3 +CREATE_SUBDIRS = NO +ALLOW_UNICODE_NAMES = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 4 +ALIASES = +TCL_SUBST = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +EXTENSION_MAPPING = +MARKDOWN_SUPPORT = YES +AUTOLINK_SUPPORT = YES +BUILTIN_STL_SUPPORT = NO +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +GROUP_NESTED_COMPOUNDS = NO +SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +INLINE_SIMPLE_STRUCTS = NO +TYPEDEF_HIDES_STRUCT = NO +LOOKUP_CACHE_SIZE = 0 +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_PACKAGE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = NO +HIDE_SCOPE_NAMES = NO +HIDE_COMPOUND_REFERENCE= NO +SHOW_INCLUDE_FILES = YES +SHOW_GROUPED_MEMB_INC = NO +FORCE_LOCAL_INCLUDES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +STRICT_PROTO_MATCHING = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = +CITE_BIB_FILES = +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_AS_ERROR = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = ../lab3-4 +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f \ + *.for \ + *.tcl \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.as \ + *.js +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO +REFERENCES_LINK_SOURCE = YES +SOURCE_TOOLTIPS = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +CLANG_ASSISTED_PARSING = NO +CLANG_OPTIONS = +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_EXTRA_STYLESHEET = +HTML_EXTRA_FILES = +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_GAMMA = 80 +HTML_TIMESTAMP = NO +HTML_DYNAMIC_SECTIONS = NO +HTML_INDEX_NUM_ENTRIES = 100 +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_PUBLISHER_ID = org.doxygen.Publisher +DOCSET_PUBLISHER_NAME = Publisher +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +GENERATE_QHP = NO +QCH_FILE = +QHP_NAMESPACE = org.doxygen.Project +QHP_VIRTUAL_FOLDER = doc +QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = +QHG_LOCATION = +GENERATE_ECLIPSEHELP = NO +ECLIPSE_DOC_ID = org.doxygen.Project +DISABLE_INDEX = NO +GENERATE_TREEVIEW = NO +ENUM_VALUES_PER_LINE = 4 +TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +FORMULA_FONTSIZE = 10 +FORMULA_TRANSPARENT = YES +USE_MATHJAX = NO +MATHJAX_FORMAT = HTML-CSS +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_EXTENSIONS = +MATHJAX_CODEFILE = +SEARCHENGINE = YES +SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = +#--------------------------------------------------------------------------- +# Configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4 +EXTRA_PACKAGES = +LATEX_HEADER = +LATEX_FOOTER = +LATEX_EXTRA_STYLESHEET = +LATEX_EXTRA_FILES = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +LATEX_SOURCE_CODE = NO +LATEX_BIB_STYLE = plain +LATEX_TIMESTAMP = NO +#--------------------------------------------------------------------------- +# Configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +RTF_SOURCE_CODE = NO +#--------------------------------------------------------------------------- +# Configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_SUBDIR = +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# Configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = YES +XML_OUTPUT = xml +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# Configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- +GENERATE_DOCBOOK = NO +DOCBOOK_OUTPUT = docbook +DOCBOOK_PROGRAMLISTING = NO +#--------------------------------------------------------------------------- +# Configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# Configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration options related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +EXTERNAL_PAGES = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +MSCGEN_PATH = +DIA_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +DOT_NUM_THREADS = 0 +DOT_FONTNAME = Helvetica +DOT_FONTSIZE = 10 +DOT_FONTPATH = +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +UML_LIMIT_NUM_FIELDS = 10 +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = NO +DOT_PATH = +DOTFILE_DIRS = +MSCFILE_DIRS = +DIAFILE_DIRS = +PLANTUML_JAR_PATH = +PLANTUML_INCLUDE_PATH = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..859e735ee05f4b45a128030762a08d72e465d9d9 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,28 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SPHINXPROJ = TDDD55CompilersAndInterpreters +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +html: Makefile doxygen-lab1/xml/index.xml doxygen-lab3/xml/index.xml + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + rm -rf "$(SOURCEDIR)/html/_source" + +clean: + rm -rf "$(BUILDDIR)" doxygen-lab* +doxygen-lab1/xml/index.xml: Doxyfile.lab1 + doxygen $< +doxygen-lab3/xml/index.xml: Doxyfile.lab3 + doxygen $< diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst new file mode 100644 index 0000000000000000000000000000000000000000..6f539a3edd2783b7daca279e568c87af688afd37 --- /dev/null +++ b/doc/source/changelog.rst @@ -0,0 +1,6 @@ +Changelog +========= + +.. git_changelog:: + :rev-list: HEAD + :filename_filter: doc/.* diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000000000000000000000000000000000000..0f5c711bab74b7b8d6c24a0275ab8848d97b2382 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,158 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/stable/config + +# -- Path setup -------------------------------------------------------------- + +# 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. +# +import os +import sys +sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'TDDD55 Compilers and Interpreters' +copyright = u'2013-2019, Linköping University' +author = u'Martin Sjölund et al.' + +# The short X.Y version +version = 'HT2019' +# The full version, including alpha/beta/rc tags +release = '' + + +# -- 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.imgmath', + 'sphinx.ext.todo', + 'sphinxcontrib.bibtex', + 'breathe', + # Currently, graphviz has no option to deal with large figures + 'modifiedgraphviz', + 'sphinx_git' +] + +# 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 master toctree document. +master_doc = 'index' + +# 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 + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path . +exclude_patterns = [] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +if True: + html_theme = 'sphinx_rtd_theme' + html_theme_options = { + } +else: + html_theme = 'alabaster' + +# 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 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'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- 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', +} + +imgmath_image_format = 'svg' +imgmath_dvisvgm_args = ['--no-fonts', '--exact'] +highlight_language = 'c++' + +breathe_projects = { + "lab1": "../doxygen-lab1/xml", + "lab3": "../doxygen-lab3/xml" +} + +mermaid_output_format = 'raw' +graphviz_output_format = 'svg' + +primary_domain = 'cpp' + +todo_include_todos = True + +numfig = True +numfig_format = { + 'figure' : 'Figure %s', + 'table' : 'Table %s', + 'code-block' : 'Listing %s' +} +numfig_secnum_depth = 1 +# -- Extension configuration ------------------------------------------------- + +html_show_sourcelink = False diff --git a/doc/source/doxygen.rst b/doc/source/doxygen.rst new file mode 100644 index 0000000000000000000000000000000000000000..b0783ba02390c8893b59a70efad3a3bb2241dc41 --- /dev/null +++ b/doc/source/doxygen.rst @@ -0,0 +1,14 @@ +Source Documentation +==================== + +Lab1 +---- + +.. doxygenindex:: + :project: lab1 + +Lab3-4 +------ + +.. doxygenindex:: + :project: lab3 diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..a69e18d3d2edf13f277331e538a4c0e5512454f8 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,33 @@ +Lab Instructions +================ + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + lab1.rst + lab2.rst + lab3.rst + lab4.rst + skeleton.rst + language.rst + changelog.rst + doxygen.rst + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + +.. todolist:: + +This version of the documentation: + +.. git_commit_detail:: + :branch: + :commit: + :sha_length: 10 + :uncommitted: + :untracked: diff --git a/doc/source/lab1.rst b/doc/source/lab1.rst new file mode 100644 index 0000000000000000000000000000000000000000..b1f02ed5d65b855bf33b63844ef5a8b7a4ac5150 --- /dev/null +++ b/doc/source/lab1.rst @@ -0,0 +1,134 @@ +.. _lab1: + +Lab 1: Attribute Grammars and Top-Down Parsing +============================================== + +.. default-domain:: cpp + +Although not as flexible as bottom-up parsers, top-down parsers can easily be implemented by hand, and as such they may be more convenient than a bottom-up parsers. +In this exercise you will specify a language of mathematical expressions using an attribute grammar, and then write a top-down parser to calculate the value of expressions in the language. + +The language consists of numbers, symbolic constants, single-argument functions, one unary and five binary operators. +A grammar for the language is given below, but this grammar is not suitable for implementation using a top-down technique since it is ambiguous and contains left recursion. + +.. code-block :: bnf + + <S> ::= <E> <end of line> <S> // Single Expression + | <end of line> // No more input + <E> ::= <E> "+" <E> // Addition + | <E> "-" <E> // Subtraction + | <E> "*" <E> // Multiplication + | <E> "/" <E> // Division + | <E> "^" <E> // Exponentiation + | "-" <E> // Unary minus + | "(" <E> ")" // Grouping + | id "(" <E> ")" // Function call + | id // Symbolic constant + | num // Numeric value + +Requirements +------------ + +Rewrite the grammar in the previous section so that the precedence and associativity of all operators becomes obvious. +Your grammar may contain left recursion. +The operator precedence is unary negation before exponentiation before multiplication and division, before addition and subtraction. +Addition, subtraction, multiplication and division are left associative. +Exponentiation is right-associative. + +Eliminate left recursion from your grammar and revise it so it is suitable for implementation in a predictive top-down parser. + +Implement your attribute grammar in a C++ class named :class:`Parser`. +The :class:`Parser` class should contain a method named :func:`Parser::Parse` that returns the value of a single statement in the language. +Your interpreter should understand the following symbolic constants and functions: + +.. list-table :: + + * - pi + - 3.14159265 + * - e + - 2.71828183 + * - `log() <https://linux.die.net/man/3/log>`_ + - Natural logarithm + * - `log10() <https://linux.die.net/man/3/log10>`_ + - Base 10 logarithm + * - `exp() <https://linux.die.net/man/3/exp>`_ + - Powers of e + * - `sin() <https://linux.die.net/man/3/sin>`_ + - Sine + * - `cos() <https://linux.die.net/man/3/cos>`_ + - Cosine + * - `tan() <https://linux.die.net/man/3/tan>`_ + - Tangent + * - `arcsin() <https://linux.die.net/man/3/arcsin>`_ + - Arc sine + * - `arccos() <https://linux.die.net/man/3/arccos>`_ + - Arc cosine + * - `arctan() <https://linux.die.net/man/3/arctan>`_ + - Arc tangent + +All the functions are available in the standard math library. +See the Unix manual pages for details. + +Implement error recovery in your parser. +The simplest form of error recovery is to scan tokens to the end of a line and then resume parsing. +Feel free to implement a smarter error recovery strategy. + +Hand in the following + * Printouts of all the files you modified or created. + * Answers to the questions in the next section. + * Test data that show that the program works as specified. + Be sure to test error recovery, both from parser and scanner errors. + Be sure to check that error recovery does not interfere with the next input line. + Check that precedence and associativity rules are followed. + +Demonstrate your solution to your lab assistant during a laboratory session. +Send an e-mail (one e-mail per group) with your modified code and answers to the questions to the same assistant, put TDDD55, assignment number and your LiU logins in the e-mail subject line. + +Questions +--------- + +#. Define a regular expression for numeric constants. + It should allow integers, numbers with a fractional part and numbers with an exponent. + A number containing a decimal point must have at least one digit before or after the decimal point (or both). + The exponent may have a sign, plus or minus, and is always an integer. + + .. list-table :: + :header-rows: 1 + + * - Allowed + - Not allowed + * - ``1234`` + - ``A123`` + * - ``3.14`` + - ``.`` + * - ``.112`` + - ``112.a`` + * - ``112.`` + - ``1E2.3`` + * - ``12.34`` + - ``2.3e3.`` + * - ``34E-23`` + - ``23E 54`` + * - ``34.E+3`` + - + * - ``2.2e5`` + - +#. Construct a DFA that accepts the same language as the regular expression you defined in the previous question. + Suggest how to implement a scanner based on your DFA. + +Supporting Programs +------------------- + +The files ``lab1.cc`` and ``lab1.hh`` contain a skeleton for the parser class and a class called :class:`Trace` that can be used to trace invocation of functions. +See the :func:`Parser::Parse` method for an example of how to use it. +Objects of the class print an entry message when created and an exit message when destroyed. + +The files ``lex.cc`` and ``lex.hh`` contain a scanner class. +To use it create an object of type :class:`Scanner` and call its :func:`Scanner::Scan` method to get a token. +Tokens returned are of type :class:`Token`. +See the comments in ``lex.hh`` for a description of how they work. + +The file ``main.cc`` contains a sample main program. +You may have to modify it depending on how you choose to report errors from your parser. +If the scanner encounters an error it will throw an object of type :class`ScannerError`. +Your main program should catch this exception (the sample main program does), print an error message (you can print a :class:`ScannerError` object using stream operators) and then perform error recovery. diff --git a/doc/source/lab2.rst b/doc/source/lab2.rst new file mode 100644 index 0000000000000000000000000000000000000000..580d2b25be76d415632bd90dd139e50ebcf224b8 --- /dev/null +++ b/doc/source/lab2.rst @@ -0,0 +1,79 @@ +Lab 2: Scanner Specification +============================ + +The scanner is the part of the compiler responsible for grouping characters in the input stream into tokens which are used by the parser. +A typical scanner for a programming language will recognize tokens such as reserved words, identifiers, numeric constants, strings and operators. + +One of the simplest ways of implementing a scanner is to use a scanner generator. +There are numerous such tools available. For this exercise you will use ``flex``, which stands for "Fast lex". + +Using flex +---------- + +Full documentation for flex is available as a man page. +Just type ``man flex`` at a Unix prompt to see the documentation. +There are a few differences between ``lex`` and ``flex``, but not too many. + +The Generated Scanner +--------------------- + +When you compile a scanner specification using flex, a function named ``yylex`` is generated. +The default definition of this function takes no arguments and returns an integer, which represents the scanned token. + +Tokens are usually numbered from 257 and up, since that allows the scanner to return any single character as a token. +In ``scanner.l`` the final rule uses this feature; any unmatched characters are returned as tokens. + +The generated scanner also includes a number of important global variables and utility functions. +The ones that you will encounter are the variables ``yylineno``, ``yyin``, ``yytext`` and the function ``yyterminate``. + +yylineno + This variable holds the number of the current line of input. + It is useful for error reporting, but slows the scanner down somewhat, so in order to use it, it has to be explicitly enabled using command-line options or the ``yylineno`` declaration in the scanner specification. + +yyin + This variable holds the file pointer from which ``yylex`` reads its input. + +yytext + This is a character array containing the characters that were recognized as a token. + +yyterminate + This function terminates the scanning process and causes ``yylex`` to return 0. + It can be called in any action, and is the default action at the end of file. + +The Tokens +---------- + +Your scanner shall skip comments, both single-line C++ comments and multi line C-style comments. +If the scanner sees ``/*`` within a C comment it has to print a warning message. +If the end of file is encountered within a C style comment, your scanner must print an error message and then terminate. + +Floating-point numbers + Consist of an integer part followed by a period, a decimal part and an exponent. + The integer and decimal parts are simply sequences of digits. + The exponent part consists of the character ``E`` followed by an optional sign and a sequence of digits. + Either the integer or the decimal part (or both) must be given. + The exponent is optional. + If the integer part and exponent are both given, the decimal point and decimal part are optional. + These are some valid floating-point numbers: ``1.1``, ``.1``, ``1.``, ``1E2``, ``2E-3``, ``.1E-4``. + When your scanner recognizes a floating-point number it should return ``REAL``. +Integers + Are simply sequences of digits that are not part of identifiers or floating-point numbers. + When your scanner recognizes an integer it should return ``INTEGER``. +Identifiers + Must start with a letter, followed by any number of digits, letters or underscore characters. + When your scanner recognizes an identifier it should return ``ID``. + +Requirements +------------ + +You are to finish the scanner specification in ``scanner.l`` by adding rules for C and C++ style comments, identifiers, integers and reals. +Compile your scanner using the command ``make scanner``. +This generates a program named scanner, which you can use to test your scanner. +Run your scanner on the files in lab2/test and check that it generates the correct output. + +Hand in the following + * The scanner specification, with your changes clearly marked. + * Test data that show that the scanner works as specified. + +Demonstrate your solution to your lab assistant during a laboratory session. +Send an e-mail (one e-mail per group) with your modified code to the same assistant, put TDDD55, assignment number and your LiU logins in the e-mail subject line. diff --git a/doc/source/lab3.rst b/doc/source/lab3.rst new file mode 100644 index 0000000000000000000000000000000000000000..f05e22472dca41fa0431a51d43b33a2a6431dfbb --- /dev/null +++ b/doc/source/lab3.rst @@ -0,0 +1,44 @@ +Lab 3: Parser Generators +======================== + +The purpose of a parser generator is to create a parser from a language specification. +A language specification is much easier to create and maintain than a hand-written parser, which is the main reason for using parser generators. + +There are a wide variety of parser generators available. +Most available tools generate LALR parsers, but there are general LR(k) and LL(k) parser generators available as well. +In this exercise you will use ``bison``, an LALR(1) parser generator. + +Using ``bison`` +--------------- + +Full documentation for bison is available as an info document. +To view the documentation, start emacs, type C-h i, and select the entry entitled ``bison``. + +It is also available as `HTML <https://www.gnu.org/software/bison/manual/html_node/index.html>`_ and alternatives include plain old books. + +The Generated Parser +-------------------- + +When you compile a parser specification with bison, a function named ``yyparse`` is created. +This function in turn calls ``yylex`` to retrieve tokens from the input, and ``yyerror`` to report errors. + +You can provide ``yylex`` by updating the rules in ``scanner.l`` to match the ones you wrote in the previous exercise. +A version of ``yyerror`` is already supplied in ``parser.y``. + +Requirements +------------ + +You are to write the specifications for expressions, conditions and function definitions. +Make sure that both children of an operator node have the same type. +You may need to insert :class:`IntegerToReal` nodes in some cases, to convert integers to floating-point numbers. + +You also need to augment the grammar with error productions. +After an error occurs, parsing of statements should be resumed after the next semicolon. +You may insert other error productions if you want to. + +Hand in the following + * A listing of parser.y with your changes clearly marked. + * Listings of any other files you have modified, with your changes clearly marked. + +Demonstrate your solution to your lab assistant during a laboratory session. +Send an e-mail (one e-mail per group) with your modified code to the same assistant, put TDDD55, assignment number and your LiU logins in the e-mail subject line. diff --git a/doc/source/lab4.rst b/doc/source/lab4.rst new file mode 100644 index 0000000000000000000000000000000000000000..1a677438de7ce074eadc97cf5da2c55011de7b81 --- /dev/null +++ b/doc/source/lab4.rst @@ -0,0 +1,28 @@ +Lab 4 : Intermediate Code Generation +==================================== + +The purpose of this exercise is to learn a little about how parse trees can be translated into intermediary code. +Although there are powerful tools that can be used to generate code generators, it is still often done by hand. + +Requirements +------------ + +The file ``codegen.cc`` contains methods for generating code from most types of abstract syntax tree nodes, but you need to write the methods for if statements (including the elseif and else branches), for array references and assignments to array elements and for all binary operators and relations by implementing the function :func:`BinaryGenerateCode` which is used for all binary operators and relations. +Write the missing methods and add calls to ``GenerateCode`` in the parser specification. +When completed, you should have a program that is capable of generating intermediate code for the small programming language used in exercises two, three and four. + +Hand in the following + * A listing of ``codegen.cc`` with your changes clearly marked. + * Listings of any other files you modified. + * Answers to the questions in the next section. + +Demonstrate your solution to your lab assistant during a laboratory session. +Send an e-mail (one e-mail per group) with your modified code and answers to the questions to the same assistant, put TDDD55, assignment number and your LiU logins in the e-mail subject line. + +Questions +--------- + +#. The code generator generates terribly inefficient code. + For example, assigning a constant to a variable causes two quads to be generated, where one would have been enough. + There are a number of other situations where equally bad code is generated. + Suggest at least one way of eliminating most of the bad code that is generated. diff --git a/doc/source/language.rst b/doc/source/language.rst new file mode 100644 index 0000000000000000000000000000000000000000..359781cf00328749637f2376227d06ef9ddd2a78 --- /dev/null +++ b/doc/source/language.rst @@ -0,0 +1,374 @@ +The Language +============ + +The language you are to compile is in some ways similar to Pascal, but uses syntax from C and Ada. +It supports nested functions, one-dimensional arrays and numeric data types. + +The Program Structure +--------------------- + +A program consists of three sections. +The first section, *declarations*, holds declarations of all global variables. +The next section, *functions*, holds all functions defined in the program. +The final section, *body*, is a code block representing the main program body. + +.. _structure-program: + +.. code-block :: pascal + :caption: The structure of a program + + // First section, declarations + + declare + var1 : type1; + var2 : type2; + + // Second section, functions + + function func1 ( params ) : type + begin + ... + end; + + function func2 ( params ) : type + begin + ... + end; + + // Final section, main program code block + + begin + ... + end; + +Function Definitions +-------------------- + +Function definitions start out with the keyword ``function`` followed by the function's name, its parameters and return type. +Next comes a block of local variable declarations and then local function declarations. +The function is concluded with a code block for the function body. + +.. _structure-fun-def: + +.. code-block :: pascal + :caption: Structure of a function definition + + function name ( param1 , param2 , ... ) : type + declare + var1 : type1; + var2 : type2; + + function local1 ( params ) : type + begin + end; + + begin + // Function body + end; + +Function that are declared within another function have access to the local variables and parameters of the surrounding function. +The language has a static scope. + +.. _valid-fun-def: + +.. code-block :: pascal + :caption: Examples of valid function definitions. + + function fac ( x : integer ) : integer + begin + if x == 1 then begin return 1; end + else begin return x * fac(x - 1); end if; + end; + + function max3 ( x : array 5 of real ) : real + declare + tmp : real; + i : integer; + begin + i := 1; + tmp := x[0]; + while i < 5 do + begin + if tmp < x[i] then begin tmp = x[i]; end; + i := i + 1; + end while; + return tmp; + end; + +Declaration Blocks +------------------ + +Declarations can appear either at the beginning of a program or at the beginning of a function. +The purpose of a declaration block is to define the names and types of variables used in subsequent code blocks. + +A declaration block starts with the keyword ``declare``, followed by one or more declarations. +Each declarations is an identifier followed by a colon and a type. +The declaration block is terminated by the start of anything that does not look like a declaration. +All declaration blocks are optional and may be omitted completely. + +There are examples of declaration blocks in :numref:`structure-program`, :numref:`structure-fun-def`, and :numref:`valid-fun-def`. + +Code Blocks +----------- + +A code block starts with the keyword ``begin``, which is followed by zero or more statements. +The code block is terminated by ``end``. +Each statement must be terminated by a semicolon. + +There are five types of statements: + +* ``if`` statements +* assignments +* ``return`` statements +* function calls +* ``while`` statements + +Each type of statement is described below. + +The if statement +^^^^^^^^^^^^^^^^ + +An if statement starts with the keyword ``if``, followed by a condition, the keyword ``then``, a code block, an optional elseif list and an optional else part. + +.. code-block :: pascal + :caption: Structure of an if statement + + if condition then + then-part; + elseif condition then + elseif-part; + elseif condition then + elseif-part; + else + else-part; + end if; + +The elseif-list is a list of one or more pieces of code consisting of the keyword ``elseif``, followed by a condition, the keyword ``then`` and a code block. + +The else part is a piece of code consisting of the keyword ``else`` followed by a code block. + +The last ``end`` of an if statement must be followed by the keyword ``if``. + +The if statement tests each of its conditions, specified after the ``if`` or ``elseif`` in order. +If a condition is true, then the code block corresponding to that condition is executed, and when it is finished, execution resumes at the statement following the if statement. +If none of the conditions are true and there is an else part, the code block in the else part is executed. +If there is no else part, execution is simple resumed at the next statement. + +.. code-block :: pascal + :caption: Some valid if statements + + if x == 1 then + begin + y := 3; + end if; + + if x == 1 then + begin + result := a; + end + elseif x == 2 then + begin + result := b; + end if; + + if x > y then + begin + out := 1; + end + elseif x < y + begin + out := -1; + end + else + begin + out := 0; + end + if; + +The Assignment Statement +^^^^^^^^^^^^^^^^^^^^^^^^ + +An assignment statement is simply an identifier or a reference to an array element followed by ``:=`` and an expression. +Assignments to entire arrays are not allowed, nor are assignments to functions. + +Tbe result of the expression is converted as necessary. +If it is an integer, it may converted to a real; if it is a real, it may be truncated. + +.. code-block :: pascal + :caption: Some valid assignment statements + + x := 3; + x := 2 - (x * 2); + x := fac(y); + +The Function Call +^^^^^^^^^^^^^^^^^ + +A function call consists of an identifier, followed by a left parenthesis, a comma-separated list of expressions and a right parenthesis. +When as a statement, the result of the function call is simply discarded. + +.. code-block :: pascal + :caption: Some valid function call statements + + ackerman(2,3); + fac(4); + initialize(); + +The Return Statement +^^^^^^^^^^^^^^^^^^^^ + +A return statement consists of the keyword ``return`` followed by an expression. + +The return statement causes the currently executing function to return the value of the expression. +Calling return from the body of the main program, or with the wrong data type, is an error. + +The While Statement +^^^^^^^^^^^^^^^^^^^ + +A while statement consists of the keyword ``while``, followed by a condition, the keyword ``do``, a code block and finally the keyword ``while``. + +.. code-block :: pascal + :caption: Structure of the while statement. + + while condition do + begin + loop-body; + end while; + +While loops are the only kind of loop in the language. +The loop body is executed until the condition is false at the beginning of the loop body. +The condition is also tested before entering the loop for the first time. + + +.. code-block :: pascal + :caption: Examples of valid while statements. + + x := 1; + while x < 10 do + begin + y := y + calculate(x); + x := x + 1; + end while; + + while x == 1 and x < 5 do + begin + x := random(); + end while; + +Types +----- + +There are only two predefined types, ``integer`` and ``real``. +Integers are signed 32-bit integer quantities. +Reals are double-precision floating point numbers. + +It is possible to construct arrays from integers and reals. +The syntax from an array is ``array`` *size* ``of`` *type*, where *size* is the number of elements in the array (an integer constant) and *type* is the element type (either ``integer`` or ``real``). + +Identifiers +----------- + +An identifier is an arbitrarily long string of characters. +The first character must be a letter. +Any subsequent characters must be letters, digits or underscores. + +Some valid identifiers + ``tmp``, ``g_04``, ``integer_constant`` + +Numeric Constants +----------------- + +There are two kinds of numeric constants (literal values). +An integer constant consists of a string of digits. +A real constant consists of a string of digits, a decimal point, a string of digits and an optional exponent. +There must be at least one digit on one side of the decimal point. +The optional exponent consists of the letter ``E`` an optional sign and an integer. +A real constant can also be a string of digits followed by an exponent. + +Some valid integers + ``123``, ``4711``, ``17`` + +Some valid reals + ``.12``, ``1.2``, ``3.``, ``1.2E-3``, ``.3E44``, ``12E5`` + +Array References +---------------- + +An array reference consists of an identifier, a left square bracket, an expression and a right square bracket. +Array elements are numbered from 0 and up, so ``a[0]`` is the first element in the array ``a`` and ``a[1]`` is the second element. + +The expression used as the index must return an integer. + +Expressions +----------- + +Expressions are used on the right-hand side of assignments, as the index in array references. +Expressions may contain the following binary operators: + +``x ^ y`` + The result is ``x`` raised to the power of ``y``. +``- x`` + The result is the unary negation of ``x``. +``x * y`` + The result is the multiplication of ``x`` and ``y``. +``x / y`` + The result is ``x`` divided by ``y``. +``x + y`` + The result is ``x`` plus ``y``. +``x - y`` + The result is ``x`` minus ``y``. + +If all operands are of the same type, then the result will also be of that type. +This means that division of two integers will produce a truncated value. +If one of the operands is an integer and the other is a real, then the integer must be converted to a real before executing the operation. +Arrays are not permitted in expressions, although references to array elements are. + +The precedence levels (highest first) and associativity of the operators are: + +.. list-table :: + + * - ``^`` + - Right-associative + * - ``-`` + - (unary minus) + * - ``*``, ``/`` + - Left-associative + * - ``+``, ``-`` + - Left-associative + +Parenthesis may be used in the conventional manner to force the order of evaluation. + +Expressions may also contain numeric constants, variables, array references and function calls. + +Conditions +---------- + +Conditions consist of binary relations and logical operators. +The following operators exist (both x and y are expressions): + +``x >= y`` + True if ``x`` is greater than or equal to ``y`` +``x <= y`` + True if ``x`` is less than or equal to ``y`` +``x > y`` + True if ``x`` is greater than ``y`` +``x < y`` + True if ``x`` is less than ``y`` +``x == y`` + True if ``x`` is equal to ``y`` +``x <> y`` + True if ``x`` is not equal to ``y`` + +The logical operators are + +``x and y`` + True if ``x`` and ``y`` are both true +``x or y`` + True if one or both of ``x`` and ``y`` are true +``not x`` + True if ``x`` is not true + +Parenthesis may be used within conditions in the same way as in expressions. +The binary relations have higher precedence than the logical operators, so ``a == b and c < d`` is the same as ``(a == b) and (c == d)``. +Among the logical operators, ``not`` has higher precedence than ``and``, which has higher precedence than ``or``. +Finally, the constants ``true`` and ``false`` are allowed as conditions. diff --git a/doc/source/modifiedgraphviz.py b/doc/source/modifiedgraphviz.py new file mode 100644 index 0000000000000000000000000000000000000000..08e15551624e7eae4bf6cd4cfe1c02564fa805e0 --- /dev/null +++ b/doc/source/modifiedgraphviz.py @@ -0,0 +1,366 @@ +# -*- coding: utf-8 -*- +""" + sphinx.ext.graphviz + ~~~~~~~~~~~~~~~~~~~ + + Allow graphviz-formatted graphs to be included in Sphinx-generated + documents inline. + + :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re +import codecs +import posixpath +from os import path +from subprocess import Popen, PIPE +from hashlib import sha1 + +from six import text_type + +from docutils import nodes +from docutils.parsers.rst import Directive, directives +from docutils.statemachine import ViewList + +import sphinx +from sphinx.errors import SphinxError +from sphinx.locale import _, __ +from sphinx.util import logging +from sphinx.util.i18n import search_image_for_language +from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL + +if False: + # For type annotation + from typing import Any, Dict, List, Tuple # NOQA + from sphinx.application import Sphinx # NOQA + +logger = logging.getLogger(__name__) + + +mapname_re = re.compile(r'<map id="(.*?)"') + + +class GraphvizError(SphinxError): + category = 'Graphviz error' + + +class graphviz(nodes.General, nodes.Inline, nodes.Element): + pass + + +def figure_wrapper(directive, node, caption): + # type: (Directive, nodes.Node, unicode) -> nodes.figure + figure_node = nodes.figure('', node) + if 'align' in node: + figure_node['align'] = node.attributes.pop('align') + + parsed = nodes.Element() + directive.state.nested_parse(ViewList([caption], source=''), + directive.content_offset, parsed) + caption_node = nodes.caption(parsed[0].rawsource, '', + *parsed[0].children) + caption_node.source = parsed[0].source + caption_node.line = parsed[0].line + figure_node += caption_node + return figure_node + + +def align_spec(argument): + # type: (Any) -> bool + return directives.choice(argument, ('left', 'center', 'right')) + + +class Graphviz(Directive): + """ + Directive to insert arbitrary dot markup. + """ + has_content = True + required_arguments = 0 + optional_arguments = 1 + final_argument_whitespace = False + option_spec = { + 'alt': directives.unchanged, + 'align': align_spec, + 'caption': directives.unchanged, + 'graphviz_dot': directives.unchanged, + 'name': directives.unchanged, + } + + def run(self): + # type: () -> List[nodes.Node] + if self.arguments: + document = self.state.document + if self.content: + return [document.reporter.warning( + __('Graphviz directive cannot have both content and ' + 'a filename argument'), line=self.lineno)] + env = self.state.document.settings.env + argument = search_image_for_language(self.arguments[0], env) + rel_filename, filename = env.relfn2path(argument) + env.note_dependency(rel_filename) + try: + with codecs.open(filename, 'r', 'utf-8') as fp: + dotcode = fp.read() + except (IOError, OSError): + return [document.reporter.warning( + __('External Graphviz file %r not found or reading ' + 'it failed') % filename, line=self.lineno)] + else: + dotcode = '\n'.join(self.content) + if not dotcode.strip(): + return [self.state_machine.reporter.warning( + __('Ignoring "graphviz" directive without content.'), + line=self.lineno)] + node = graphviz() + node['code'] = dotcode + node['options'] = {} + if 'graphviz_dot' in self.options: + node['options']['graphviz_dot'] = self.options['graphviz_dot'] + if 'alt' in self.options: + node['alt'] = self.options['alt'] + if 'align' in self.options: + node['align'] = self.options['align'] + + caption = self.options.get('caption') + if caption: + node = figure_wrapper(self, node, caption) + + self.add_name(node) + return [node] + + +class GraphvizSimple(Directive): + """ + Directive to insert arbitrary dot markup. + """ + has_content = True + required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = False + option_spec = { + 'alt': directives.unchanged, + 'align': align_spec, + 'caption': directives.unchanged, + 'graphviz_dot': directives.unchanged, + 'name': directives.unchanged, + } + + def run(self): + # type: () -> List[nodes.Node] + node = graphviz() + node['code'] = '%s %s {\n%s\n}\n' % \ + (self.name, self.arguments[0], '\n'.join(self.content)) + node['options'] = {} + if 'graphviz_dot' in self.options: + node['options']['graphviz_dot'] = self.options['graphviz_dot'] + if 'alt' in self.options: + node['alt'] = self.options['alt'] + if 'align' in self.options: + node['align'] = self.options['align'] + + caption = self.options.get('caption') + if caption: + node = figure_wrapper(self, node, caption) + + self.add_name(node) + return [node] + + +def render_dot(self, code, options, format, prefix='graphviz'): + # type: (nodes.NodeVisitor, unicode, Dict, unicode, unicode) -> Tuple[unicode, unicode] + """Render graphviz code into a PNG or PDF output file.""" + graphviz_dot = options.get('graphviz_dot', self.builder.config.graphviz_dot) + hashkey = (code + str(options) + str(graphviz_dot) + + str(self.builder.config.graphviz_dot_args)).encode('utf-8') + + fname = '%s-%s.%s' % (prefix, sha1(hashkey).hexdigest(), format) + relfn = posixpath.join(self.builder.imgpath, fname) + outfn = path.join(self.builder.outdir, self.builder.imagedir, fname) + + if path.isfile(outfn): + return relfn, outfn + + if (hasattr(self.builder, '_graphviz_warned_dot') and + self.builder._graphviz_warned_dot.get(graphviz_dot)): + return None, None + + ensuredir(path.dirname(outfn)) + + # graphviz expects UTF-8 by default + if isinstance(code, text_type): + code = code.encode('utf-8') + + dot_args = [graphviz_dot] + dot_args.extend(self.builder.config.graphviz_dot_args) + dot_args.extend(['-T' + format, '-o' + outfn]) + if format == 'png': + dot_args.extend(['-Tcmapx', '-o%s.map' % outfn]) + try: + p = Popen(dot_args, stdout=PIPE, stdin=PIPE, stderr=PIPE) + except OSError as err: + if err.errno != ENOENT: # No such file or directory + raise + logger.warning(__('dot command %r cannot be run (needed for graphviz ' + 'output), check the graphviz_dot setting'), graphviz_dot) + if not hasattr(self.builder, '_graphviz_warned_dot'): + self.builder._graphviz_warned_dot = {} + self.builder._graphviz_warned_dot[graphviz_dot] = True + return None, None + try: + # Graphviz may close standard input when an error occurs, + # resulting in a broken pipe on communicate() + stdout, stderr = p.communicate(code) + except (OSError, IOError) as err: + if err.errno not in (EPIPE, EINVAL): + raise + # in this case, read the standard output and standard error streams + # directly, to get the error message(s) + stdout, stderr = p.stdout.read(), p.stderr.read() + p.wait() + if p.returncode != 0: + raise GraphvizError(__('dot exited with error:\n[stderr]\n%s\n' + '[stdout]\n%s') % (stderr, stdout)) + if not path.isfile(outfn): + raise GraphvizError(__('dot did not produce an output file:\n[stderr]\n%s\n' + '[stdout]\n%s') % (stderr, stdout)) + return relfn, outfn + + +def render_dot_html(self, node, code, options, prefix='graphviz', + imgcls=None, alt=None): + # type: (nodes.NodeVisitor, graphviz, unicode, Dict, unicode, unicode, unicode) -> Tuple[unicode, unicode] # NOQA + format = self.builder.config.graphviz_output_format + try: + if format not in ('png', 'svg'): + raise GraphvizError(__("graphviz_output_format must be one of 'png', " + "'svg', but is %r") % format) + fname, outfn = render_dot(self, code, options, format, prefix) + except GraphvizError as exc: + logger.warning('dot code %r: ' % code + str(exc)) + raise nodes.SkipNode + + if fname is None: + self.body.append(self.encode(code)) + else: + if alt is None: + alt = node.get('alt', self.encode(code).strip()) + imgcss = imgcls and 'class="%s"' % imgcls or '' + if 'align' in node: + self.body.append('<div align="%s" class="align-%s">' % + (node['align'], node['align'])) + if format == 'svg': + svgtag = '''<img src="%s" alt="%s" />\n''' % (fname, alt) + self.body.append(svgtag) + else: + with open(outfn + '.map', 'rb') as mapfile: + imgmap = mapfile.readlines() + if len(imgmap) == 2: + # nothing in image map (the lines are <map> and </map>) + self.body.append('<img src="%s" alt="%s" %s/>\n' % + (fname, alt, imgcss)) + else: + # has a map: get the name of the map and connect the parts + mapname = mapname_re.match(imgmap[0].decode('utf-8')).group(1) # type: ignore + self.body.append('<img src="%s" alt="%s" usemap="#%s" %s/>\n' % + (fname, alt, mapname, imgcss)) + self.body.extend([item.decode('utf-8') for item in imgmap]) + if 'align' in node: + self.body.append('</div>\n') + + raise nodes.SkipNode + + +def html_visit_graphviz(self, node): + # type: (nodes.NodeVisitor, graphviz) -> None + render_dot_html(self, node, node['code'], node['options']) + + +def render_dot_latex(self, node, code, options, prefix='graphviz'): + # type: (nodes.NodeVisitor, graphviz, unicode, Dict, unicode) -> None + try: + fname, outfn = render_dot(self, code, options, 'pdf', prefix) + except GraphvizError as exc: + logger.warning('dot code %r: ' % code + str(exc)) + raise nodes.SkipNode + + is_inline = self.is_inline(node) + + if not is_inline: + pre = '' + post = '' + if 'align' in node: + if node['align'] == 'left': + pre = '{' + post = r'\hspace*{\fill}}' + elif node['align'] == 'right': + pre = r'{\hspace*{\fill}' + post = '}' + elif node['align'] == 'center': + pre = r'{\hfill' + post = r'\hspace*{\fill}}' + self.body.append('\n%s' % pre) + + self.body.append(r'\includegraphics{%s}' % fname) + + if not is_inline: + self.body.append('%s\n' % post) + + raise nodes.SkipNode + + +def latex_visit_graphviz(self, node): + # type: (nodes.NodeVisitor, graphviz) -> None + render_dot_latex(self, node, node['code'], node['options']) + + +def render_dot_texinfo(self, node, code, options, prefix='graphviz'): + # type: (nodes.NodeVisitor, graphviz, unicode, Dict, unicode) -> None + try: + fname, outfn = render_dot(self, code, options, 'png', prefix) + except GraphvizError as exc: + logger.warning('dot code %r: ' % code + str(exc)) + raise nodes.SkipNode + if fname is not None: + self.body.append('@image{%s,,,[graphviz],png}\n' % fname[:-4]) + raise nodes.SkipNode + + +def texinfo_visit_graphviz(self, node): + # type: (nodes.NodeVisitor, graphviz) -> None + render_dot_texinfo(self, node, node['code'], node['options']) + + +def text_visit_graphviz(self, node): + # type: (nodes.NodeVisitor, graphviz) -> None + if 'alt' in node.attributes: + self.add_text(_('[graph: %s]') % node['alt']) + else: + self.add_text(_('[graph]')) + raise nodes.SkipNode + + +def man_visit_graphviz(self, node): + # type: (nodes.NodeVisitor, graphviz) -> None + if 'alt' in node.attributes: + self.body.append(_('[graph: %s]') % node['alt']) + else: + self.body.append(_('[graph]')) + raise nodes.SkipNode + + +def setup(app): + # type: (Sphinx) -> Dict[unicode, Any] + app.add_node(graphviz, + html=(html_visit_graphviz, None), + latex=(latex_visit_graphviz, None), + texinfo=(texinfo_visit_graphviz, None), + text=(text_visit_graphviz, None), + man=(man_visit_graphviz, None)) + app.add_directive('graphviz', Graphviz) + app.add_directive('graph', GraphvizSimple) + app.add_directive('digraph', GraphvizSimple) + app.add_config_value('graphviz_dot', 'dot', 'html') + app.add_config_value('graphviz_dot_args', [], 'html') + app.add_config_value('graphviz_output_format', 'png', 'html') + return {'version': sphinx.__display_version__, 'parallel_read_safe': True} diff --git a/doc/source/skeleton.rst b/doc/source/skeleton.rst new file mode 100644 index 0000000000000000000000000000000000000000..ba0f4f22073c442761f0b1917977c367a49cecc2 --- /dev/null +++ b/doc/source/skeleton.rst @@ -0,0 +1,2 @@ +The Skeleton +============