Skip to content

Commit 6196795

Browse files
authored
Update broken links to source code.
1 parent 06d3de3 commit 6196795

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

_posts/2020-03-12-thing-explainer-parser.markdown

+5-8
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ date: 2020-04-02 11:34:01 -0400
55
redirect_from: /2020/04/02/thing-explainer-parser.html
66
---
77

8-
This post goes over the RustPython parser. You can see the source code at [RustPython/parser/](https://github.com/RustPython/RustPython/tree/master/parser).
8+
This post goes over the RustPython parser. You can see the source code in the [rustpython-parser](https://github.com/RustPython/RustPython/tree/main/compiler/parser) crate.
99

1010
When you write code in Python and run it, an interpreter, such as the RustPython interpreter, acts as the translator between you and your machine.
1111

12-
The interpreter has the job of turning your human code into bytecode that a Python virtual machine can run. Bytecode is an intermediate code between source code and machine code. This makes it portable across multiple hardware and operating systems. Bytecode "works" as long as you implement a virtual machine (vm) that can run it. There is a performance penalty for this flexibility. RustPython has a vm under [RustPython/vm/](https://github.com/RustPython/RustPython/tree/master/vm). Other posts will go into the details of that vm but now let's figure out how to turn code into bytecode.
12+
The interpreter has the job of turning your human code into bytecode that a Python virtual machine can run. Bytecode is an intermediate code between source code and machine code. This makes it portable across multiple hardware and operating systems. Bytecode "works" as long as you implement a virtual machine (vm) that can run it. There is a performance penalty for this flexibility. RustPython also [has a vm](https://github.com/RustPython/RustPython/tree/main/vm) that interprets the generated bytecode, other posts will go into the details of that vm but now let's figure out how to turn code into bytecode.
1313

1414

1515
## What bytecode looks like
@@ -54,10 +54,7 @@ If you want to sound fancy:
5454
- The parsing process is called "lexical analysis"
5555
- The thing that does this is a "lexer"
5656

57-
Here is the link to the RustPython lexer.
58-
59-
**`RustPython/parser/lexer.rs`** >>
60-
[source code](https://github.com/RustPython/RustPython/blob/master/parser/src/lexer.rs)
57+
The code for the lexing stage lives in [lex.rs](https://github.com/RustPython/RustPython/blob/main/compiler/parser/src/lexer.rs) of the parser crate.
6158

6259

6360
If you want to dive into the details of lexical analysis, check out [Python in a nutshell / Lexical structure](https://learning.oreilly.com/library/view/python-in-a/9781491913833/ch03.html#python_language-id00003)
@@ -76,7 +73,7 @@ As the presenter puts it, this is the spirit of the beast (Python) and it is onl
7673

7774
So, we have the rules or grammar of a programming language in a machine encoded format... now we need to write something that verifies that those rules were followed... This sounds like something that other people could use and like something that should exist as an open source project! 🤔
7875

79-
Sure enough, there is a whole Rust framework called `LALRPOP`. It takes the tokens generated by the lexer, verifies the syntax and turns the tokens into an AST (Abstract Syntax Tree). More information and a tutorial can be found in the [LALRPOP book](https://lalrpop.github.io/lalrpop/README.html).
76+
Sure enough, there is a whole Rust framework called `LALRPOP`. It takes the tokens generated by the lexer, verifies the syntax and turns the tokens into an AST (Abstract Syntax Tree). More information and a tutorial can be found in the [LALRPOP book](https://lalrpop.github.io/lalrpop/index.html).
8077

8178
RustPython does one nice extra thing on top of `LALRPOP`. It masks the errors and provides you with safer, nicer errors. You can see the code for this in `RustPython/parser/src/error.rs`
8279

@@ -101,4 +98,4 @@ As a recap, when you write a line of Python code and "run it", here is what the
10198
⬇️ compile the AST into bytecode
10299
**OUTPUT: bytecode** (in `__pycache__/file.pyc` or in memory)
103100

104-
The compiler is under **`RustPython/compiler`**. Keep an eye on the blog for a future post about the details or the compiler. In the meantime, check out the parser source code in [RustPython/parser/](https://github.com/RustPython/RustPython/tree/master/parser).
101+
The compiler is located in the [rustpython-compiler](https://github.com/RustPython/RustPython/tree/main/compiler) crate. Keep an eye on the blog for a future post about the details or the compiler. In the meantime, check out the parser source code in [rustpython-parser](https://github.com/RustPython/RustPython/tree/main/compiler/parser).

0 commit comments

Comments
 (0)