Files
RustPython/parser
Mireille Raad 4b506c2fee Adding readme under parser and parser/src
Adding readme files under parser and parser/src to make it faster to figure out the files and what each does.
2020-03-22 19:59:20 -04:00
..
2020-01-27 08:35:58 -05:00

RustPython/parser

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

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.

This crate is published on https://docs.rs/rustpython-parser.

We 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.

How to use

For example, one could do this:

  use rustpython_parser::{parser, ast};
  let python_source = "print('Hello world')";
  let python_ast = parser::parse_expression(python_source).unwrap();