Quail-Language

Quail Specification

Back to index

Chapter 3: Preprocessing

3.1 Definitions

Preprocessor is a program that transforms textual representation of program code by given rules. Preprocessing comes before lexical analysing.

Preprocessor directive is a textual representation of preprocessor rule.

Directive argument is a parameter that modifies the directive’s behaviour.

3.2 Directives

Directive consists of its name and arguments. One directive takes only one line. If you wish to use wrap your directive to next line, you should place \ backslash between lines as shown:

#:alias "HELLO" \
print("Hello")

#:alias "OTHERHELLO" \
print("Hello") \
print("Hello again")

General form of a directive look like this:

#:directive_name argument1 argument2 argument3 ... argumentN

Directives can accept following types of arguments:

Quail preprocessor defines grammar for next directives:

3.2.1 Alias

Name: alias, define

Arguments: string regex code replacement

Aliasing directive. Replaces all regex occurrences with given replacement. Regex capture groups also work. Does not replace content of strings.

3.2.3 Include

Name: include

Arguments: string path

Includes all contents of given file as a plain text at the top of the file

3.2 Preprocessor overview

Preprocessing consists of several steps:

  1. Resolving

    • Filter directive strings

    • Resolving string boundaries

    • Parsing preprocessor directives

  2. Processing

    • Executing directives

This process is repeated until resolving gives 0 resolved directives. Then the preprocessor gives out the result.