Autumn Developer Guide
April 9, 2017 · View on GitHub
This page details the file structure of Autumn's source code, and how everything fits together including the parts that are not user-facing.
Directory Structure
├─ src/norswap/autumn/
│ ├── parsers/
│ ├── test/
│ ├── undoable/
├─ test/norswap/autumn/test/
│ ├── parsers/
src/norswap/autumn
Generally speaking, holds all source files that do not belong in any of the sub-packages.
-
The abstract base class for all Grammars.
-
The abstract base class for Grammars with tokenization support.
-
The type alias defining the
Parsertype. -
Encapsulate some textual input, adding a null terminator, performing tab-expansion, and enabling to track (line, column) positions within the input.
All parses run over a
ParseInput, although one may be automatically constructed form a string. -
A few global settings. Currently they only affect how
ParseInputinstances are created by default. -
Definitions related to the concept of side effect. A side effect is a reversible change to the parse state that has to be saved so that backtracking may undo the change. Side effects are also useful for memoization and left-recursion handling.
-
Defines the
Failuretype used to report parse errors.Also includes the definition of all failures that can be emitted by the parsers bundled with Autumn.
src/norswap/autumh/parsers/
Contains the definition of all parsers bundled with Autumn.
-
A parser that enable the definition of left-associative binary and postfix operators. Multiple operators sharing the same precedence can be defined. Instances of
AssocLeftandAssocRightcan be chained in order to enforced operator precedence. -
A parser that enable the definition of right-associative binary and prefix operators. Multiple operators sharing the same precedence can be defined. Instances of
AssocLeftandAssocRightcan be chained in order to enforced operator precedence. -
Parsers that match bracketed content and comma-separated lists.
-
Parsers that match at the character level.
-
Defines the
choiceparser that invokes its sub-parsers in order until one matches, and thelongestparser that invokes all its sub-parsers at the same position, and retains the result of the one that matched the most input. -
Defines the
leftrecparser that enables the creation of left-recursive parsers. -
Defines the
aheadparser that enables lookahead and thenotparser that succeeds only if some lookahead fails. -
Miscelleaneous parsers, some of which are related to failure-handling.
-
Parsers to match sub-parsers sequentially. Also enables optional matching. Includes
seq,opt,repeat0,repeat1, ... -
Parsers used to manipulate the value stack.
-
Defines parser that repeatedly match their first sub-parsers until their second sub-parser is matched.
src/norswap/autumh/test/
Contains the file GrammarFixture.kt which defines an
abstract base class for test classes to extend. The base class provides facilities to easily setup
grammar tests.
See the tests for the Java grammar as an example.
src/norswap/autumn/undoable
Contains the definition of data structures whose modifications automatically create a SideEffect
and register it with a grammar supplied at creation time.
The content of UndoList.kt and
UndoMap.kt should be obvious.
UndoRef.kt provides the means to create simple slots
whose mutation generate SideEffect objects. These slots may be backed by an existing memory
location.
TODO
- interior links
- link Grammar concept
- link tokenization concept
- link parser concept
- link tab expansion concept
- link side effect concept