-
Notifications
You must be signed in to change notification settings - Fork 0
Rewrite exported function #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,12 @@ enum INPUT_MODE { | |
| }; | ||
| typedef enum INPUT_MODE INPUT_MODE; | ||
|
|
||
| enum START_RULE { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this enum of only one field? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll probably add more, we we need to choose between start rules. I'm currently working on maybe changing the start rule for f-string to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Probably for a separate PR.) Maybe we could pass a string literal instead? By convention we could have which would generate a little table at the end and then the dispatch function could just look up the argument in the table. (This is a negligible cost given everything else that goes into parsing even one line.) [1] We'd need to add a few new rules named |
||
| START, | ||
| EXPRESSIONS | ||
| }; | ||
| typedef enum START_RULE START_RULE; | ||
|
|
||
| typedef struct _memo { | ||
| int type; | ||
| void *node; | ||
|
|
@@ -41,7 +47,7 @@ typedef struct { | |
| PyArena *arena; | ||
| KeywordToken **keywords; | ||
| int n_keyword_lists; | ||
| void *start_rule_func; | ||
| START_RULE start_rule_func; | ||
| INPUT_MODE input_mode; | ||
| jmp_buf error_env; | ||
| } Parser; | ||
|
|
@@ -81,9 +87,6 @@ typedef struct { | |
| int is_keyword; | ||
| } KeywordOrStarred; | ||
|
|
||
| extern const int n_keyword_lists; | ||
| extern KeywordToken *reserved_keywords[]; | ||
|
|
||
| int insert_memo(Parser *p, int mark, int type, void *node); | ||
| int update_memo(Parser *p, int mark, int type, void *node); | ||
| int is_memoized(Parser *p, int type, void *pres); | ||
|
|
@@ -136,8 +139,10 @@ CHECK_CALL_NULL_ALLOWED(Parser *p, void *result) | |
| #define CHECK_NULL_ALLOWED(result) CHECK_CALL_NULL_ALLOWED(p, result) | ||
|
|
||
| PyObject *new_identifier(Parser *, char *); | ||
| mod_ty run_parser_from_file(const char *, mod_ty(*)(Parser *), PyObject *, PyArena *); | ||
| mod_ty run_parser_from_string(const char *, mod_ty(*)(Parser *), PyObject *, PyArena *); | ||
| Parser *Parser_New(struct tok_state *, START_RULE, int, PyArena *); | ||
| void Parser_Free(Parser *); | ||
| mod_ty run_parser_from_file(const char *, START_RULE, PyObject *, PyArena *); | ||
| mod_ty run_parser_from_string(const char *, START_RULE, PyObject *, PyArena *); | ||
| asdl_seq *singleton_seq(Parser *, void *); | ||
| asdl_seq *seq_insert_in_front(Parser *, void *, asdl_seq *); | ||
| asdl_seq *seq_flatten(Parser *, asdl_seq *); | ||
|
|
@@ -166,6 +171,6 @@ asdl_seq *seq_extract_starred_exprs(Parser *, asdl_seq *); | |
| asdl_seq *seq_delete_starred_exprs(Parser *, asdl_seq *); | ||
| expr_ty concatenate_strings(Parser *p, asdl_seq *); | ||
|
|
||
| mod_ty parse_start(Parser *); | ||
| void *parse(Parser *); | ||
|
|
||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.