Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
90c4dcc5
Commit
90c4dcc5
authored
Jan 22, 2019
by
Eckhart Arnold
Browse files
more cython support
parent
d65ff898
Changes
4
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
90c4dcc5
...
...
@@ -45,4 +45,5 @@ _static
_templates
.vs
OLDSTUFF
.pytest_cache
\ No newline at end of file
.pytest_cache
*.c
\ No newline at end of file
DHParser/parse.pxd
0 → 100644
View file @
90c4dcc5
#cython: infer_types=True
#cython: language_level=3
#cython: c_string_type=unicode
#cython: c_string_encoding=utf-8
import
cython
from
DHParser
cimport
syntaxtree
# cdef class ParserError(Exception):
# cdef bint first_throw
# cdef add_parser_guard(parser_func)
# cdef class Parser(syntaxtree.ParserBase):
# pass
# cdef class Grammar:
# cdef bint dirty_flag__
# cdef bint history_tracking__
# cdef bint memoization__
# cdef bint left_recursion_handling__
# cdef int document_length__
# cdef int last_rb__loc__
# cdef bint moving_forward__
# cdef class PreprocessorToken(Parser):
# pass
#
# cdef class Token(Parser):
# cdef int len
#
# cdef class RegExp(Parser):
# pass
#
# cdef class Whitespace(RegExp):
# pass
#
# cdef class UnaryOperator(Parser):
# pass
#
# cdef class NaryOperator(Parser):
# pass
#
# cdef class Option(UnaryOperator):
# pass
#
# cdef class ZeroOrMore(Option):
# pass
#
# cdef class OneOrMore(UnaryOperator):
# pass
#
# cdef class Series(NaryOperator):
# cdef int mandatory
#
# cdef class Alternative(NaryOperator):
# pass
#
# cdef class SomeOf(NaryOperator):
# pass
#
# cdef class AllOf(NaryOperator):
# cdef int mandatory
# cdef int num_parsers
#
# cdef class FlowOperator(UnaryOperator):
# pass
#
# # cdef class Required(FlowOperator):
# # pass
#
# cdef class Lookahead(FlowOperator):
# pass
#
# cdef class NegativeLookahead(Lookahead):
# pass
#
# cdef class Lookbehind(FlowOperator):
# pass
#
# cdef class NegativeLookbehind(Lookbehind):
# pass
#
# cdef class Capture(UnaryOperator):
# pass
#
# cdef class Retrieve(Parser):
# pass
#
# cdef class Pop(Retrieve):
# pass
#
# cdef class Synonym(UnaryOperator):
# pass
#
# cdef class Forward(Parser):
# pass
DHParser/syntaxtree.pxd
0 → 100644
View file @
90c4dcc5
#cython: infer_types=True
#cython: language_level=3
#cython: c_string_type=unicode
#cython: c_string_encoding=utf-8
import
cython
# cdef class ParserBase:
# cdef str name
# cdef str ptype
# cdef class MockParser(ParserBase):
# pass
# cdef class ZombieParser(MockParser):
# pass
# cdef class Node:
# cdef int _pos
# cdef int _len
# cdef class RootNode(Node):
# pass
DHParser/transform.pxd
0 → 100644
View file @
90c4dcc5
#cython: infer_types=True
#cython: language_level=3
#cython: c_string_type=unicode
#cython: c_string_encoding=utf-8
import
cython
# any functions that causes trouble with cython has been commented out!
# cpdef transformation_factory(t1=?, t2=?, t3=?, t4=?, t5=?)
# cpdef type_guard(t)
# cpdef decorator(f)
# cpdef gen_special(*args)
# cpdef gen_partial(*args, **kwargs)
cpdef
key_parser_name
(
node
:
Node
)
cpdef
key_tag_name
(
node
:
Node
)
# cpdef traverse(root_node: Node, processing_table: ProcessingTableType,
# key_func: KeyFunc = ?)
# cpdef traverse_recursive(context)
# cpdef traverse_locally(context: List[Node], processing_table: Dict,
# key_func: Callable = ?)
# cpdef apply_if(context: List[Node], transformation: Callable,
# condition: Callable)
# cpdef apply_unless(context: List[Node], transformation: Callable,
# condition: Callable)
cpdef
is_single_child
(
context
:
List
[
Node
])
cpdef
is_named
(
context
:
List
[
Node
])
cpdef
is_anonymous
(
context
:
List
[
Node
])
cpdef
is_whitespace
(
context
:
List
[
Node
])
cpdef
is_empty
(
context
:
List
[
Node
])
cpdef
is_expendable
(
context
:
List
[
Node
])
# cpdef is_token(context: List[Node], tokens: AbstractSet[str] = ?)
# cpdef is_one_of(context: List[Node], tag_name_set: AbstractSet[str])
# cpdef not_one_of(context: List[Node], tag_name_set: AbstractSet[str])
# cpdef matches_re(context: List[Node], patterns: AbstractSet[str])
# cpdef has_content(context: List[Node], regexp: str)
# cpdef has_parent(context: List[Node], tag_name_set: AbstractSet[str])
cpdef
_replace_by
(
node
:
Node
,
child
:
Node
)
cpdef
_reduce_child
(
node
:
Node
,
child
:
Node
)
cpdef
replace_by_single_child
(
context
:
List
[
Node
])
cpdef
reduce_single_child
(
context
:
List
[
Node
])
# cpdef replace_or_reduce(context: List[Node], condition: Callable = ?)
# cpdef replace_parser(context: List[Node], name: str)
# cpdef flatten(context: List[Node], condition: Callable = ?,
# recursive: bool = ?)
cpdef
collapse
(
context
:
List
[
Node
])
# cpdef collapse_if(context: List[Node], condition: Callable,
# target_tag: ParserBase)
# cpdef close_package()
# cpdef replace_content(context: List[Node], func: Callable)
# cpdef replace_content_by(context: List[Node], content: str)
cpdef
normalize_whitespace
(
context
)
# cpdef merge_whitespace(context)
cpdef
move_whitespace
(
context
)
## cpdef lstrip(context: List[Node], condition: Callable = ?)
## cpdef rstrip(context: List[Node], condition: Callable = ?)
## cpdef strip(context: List[Node], condition: Callable = ?)
# cpdef keep_children(context: List[Node], section: slice)
# cpdef keep_children_if(context: List[Node], condition: Callable)
# cpdef keep_tokens(context: List[Node], tokens: AbstractSet[str] = ?)
# cpdef keep_nodes(context: List[Node], tag_names: AbstractSet[str])
# cpdef keep_content(context: List[Node], regexp: str)
# cpdef remove_children_if(context: List[Node], condition: Callable)
cpdef
remove_first
(
context
:
List
[
Node
])
cpdef
remove_last
(
context
:
List
[
Node
])
cpdef
remove_brackets
(
context
:
List
[
Node
])
# cpdef remove_tokens(context: List[Node], tokens: AbstractSet[str] = ?)
# cpdef remove_nodes(context: List[Node], tag_names: AbstractSet[str])
# cpdef remove_content(context: List[Node], regexp: str)
# cpdef error_on(context: List[Node], condition: Callable,
# error_msg: str, error_code: ErrorCode)
# cpdef assert_content(context: List[Node], regexp: str)
# cpdef require(context: List[Node], child_tags: AbstractSet[str])
# cpdef forbid(context: List[Node], child_tags: AbstractSet[str])
cpdef
peek
(
context
:
List
[
Node
])
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment