New ARTIQ compiler, third iteration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sebastien Bourdeauducq f66ca02b2d update Rust dependencies 4 months ago
src fix warnings 8 months ago
Cargo.toml update Rust dependencies 4 months ago integrate nac3parser 1 year ago add RustPython parser 1 year ago


This directory has the code for python lexing, parsing and generating Abstract Syntax Trees (AST).

This is the RustPython parser with modifications for NAC3.

The steps are:

  • Lexical analysis: splits the source code into tokens.
  • Parsing and generating the AST: transforms those tokens into an AST. Uses LALRPOP, a Rust parser generator framework.

The RustPython team wrote a blog post with screenshots and an explanation to help you understand the steps by seeing them in action.

For more information on LALRPOP, here is a link to the LALRPOP book.

There is a readme in the src folder with the details of each file.

Directory content The build script. Cargo.toml: The config file.

The src directory has:
This is the crate's root.
This module takes care of lexing python source text. This means source code is translated into separate tokens.
A python parsing module. Use this module to parse python code into an AST. There are three ways to parse python code. You could parse a whole program, a single statement, or a single expression.
Implements abstract syntax tree (AST) nodes for the python language. Roughly equivalent to the python AST.

Python grammar.
Different token definitions. Loosely based on token.h from CPython source.
Define internal parse error types. The goal is to provide a matching and a safe error API, masking errors from LALR.
Format strings.
Collection of functions for parsing parameters, arguments.
Datatypes to support source location information.
Execution mode check. Allowed modes are exec, eval or single.