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

Lexer crash on ...>=(...)... #170

Open
fenollp opened this issue Dec 21, 2020 · 1 comment
Open

Lexer crash on ...>=(...)... #170

fenollp opened this issue Dec 21, 2020 · 1 comment

Comments

@fenollp
Copy link

fenollp commented Dec 21, 2020

% fcn.m
function [B] = fcn(A)
  B = A>=(A)
end

smop fcn.m

Traceback (most recent call last):
  File "/home/pete/.local/lib/python3.5/site-packages/smop/main.py", line 65, in main
    stmt_list = parse.parse(buf if buf[-1] == '\n' else buf + '\n')
  File "/home/pete/.local/lib/python3.5/site-packages/smop/parse.py", line 850, in parse
    buf, tracking=1, debug=options.debug_parser, lexer=new_lexer)
  File "/home/pete/.local/lib/python3.5/site-packages/ply/yacc.py", line 331, in parse
    return self.parseopt(input, lexer, debug, tracking, tokenfunc)
  File "/home/pete/.local/lib/python3.5/site-packages/ply/yacc.py", line 909, in parseopt
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/home/pete/.local/lib/python3.5/site-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "/home/pete/.local/lib/python3.5/site-packages/smop/parse.py", line 838, in p_error
    new_lexer)
  File "/home/pete/.local/lib/python3.5/site-packages/smop/lexer.py", line 338, in raise_exception
    my_lexer.lexdata[startpos:endpos]))
  File "fcn.m", line 2
    B = A>=(A)
           ^
SyntaxError: Unexpected "=" (parser)

Note: crash is flaky. Sometimes compilation passes and generates:

# Generated with SMOP  0.41-beta
from libsmop import *
# fcn.m


@function
def fcn(A=None,*args,**kwargs):
    varargin = fcn.varargin
    nargin = fcn.nargin

    B=A >= (A)
# fcn.m:2
    return B

if __name__ == '__main__':
    pass

Workaround: try compilation multiple times. Looks like it works 1 in 10 times 100% of the times :)

@amole-arup
Copy link

Having similar problem. Will try your work-around:

File "dloslab.m", line 179

[r b]= deal(var(1,:)'>=delta*varmax & YL(:,5)~=2, var(1,:)'<=-delta*varmax & YL(:,5)~=2);
SyntaxError: Unexpected "=" (parser)
Errors: 1

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