leo/parser
gluaxspeed a91c8b9e6a Revert "type on call expression"
This reverts commit cf5a23b38f.
2021-08-18 13:38:50 -07:00
..
benches hacky, but optional comma only allowed on last member variable 2021-04-29 15:22:17 -04:00
examples clippy & test fixes 2021-08-02 23:45:33 +03:00
src Revert "type on call expression" 2021-08-18 13:38:50 -07:00
tests merge master, resolve conflicts, login test is failing 2021-04-26 14:43:21 -04:00
Cargo.toml chore(leo): bump version for new release 2021-07-29 18:59:08 -07:00
README.md parser readme, started ast readme 2021-07-21 01:31:20 -07:00

Leo Parser

Crates.io Authors License

This directory contains the code to tokenize, lex and parse Leo files to the Leo AST.

Tokenizer

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.

Tokens

Bolded ones are also keywords.

Literals

  • CommentLine
  • CommentBlock
  • StringLit
  • Ident
  • Int
  • True
  • False
  • AddressLit
  • CharLit

Symbols

  • 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

Types

  • U8
  • U16
  • U32
  • U64
  • U128
  • I8
  • I16
  • I32
  • I64
  • I128
  • Field
  • Group
  • Bool
  • Address
  • Char
  • BigSelf

Words

  • Input
  • LittleSelf
  • Import
  • As
  • Circuit
  • Console
  • Const
  • Else
  • For
  • Function
  • If
  • In
  • Let
  • Mut
  • Return
  • Static
  • String

Meta

  • Eof

Parser

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.

Grammar Relation

All function and token names are as close as possible to the Leo Grammar