From: Stefan Behnel Date: Tue, 16 Nov 2010 20:54:46 +0000 (+0100) Subject: more cythonisation in the scanner/parser X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=698b502d4c5aee7a80dd4b83cc7463ef6141747c;p=cython.git more cythonisation in the scanner/parser --- diff --git a/Cython/Compiler/Parsing.pxd b/Cython/Compiler/Parsing.pxd index 1e39a34a..486f758f 100644 --- a/Cython/Compiler/Parsing.pxd +++ b/Cython/Compiler/Parsing.pxd @@ -68,7 +68,7 @@ cdef p_comp_if(PyrexScanner s, body) cdef p_dict_or_set_maker(PyrexScanner s) cdef p_backquote_expr(PyrexScanner s) cpdef p_simple_expr_list(PyrexScanner s, expr=*) -cdef p_test_or_starred_expr_list(s, expr=*) +cdef p_test_or_starred_expr_list(PyrexScanner s, expr=*) cdef p_testlist(PyrexScanner s) cdef p_testlist_star_expr(PyrexScanner s) cdef p_testlist_comp(PyrexScanner s) @@ -111,6 +111,7 @@ cdef p_try_statement(PyrexScanner s) cdef p_except_clause(PyrexScanner s) cdef p_include_statement(PyrexScanner s, ctx) cdef p_with_statement(PyrexScanner s) +cdef p_with_items(PyrexScanner s) cpdef p_simple_statement(PyrexScanner s, bint first_statement = *) cpdef p_simple_statement_list(PyrexScanner s, ctx, bint first_statement = *) cdef p_compile_time_expr(PyrexScanner s) diff --git a/Cython/Compiler/Scanning.pxd b/Cython/Compiler/Scanning.pxd index abcc5eea..b560c1ec 100644 --- a/Cython/Compiler/Scanning.pxd +++ b/Cython/Compiler/Scanning.pxd @@ -2,14 +2,21 @@ import cython from Cython.Plex.Scanners cimport Scanner +cdef class Method: + cdef object name + cdef object __name__ + cdef class CompileTimeScope: - cdef public entries - cdef public outer + cdef public dict entries + cdef public CompileTimeScope outer + cdef declare(self, name, value) + cdef lookup_here(self, name) + cpdef lookup(self, name) cdef class PyrexScanner(Scanner): cdef public context cdef public list included_files - cdef public compile_time_env + cdef public CompileTimeScope compile_time_env cdef public bint compile_time_eval cdef public bint compile_time_expr cdef public bint parse_comments @@ -23,9 +30,23 @@ cdef class PyrexScanner(Scanner): cdef public systring cdef long current_level(self) - cpdef begin(self, state) - cpdef next(self) - cpdef bint expect(self, what, message = *) except -2 - + #cpdef commentline(self, text) + #cpdef open_bracket_action(self, text) + #cpdef close_bracket_action(self, text) + #cpdef newline_action(self, text) + #cpdef begin_string_action(self, text) + #cpdef end_string_action(self, text) + #cpdef unclosed_string_action(self, text) @cython.locals(current_level=cython.long, new_level=cython.long) cpdef indentation_action(self, text) + #cpdef eof_action(self, text) + cdef next(self) + cdef peek(self) + #cpdef put_back(self, sy, systring) + #cdef unread(self, token, value) + cdef bint expect(self, what, message = *) except -2 + cdef expect_keyword(self, what, message = *) + cdef expected(self, what, message = *) + cdef expect_indent(self) + cdef expect_dedent(self) + cdef expect_newline(self, message = *) diff --git a/Cython/Plex/Scanners.pxd b/Cython/Plex/Scanners.pxd index 4ecdba68..c746cc5a 100644 --- a/Cython/Plex/Scanners.pxd +++ b/Cython/Plex/Scanners.pxd @@ -25,10 +25,10 @@ cdef class Scanner: cdef public level @cython.locals(input_state=long) - cpdef next_char(self) - cpdef tuple read(self) + cdef next_char(self) + cdef tuple read(self) cdef tuple scan_a_token(self) - cpdef tuple position(self) + cdef tuple position(self) @cython.locals(cur_pos=long, cur_line=long, cur_line_start=long, input_state=long, next_pos=long, state=dict, @@ -36,5 +36,5 @@ cdef class Scanner: trace=bint, discard=long, data=unicode, buffer=unicode) cdef run_machine_inlined(self) - cpdef begin(self, state) - cpdef produce(self, value, text = *) + cdef begin(self, state) + cdef produce(self, value, text = *)