package
0.0.0-20201212205213-ae3286749100
Repository: https://github.com/npillmayer/gotype.git
Documentation: pkg.go.dev

# README

Purposes of Macro Languages

TeX features a powerful macro language. For newcomers to TeX-typesetting its language may look cumbersome—or even ugly or funny—but it is well thought out and surprisingly versatile. It serves a couple of purposes, which we will discuss.

  • Configurability
  • Adaptability
  • Extensibility

Configurability

When formatting your text you want to be able to configure a lot of things: fonts, colors, running headers, etc. Necessary configuration is often done in templates, but plain TeX does not support a templating mechnism. Instead, configuration is provided through a macro file.

Adaptability

TeX is used for all kinds of "documents." Obviously, it has been created for scientific papers and books, possibly heavy on mathematics, but over the year TeX has found usages besides that as well: music notes, chemistry, school books, and others. This testifies the versatility gained by the TeX macro language.

Extensibility

The best software systems usually provide a means of extending their functionality. TeX does this by providing hooks which may be extended or overridden by macros. Examples are token registers like everypar or the page output routine. There is even a generic extension mechanism called specials, which can be used for all kinds of additional functionality.

Lua

Modern versions of TeX support Lua as an extension language. Embedding Lua in an application is all the rage today, and we will follow this tradition. However, we will employ at least one Domain Specific Language: a derivate of MetaPost, which will be called (working title) "Poor Man's MetaPost" (PMMPost). MetaPost includes a powerful macro-language, which we will not support. Instead, we will make PMMPost extensible via Lua.

Parser Generators

We use ANTLR V4 as our goto-tool for implementing grammars, e.g., for PMMPost. Additionally we will create an experimental GLR parser. It is intended for parsing Markdown, but the idea still needs some working-on.

# Packages

Package corelang implements core commands for DSLs dealing with arithmetic expressions, pairs and paths.
Package pmmpost implements an interpreter for "Poor Man's MetaPost".
Package runtime implements an interpreter runtime, consisting of scopes, memory frames and symbols (variable declarations and references).
Package variables implements variables for programming languages similar to those in MetaFont and MetaPost.

# Functions

Create a new expression stack.
Create a new expression node given a polynomial.
Create a non-constant numeric expression node.
Create an expression node with other information.
Create a new pair expression node.
Create a non-constant pair expression node.

# Structs

Expressions will contain linear polynomials, possibly with variables of unknown value.
Type ExprStack.

# Interfaces

Some symbols are lvalues, i.e.