This directory contains the code to tokenize, lex and parse Leo files to the Leo AST.
The tokenizer contains all tokens in Leo. It also decides which tokens are keywords. Meaning that keywords are a subset of tokens. The lexer goes through character by character as bytes, and converts the bytes into the tokens.
Bolded ones are also keywords.
- CommentLine
- CommentBlock
- StringLit
- Ident
- Int
- True
- False
- AddressLit
- CharLit
- At
- Not
- And
- Or
- Eq
- NotEq
- Lt
- LtEq
- Gt
- GtEq
- Add
- Minus
- Mul
- Div
- Exp
- Assign
- AddEq
- MinusEq
- MulEq
- DivEq
- ExpEq
- LeftParen
- RightParen
- LeftSquare
- RightSquare
- LeftCurly
- RightCurly
- Comma
- Dot
- DotDot
- DotDotDot
- Semicolon
- Colon
- DoubleColon
- Question
- Arrow
- Underscore
- U8
- U16
- U32
- U64
- U128
- I8
- I16
- I32
- I64
- I128
- Field
- Group
- Bool
- Address
- Char
- BigSelf
- Input
- LittleSelf
- Import
- As
- Circuit
- Console
- Const
- Else
- For
- Function
- If
- In
- Let
- Mut
- Return
- Static
- String
- Eof
The parser converts the tokens to the Leo AST.
The parser is broken down to different files that correspond to different aspects of the AST:
-
File - Parses the top level nodes in Leo.
-
Types - Parses the type declarations in Leo.
-
Statements - Parses the different kinds of statements.
-
Expressions - Parses the different kinds of expressions.
For more information on those please read the Leo AST README, linked above.
All function and token names are as close as possible to the Leo Grammar