victorlei / smop

Small Matlab to Python compiler
MIT License
1.08k stars 409 forks source link

SyntaxError: Unexpected ";" (parser) #154

Open Light-- opened 4 years ago

Light-- commented 4 years ago

i tried smop to covert my matlab code, but get many warnings and errors......

C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\lex.py:760: FutureWarning: Possible nested set at position 65
  c = re.compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags)
C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\lex.py:498: FutureWarning: Possible nested set at position 118
  lexre = re.compile(regex, reflags)
Traceback (most recent call last):
  File "C:/user1/smop/smop/main.py", line 68, in main
    stmt_list = parse.parse(buf if buf[-1] == '\n' else buf + '\n')
  File "C:\user1\smop\smop\parse.py", line 852, in parse
    p = parser.parse(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\yacc.py", line 331, in parse
    return self.parseopt(input, lexer, debug, tracking, tokenfunc)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\yacc.py", line 909, in parseopt
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "C:\user1\smop\smop\parse.py", line 839, in p_error
    raise_exception(SyntaxError,
  File "C:\user1\smop\smop\lexer.py", line 335, in raise_exception
    raise error_type(message, (options.filename,
  File "..\..\matlab\cData_run.m", line 10
    close all;
    ^
SyntaxError: Unexpected ";" (parser)
Errors: 1

my matlab code is like:

function cData_run
    close all;
    getrandparamsfunc = @getrandparamwithmotiontype6;
    outdir = '../out/mat_double';
    totalnTrainSamples = 60000;
    split_size = 50;   
.....
hzy258 commented 3 years ago

你好,SyntaxError: Unexpected ";" (parser)这个问题解决了吗

我试图通过smop掩盖我的matlab代码,但收到许多警告和错误……

C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\lex.py:760: FutureWarning: Possible nested set at position 65
  c = re.compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags)
C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\lex.py:498: FutureWarning: Possible nested set at position 118
  lexre = re.compile(regex, reflags)
Traceback (most recent call last):
  File "C:/user1/smop/smop/main.py", line 68, in main
    stmt_list = parse.parse(buf if buf[-1] == '\n' else buf + '\n')
  File "C:\user1\smop\smop\parse.py", line 852, in parse
    p = parser.parse(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\yacc.py", line 331, in parse
    return self.parseopt(input, lexer, debug, tracking, tokenfunc)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\yacc.py", line 909, in parseopt
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\ply\yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "C:\user1\smop\smop\parse.py", line 839, in p_error
    raise_exception(SyntaxError,
  File "C:\user1\smop\smop\lexer.py", line 335, in raise_exception
    raise error_type(message, (options.filename,
  File "..\..\matlab\cData_run.m", line 10
    close all;
    ^
SyntaxError: Unexpected ";" (parser)
Errors: 1

我的matlab代码是这样的:

function cData_run
    close all;
    getrandparamsfunc = @getrandparamwithmotiontype6;
    outdir = '../out/mat_double';
    totalnTrainSamples = 60000;
    split_size = 50;   
.....
djsweeney67 commented 2 years ago

Add an empty parentheses set at the end of your Matlab function name (it's good programming practice too): Change, function cData_run to, function cData_run()