Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
4487dd55
Commit
4487dd55
authored
Feb 23, 2017
by
di68kap
Browse files
- Bugfix: add 'encoding="utf-8"' in all open()-statements to ensure Windows-compatibility
parent
5b548dc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
ParserCombinators.py
View file @
4487dd55
...
...
@@ -82,7 +82,7 @@ def DEBUG_DUMP_SYNTAX_TREE(parser_root, syntax_tree, compiler, ext):
prefix
=
"DEBUG"
ast_file_name
=
(
DEBUG_DUMP_AST
or
compiler
.
grammar_name
or
\
parser_root
.
__class__
.
__name__
)
+
ext
with
open
(
os
.
path
.
join
(
prefix
,
ast_file_name
),
"w"
)
as
f
:
with
open
(
os
.
path
.
join
(
prefix
,
ast_file_name
),
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
syntax_tree
.
as_sexpr
())
...
...
@@ -1232,7 +1232,7 @@ def load_if_file(text_or_file):
a multiline string) returns the content of `text_or_file`.
"""
if
text_or_file
and
text_or_file
.
find
(
'
\n
'
)
<
0
:
with
open
(
text_or_file
)
as
f
:
with
open
(
text_or_file
,
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
return
content
else
:
...
...
@@ -1722,7 +1722,7 @@ def self_test():
DELIMITER
=
"
\n\n
### DON'T EDIT OR REMOVE THIS LINE ###
\n\n
"
try
:
f
=
open
(
rootname
+
'_compiler.py'
,
'r'
)
f
=
open
(
rootname
+
'_compiler.py'
,
'r'
,
encoding
=
"utf-8"
)
source
=
f
.
read
()
scanner
,
parser
,
ast
,
compiler
=
source
.
split
(
DELIMITER
)
except
(
PermissionError
,
FileNotFoundError
,
IOError
)
as
error
:
...
...
@@ -1733,7 +1733,7 @@ def self_test():
if
f
:
f
.
close
()
try
:
f
=
open
(
rootname
+
'_compiler.py'
,
'w'
)
f
=
open
(
rootname
+
'_compiler.py'
,
'w'
,
encoding
=
"utf-8"
)
f
.
write
(
scanner
)
f
.
write
(
DELIMITER
)
f
.
write
(
result
)
...
...
@@ -1760,7 +1760,7 @@ def self_test():
def
test
(
file_name
):
print
(
file_name
)
with
open
(
'examples/'
+
file_name
)
as
f
:
with
open
(
'examples/'
+
file_name
,
encoding
=
"utf-8"
)
as
f
:
grammar
=
f
.
read
()
compiler_name
=
os
.
path
.
basename
(
os
.
path
.
splitext
(
file_name
)[
0
])
compiler
=
EBNFCompiler
(
compiler_name
,
grammar
)
...
...
TODO.txt
View file @
4487dd55
* finally split ParserCombinators.py into different modules, like:
SyntaxTree, ErrorMessages, ParserCombinators, ASTTransform, EBNFCompiler, DSLCompiler
\ No newline at end of file
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