Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
badw-it
DHParser
Commits
1c42afde
Commit
1c42afde
authored
Apr 21, 2018
by
eckhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- syntaxtree: indentation level of xml and S-Expression representation now configurable
parent
3318d807
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
DHParser/syntaxtree.py
DHParser/syntaxtree.py
+6
-6
No files found.
DHParser/syntaxtree.py
View file @
1c42afde
...
...
@@ -508,7 +508,8 @@ class Node(collections.abc.Sized):
return
head
+
'
\n
'
.
join
([
tab
+
data_fn
(
s
)
for
s
in
res
.
split
(
'
\n
'
)])
+
tail
def
as_sxpr
(
self
,
src
:
str
=
None
,
compact
:
bool
=
False
,
showerrors
:
bool
=
True
)
->
str
:
def
as_sxpr
(
self
,
src
:
str
=
None
,
compact
:
bool
=
False
,
showerrors
:
bool
=
True
,
indentation
:
int
=
2
)
->
str
:
"""
Returns content as S-expression, i.e. in lisp-like form.
...
...
@@ -548,10 +549,10 @@ class Node(collections.abc.Sized):
else
"'%s'"
%
strg
if
strg
.
find
(
"'"
)
<
0
\
else
'"%s"'
%
strg
.
replace
(
'"'
,
r
'\"'
)
return
self
.
_tree_repr
(
'
'
,
opening
,
closing
,
pretty
,
density
=
density
)
return
self
.
_tree_repr
(
'
'
*
indentation
,
opening
,
closing
,
pretty
,
density
=
density
)
def
as_xml
(
self
,
src
:
str
=
None
,
showerrors
:
bool
=
True
)
->
str
:
def
as_xml
(
self
,
src
:
str
=
None
,
showerrors
:
bool
=
True
,
indentation
:
int
=
2
)
->
str
:
"""
Returns content as XML-tree.
...
...
@@ -580,7 +581,7 @@ class Node(collections.abc.Sized):
return
'
\n
</'
+
node
.
tag_name
+
'>'
line_breaks
=
linebreaks
(
src
)
if
src
else
[]
return
self
.
_tree_repr
(
'
'
,
opening
,
closing
,
density
=
1
)
return
self
.
_tree_repr
(
'
'
*
indentation
,
opening
,
closing
,
density
=
1
)
def
select
(
self
,
match_function
:
Callable
,
include_root
:
bool
=
True
)
->
Iterator
[
'Node'
]:
...
...
@@ -666,7 +667,7 @@ class Node(collections.abc.Sized):
class
RootNode
(
Node
):
"""
"""
TODO: Add Documentation!!!
errors (list): A list of all errors that have occured so far during
processing (i.e. parsing, AST-transformation, compiling)
...
...
@@ -740,7 +741,6 @@ class RootNode(Node):
self
.
add_error
(
node
,
error
)
return
self
def
collect_errors
(
self
)
->
List
[
Error
]:
"""Returns the list of errors, ordered bv their position.
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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