Core C++

1. Lexer and grammar🔗

Core C++ has an LL(1) grammar over tokens. Three lexical and syntactic conventions remove the ambiguities of C++.

Type identifiers start with an uppercase letter and variable identifiers with a lowercase letter or _. The lexer classifies an identifier by its initial, and the parser uses the class to tell whether < opens a template argument or compares. Template instantiation occurs only in type position. Methods are defined inside the class.

The lexer is a hand written finite automaton with the longest match rule, and the parser is recursive descent.

  1. 1.1. Lexer
  2. 1.2. Grammar
  3. 1.3. Abstract syntax and parser
  4. 1.4. Preprocessor