Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Franck Pommereau
/
snakes
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Franck Pommereau
2013-03-03 14:27:03 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b470970bb5047b95540d9e8a17ea8205a3fa3ed4
b470970b
1 parent
3acaca45
doc converted
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
snakes/lang/pgen.py
snakes/lang/unparse.py
snakes/plugins/synchro.py
snakes/lang/pgen.py
View file @
b470970
...
...
@@ -41,7 +41,7 @@ class Token (str) :
non-mutable object and this __init__ could not assign a str
content. For more information see:
http://docs.python.org/reference/datamodel.html#object.__new__
http://docs.python.org/reference/datamodel.html#object.__new__
"""
kind
=
token
[
0
]
text
=
token
[
1
]
...
...
@@ -196,10 +196,8 @@ class Tokenizer (object) :
- skip: a collection of tokens that the tokenizer will
automatically skip (default to [COMMENT, NL])
- additional keywords arguments allow to define new tokens,
for instance, providing
DOLLAR='$'
defines a new token called 'DOLLAR' (its kind will be
automatically computed)
for instance, providing DOLLAR='$' defines a new token
called 'DOLLAR' (its kind will be automatically computed)
An instance of Tokenizer has the following attributes:
- self.opmap: a dict mapping operators token literals to the
...
...
snakes/lang/unparse.py
View file @
b470970
...
...
@@ -17,13 +17,16 @@ def interleave(inter, f, seq):
f
(
x
)
class
Unparser
:
"""Methods in this class recursively traverse an AST and
output source code for the abstract syntax; original formatting
is disregarged. """
"""Methods in this class recursively traverse an AST and output
source code for the abstract syntax; original formatting is
disregarged.
"""
def
__init__
(
self
,
tree
,
file
=
sys
.
stdout
):
"""Unparser(tree, file=sys.stdout) -> None.
Print the source for tree to file."""
Print the source for tree to file.
"""
self
.
f
=
file
self
.
_indent
=
0
self
.
dispatch
(
tree
)
...
...
@@ -31,7 +34,9 @@ class Unparser:
self
.
f
.
flush
()
def
fill
(
self
,
text
=
""
):
"Indent a piece of text, according to the current indentation level"
"""Indent a piece of text, according to the current indentation
level
"""
self
.
f
.
write
(
"
\n
"
+
" "
*
self
.
_indent
+
text
)
def
write
(
self
,
text
):
...
...
snakes/plugins/synchro.py
View file @
b470970
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment