git @ Cat's Eye Technologies ALPACA / e0cfee6
Add --include-yoob-playfield-inline option (for node.js testing.) catseye 12 years ago
3 changed file(s) with 13 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
248248 """
249249
250250 class Compiler(object):
251 def __init__(self, alpaca, file):
251 def __init__(self, alpaca, file, options=None):
252252 """alpaca is an ALPACA description in AST form. file is a file-like
253253 object to which the compiled code will be written.
254254
255255 """
256256 self.alpaca = alpaca
257257 self.file = file
258 self.options = options
258259
259260 def compile(self):
260261 bb = BoundingBox(0, 0, 0, 0)
266267 */
267268
268269 """)
269 self.file.write(YOOB_PLAYFIELD_JS)
270 if self.options is not None and \
271 self.options.include_yoob_playfield_inline:
272 self.file.write(YOOB_PLAYFIELD_JS)
270273 self.file.write("""
271274 function in_nbhd_pred(pf, x, y, pred, nbhd) {
272275 var count = 0;
5757 optparser.add_option("-t", "--test",
5858 action="store_true", dest="test", default=False,
5959 help="run test cases and exit")
60 optparser.add_option("-y", "--include-yoob-playfield-inline",
61 action="store_true",
62 dest="include_yoob_playfield_inline", default=False,
63 help="include yoob/playfield.js (from yoob.js) "
64 "inline in generated Javascript (javascript "
65 "backend only)")
6066 (options, args) = optparser.parse_args(argv[1:])
6167 if options.test:
6268 import doctest
8490 # XXX generalize
8591 if options.compile_to == 'javascript':
8692 from alpaca.backends.javascript import Compiler
87 compiler = Compiler(ast, sys.stdout)
93 compiler = Compiler(ast, sys.stdout, options=options)
8894 success = compiler.compile()
8995 if success:
9096 sys.exit(0)
1616
1717 -> Functionality "Evolve ALPACA CA one generation" is implemented by
1818 -> shell command
19 -> "./bin/alpaca -c javascript %(test-file) > ca.js && node ca.js"
19 -> "./bin/alpaca -y -c javascript %(test-file) > ca.js && node ca.js"
2020 EOF
2121 fi
2222