Skip to content

Commit 61398ab

Browse files
committed
py: Implement parse bytecode.
1 parent 5bf649f commit 61398ab

File tree

9 files changed

+4889
-14
lines changed

9 files changed

+4889
-14
lines changed

py/compile2.c

Lines changed: 3343 additions & 0 deletions
Large diffs are not rendered by default.

py/emit.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,12 @@ typedef struct _emit_inline_asm_method_table_t {
270270
void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, scope_t *scope, mp_obj_t *error_slot);
271271
void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig);
272272
mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params);
273+
void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig);
274+
mp_uint_t (*count_params)(emit_inline_asm_t *emit, const byte *p, const byte *ptop);
273275
bool (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id);
274276
void (*align)(emit_inline_asm_t *emit, mp_uint_t align);
275277
void (*data)(emit_inline_asm_t *emit, mp_uint_t bytesize, mp_uint_t val);
276-
void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args);
278+
void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, const byte **pn_args);
277279
} emit_inline_asm_method_table_t;
278280

279281
extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table;

py/grammar.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ DEF_RULE(try_stmt_except_and_more, nc, and(3), rule(try_stmt_except_list), opt_r
180180
DEF_RULE(try_stmt_except, nc, and(4), tok(KW_EXCEPT), opt_rule(try_stmt_as_name), tok(DEL_COLON), rule(suite))
181181
DEF_RULE(try_stmt_as_name, nc, and(2), rule(test), opt_rule(as_name))
182182
DEF_RULE(try_stmt_except_list, nc, one_or_more, rule(try_stmt_except))
183-
DEF_RULE(try_stmt_finally, nc, and(3), tok(KW_FINALLY), tok(DEL_COLON), rule(suite))
183+
DEF_RULE(try_stmt_finally, nc, ident | and(3), tok(KW_FINALLY), tok(DEL_COLON), rule(suite))
184184
DEF_RULE(else_stmt, nc, ident | and(3), tok(KW_ELSE), tok(DEL_COLON), rule(suite))
185185
DEF_RULE(with_stmt, c(with_stmt), and(4), tok(KW_WITH), rule(with_stmt_list), tok(DEL_COLON), rule(suite))
186186
DEF_RULE(with_stmt_list, nc, list, rule(with_item), tok(DEL_COMMA))
@@ -247,8 +247,7 @@ DEF_RULE(power_dbl_star, nc, ident | and(2), tok(OP_DBL_STAR), rule(factor))
247247
// testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
248248
// trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
249249

250-
DEF_RULE(atom, nc, or(11), tok(NAME), tok(INTEGER), tok(FLOAT_OR_IMAG), rule(atom_string), tok(ELLIPSIS), tok(KW_NONE), tok(KW_TRUE), tok(KW_FALSE), rule(atom_paren), rule(atom_bracket), rule(atom_brace))
251-
DEF_RULE(atom_string, c(atom_string), one_or_more, rule(string_or_bytes))
250+
DEF_RULE(atom, nc, or(12), tok(NAME), tok(INTEGER), tok(FLOAT_OR_IMAG), tok(STRING), tok(BYTES), tok(ELLIPSIS), tok(KW_NONE), tok(KW_TRUE), tok(KW_FALSE), rule(atom_paren), rule(atom_bracket), rule(atom_brace))
252251
DEF_RULE(string_or_bytes, nc, or(2), tok(STRING), tok(BYTES))
253252
DEF_RULE(atom_paren, c(atom_paren), and(3), tok(DEL_PAREN_OPEN), opt_rule(atom_2b), tok(DEL_PAREN_CLOSE))
254253
DEF_RULE(atom_2b, nc, or(2), rule(yield_expr), rule(testlist_comp))
@@ -276,7 +275,7 @@ DEF_RULE(subscript_3, c(subscript_3), and(2), tok(DEL_COLON), opt_rule(subscript
276275
DEF_RULE(subscript_3b, nc, or(2), rule(subscript_3c), rule(subscript_3d))
277276
DEF_RULE(subscript_3c, nc, and(2), tok(DEL_COLON), opt_rule(test))
278277
DEF_RULE(subscript_3d, nc, and(2), rule(test), opt_rule(sliceop))
279-
DEF_RULE(sliceop, nc, and(2), tok(DEL_COLON), opt_rule(test))
278+
DEF_RULE(sliceop, nc, ident | and(2), tok(DEL_COLON), opt_rule(test))
280279
#else
281280
DEF_RULE(subscriptlist, c(generic_tuple), list_with_end, rule(test), tok(DEL_COMMA))
282281
#endif

py/parse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#include "py/parse2.h"
2627
#ifndef __MICROPY_INCLUDED_PY_PARSE_H__
2728
#define __MICROPY_INCLUDED_PY_PARSE_H__
2829

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy