• Stars
    star
    6
  • Rank 2,539,965 (Top 51 %)
  • Language
    Ada
  • License
    MIT License
  • Created about 7 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

tools for writing lexers / parsers in Ada

ParserTools

This library provides several tools useful for writing lexers / parsers in Ada.

Text

This library provides a reference-counted type named Text.Reference that points to a UTF-8 encoded String of variable length. It is designed to be used with parsers that produce text nodes / tokens. It is most efficient for parsers that are operated in a stream-like manner, i.e. produced parser events are processed when generated. It can also be used for a parser that builds up a full AST. However, it is inefficient in scenarios where generated items go out of scope in random order and new items are still generated while old items are going out of order.

Usage

Text.Pool provides a custom allocator. This allocator is optimized based on the following assumptions:

  • The deallocation of text objects occurs in the same order as the allocation. This is no hard requirement, violations are tolerated, but may have an impact on performance.
  • Since the parser may be used through a C-level API, all Strings shall have an additional null terminator so that they can be efficiently exported to C. This terminator shall be hidden from the Ada view of the string value.
  • No manual memory management shall be necessary, both the Text objects and the Pool shall be reference-counted and automatically deallocated once the last reference vanishes.
  • Text objects shall be immutable once created.

To optimize performance, the allocator carves memory from pre-allocated chunks. There is no freelist; instead, the dope vectors of the Ada String objects are used to find the next free space. This way, adjacent free spaces can be efficiently merged and thus, memory fragmentation is avoided.

The automatic memory management comes at the cost of every Text object holding a reference to the Pool it was created with. This is necessary to make sure the Pool only deallocates a memory chunk once the last Text object goes out of scope.

Lexer

Lexer.Base provides a base for a lexer. It is a translation of Nim's module lexbase. It provides efficient buffering for the lexer source. It is build for parsing languages which have more or less regular linebreaks. The lexer only needs to check whether it needs to refill the buffer at linebreak characters.

Usage

After calling Init on the lexer, the next character can be queried with Next. Whenever Next returns a linebreak character, the user must call Handle_LF or Handle_CR (depending on the linebreak character) before calling Next again. When the end of the input is reached, Next returns an End of Transmission (Character'Val (4)) character. This character must not be allowed to be a part of the input.

License

MIT

More Repositories

1

NimYAML

YAML implementation for Nim
Nim
186
star
2

emerald

HTML5 templating engine for Nimrod
Nim
95
star
3

OpenGLAda

Thick Ada binding for OpenGL and GLFW
Ada
95
star
4

Zicross

Nix Flake for cross-compiling and packaging for foreign systems
Nix
55
star
5

OpenCLAda

An Ada binding for the OpenCL host API
Ada
15
star
6

DSA-LaTeX

LaTeX-Klasse und Dokumente für Das Schwarze Auge
TeX
14
star
7

DSA-4.1-Heldendokument

Konfigurierbares Heldendokument für DSA, basierend auf LuaLaTeX.
Lua
14
star
8

Nova-TeX-Suite

Nova support for TeX, LaTeX and ConTeXt
JavaScript
7
star
9

libyaml_constructor

Code generator to load YAML into C types
C
6
star
10

ada-bundler

Library and tool for transparently handling data and configuration file access in an Ada application. Supports MacOSX, Linux and Windows.
Ada
5
star
11

gps-osx

Native GNAT Programming Studio for OSX
Ada
5
star
12

NovaZig

Zig support for the Nova editor
Scheme
4
star
13

nova-nix-suite

Nix extension for Nova.app
Scheme
4
star
14

OpenGLAda-examples

Examples for OpenGLAda
Ada
4
star
15

nix-flakes-go-plugins

Article about building Go applications that support plugins with Nix Flakes
Nix
4
star
16

zargo

2D OpenGL drawing lib for zig
C
2
star
17

askew

code generator & framework for single-page GopherJS/WASM apps
Go
2
star
18

js-audio-fiddle

Fiddling with the Web Audio API and stuff
JavaScript
1
star
19

DSA-Heldendokument-Generator

Java Bibliothek + GUI für plattformübergreifende DSA Heldendokumenterstellung
Java
1
star
20

Con-Checkliste

CSS
1
star
21

DSA-Liber-Reprints

Nix
1
star
22

soqualpoints

Punktemanagement für universitäre Übungsveranstaltungen
PHP
1
star
23

FreeTypeAda

FreeType binding for Ada 2012
Ada
1
star