Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken file is Broken #4

Closed
kajuberdut opened this issue Apr 5, 2017 · 2 comments
Closed

Broken file is Broken #4

kajuberdut opened this issue Apr 5, 2017 · 2 comments

Comments

@kajuberdut
Copy link
Contributor

kajuberdut commented Apr 5, 2017

Using notepad to create a new text file on Windows causes errors when running thinkgraph on said file.

Example:
break.txt

C:\Users\pshec\Downloads\thinkgraph-master>thinkgraph break.txt
Traceback (most recent call last):
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 213, in parse
result = rule()
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 61, in wrapper
return self._call(rule, name, params, kwparams)
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 469, in _call
node, newpos, newstate = self._invoke_rule(rule, name, params, kwparams)
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 509, in _invoke_rule
rule(self)
File "c:\users\pshec\anaconda3\lib\site-packages\thinkgraph\parser.py", line 69, in statements
self._check_eof()
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 649, in _check_eof
self._error('Expecting end of text.')
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 444, in _error
item
grako.exceptions.FailedParse: (6:1) Expecting end of text. :
2 => 3
^
statements

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\pshec\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\users\pshec\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\pshec\Anaconda3\Scripts\thinkgraph.exe_main
.py", line 9, in
File "c:\users\pshec\anaconda3\lib\site-packages\thinkgraph\graph.py", line 70, in main
ast = p.parse(f.read(), rule_name="statements", semantics = semantic_graph)
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 221, in parse
raise self._furthest_exception
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 469, in _call
node, newpos, newstate = self._invoke_rule(rule, name, params, kwparams)
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 509, in _invoke_rule
rule(self)
File "c:\users\pshec\anaconda3\lib\site-packages\thinkgraph\parser.py", line 150, in NEWLINE
self._pattern(r'\n')
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 634, in _pattern
self._error(pattern, etype=FailedPattern)
File "c:\users\pshec\anaconda3\lib\site-packages\grako\contexts.py", line 444, in _error
item
grako.exceptions.FailedPattern: (6:1) expecting '\n' :

^
NEWLINE
loop
statements

@ryanfreckleton
Copy link
Owner

It appears to be related to windows line endings, I'm not sure exactly how to fix this, probably something to do with how grako is configured. I would've hoped that it would use the universal new line feature of Python's regexes, but apparently not.

@ryanfreckleton
Copy link
Owner

Well, a simple regex fix fixes it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants