@@ -16,34 +16,25 @@ npm run start:dev # Add `-- <file.py>` to run a file
1616
1717### Consuming the API and generating an estree AST
1818``` javascript
19- import {Tokenizer , Parser , Resolver , Translator } from ' py-slang' ;
19+ import {parsePythonToEstreeAst } from ' py-slang' ;
2020
2121// Sample Python code
2222const text = `
23- (lambda a:display (a))("Hello World!")
23+ (lambda a: print (a))("Hello World!")
2424` ;
25- // Add a new line because Python scripts need to end with a blank newline.
26- text += ' \n ' ;
27- // Scan the text.
28- const tokenizer = new Tokenizer (text);
29- const tokens = tokenizer .scanEverything ();
30- // If you want to view the tokens, you can.
31- // tokenizer.printTokens();
32-
33- // Parse the tokens.
34- const parser = new Parser (text, tokens);
35- const ast = parser .parse ();
36-
37- // Validate and resolve symbols in namespaces.
38- // This step may throw false errors.
39- // This is when we detect variable declarations
40- // and hoist them out of blocks.
41- const resolver = new Resolver (text, ast);
42- resolver .resolve (ast);
43-
44- // Finally, translate the AST to estree AST.
45- const translator = new Translator (text);
46- const estreeAst = translator .resolve (ast);
25+ // Arguments:
26+ // Code to translate
27+ // SICPy chapter number
28+ // Whether to validate the code using a resolver.
29+ console .dir (parsePythonToEstreeAst (text, 1 , false ));
30+ ```
31+
32+ ### Running the test suite
33+
34+ Ensure that all tests pass before committing.
35+
36+ ``` shell
37+ npm run test
4738```
4839
4940### Regenerating the AST types
0 commit comments