Skip to content

Commit

Permalink
0.32.2
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Nov 22, 2016
1 parent c2a95af commit 203d5f1
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 26 deletions.
16 changes: 16 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
=============
Release notes
=============

Version 0.33 is out

New option -c --code
Quickly check how a particular statement
is translated. Option -c implies -o- .

Renamed option -D to -d (--debug).

New regression count:

$ cd libscripts && make regresss

Currently 14 regressions


November 18, 2016
Version 0.31 is out

Expand Down
4 changes: 4 additions & 0 deletions smop/libscripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ V = 2.7
all: pyfiles
$(PYTHON) -m py_compile *.py

regress:
$(SMOP) $(FLAGS) $(MFILES) | grep Error | wc

.PHONY: all pyfiles clean

pyfiles:
$(SMOP) $(FLAGS) $(MFILES)


wall: $(PYFILES)
$(CAT) *.py > libscripts.py

Expand Down
33 changes: 23 additions & 10 deletions smop/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SMOP -- Simple Matlab/Octave to Python compiler
# Copyright 2011-2016 Victor Leikehman

import tempfile
import fnmatch
import tarfile
import sys
Expand All @@ -25,14 +26,26 @@ def print_header(fp):


def main():
if not options.filelist and not options.archive:
options.parser.print_help()
return
if not options.filelist and options.archive:
tar = tarfile.open(options.archive)
options.filelist = tar.getnames()
else:
tar = None
tar = None
if "M" in options.debug:
import pdb
pdb.set_trace()
if not options.filelist:
if options.archive:
tar = tarfile.open(options.archive)
options.filelist = tar.getnames()
elif options.code:
tmp = tempfile.NamedTemporaryFile(suffix=".m")
tmp.file.write(options.code)
tmp.file.flush()
options.filelist = [tmp.name]
if options.output:
print "Conflicting options -c and -o"
return
options.output = "-"
else:
options.parser.print_help()
return
if options.output == "-":
fp = sys.stdout
elif options.output:
Expand All @@ -54,7 +67,7 @@ def main():
options.filename)
continue
if basename(options.filename) in options.xfiles:
if options.verbose and "a3" in options.debug:
if options.verbose:
print "\tExcluded: '%s'" % options.filename
continue
if tar:
Expand All @@ -81,7 +94,7 @@ def main():

except:
print 40*"="
traceback.print_exc()
traceback.print_exc(file=sys.stdout)

if __name__ == "__main__":
main()
10 changes: 5 additions & 5 deletions smop/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
formatter_class=argparse.RawTextHelpFormatter,
)

parser.add_argument("-c", "--code")

parser.add_argument("-a", "--archive",
metavar="archive.tar",
Expand Down Expand Up @@ -92,12 +93,11 @@
type=str,
help="""comma-separated list of files to ignore""")

parser.add_argument("-D", "--debug", type=str,
parser.add_argument("-d", "--debug",
help="""Colon-separated codes.
a Main
b Lex
c Parse
1 After parsing
M Main
L Lex
P Parse
""")

parser.add_argument("-L", "--debug-lexer",
Expand Down
21 changes: 10 additions & 11 deletions smop/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,25 +838,25 @@ def p_error(p):

@exceptions
def parse(buf):
if "P" in options.debug:
import pdb
pdb.set_trace()
global new_lexer # used in main.main()
new_lexer = lexer.new()
p = parser.parse(
buf, tracking=1, debug=options.debug_parser, lexer=new_lexer)

if "1" in options.debug:
if "P" in options.debug:
for i, pi in enumerate(p):
print i, pi.__class__.__name__, pi._backend()

if "p" in options.debug:
import pdb
pdb.set_trace()

for i in range(len(p)):
if isinstance(p[i], node.func_stmt):
break
else:
return None # p[i] is a func decl
# for i in range(len(p)):
# if isinstance(p[i], node.func_stmt):
# break
# else:
# return None # p[i] is a func decl

return p
# for j in range(i+1,len(p)):
# if i < j and isinstance(p[j], node.func_stmt):
# p.insert(j,node.return_stmt(ret=p[i].ret))
Expand All @@ -868,4 +868,3 @@ def parse(buf):
# for i,pi in enumerate(p):
# print i,pi.__class__.__name__,str(pi)[:50]

return p

0 comments on commit 203d5f1

Please sign in to comment.