Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Syntax

C²’s syntax determines how a C squared program must look.

Concrete syntax

The abstract syntax might correspond to various concrete ones, even if they are different in style. That’s why the concrete syntax exists.

The concrete syntax dictates how a C² program MUST be syntacticaly. It is formed by various concrete rules, which, if not followed, cause a syntax error.

C²’s grammar.

Lexer

The lexer is a program which generates a list of Tokens1. It is the first step in C²’s compiler, which goes before the parser, and allows for the parser to use a list of words rather than the whole source directly. You COULD consider the lexer a “crutch” for the parser, or even a part of it.

Further reading of the lexer.

To see what input the lexer accepts, read Lexical information.

Note

The lexer’s source can be found here.

Parser

The parser is a program which generates an AST (Abstract Syntax Tree).

The abstract syntax tree allows the compiler to read the original source, which was only human readable (partially, as we could technically directly compile the source in a text format, although unefficient and too complex), in a friendlier format consisting of a syntactical tree in memory.

Further reading of the parser.

Note

The parser’s source can be found here.


  1. A word, digit or character generated by the lexer and used by the parser to generate the AST. Further reading