#!/usr/bin/env python from pyvascript.grammar import Grammar, Translator import sys if len(sys.argv) != 2: print >>sys.stderr, "Usage: compile-pyva.py <script>" sys.exit(1) file_name = sys.argv[1].rsplit(".", 1)[0] fp = open(sys.argv[1], "r") source = fp.read() fp.close() g = Grammar.parse(source) output = Translator.parse(g) new_file = open(file_name + ".js", "w") new_file.write(output) new_file.close()
from pyvascript.grammar import Grammar, Translator import sys g = Grammar.parse_source(open(sys.argv[1], 'r').read()) print g print '\n------------------------------------------------------\n' t = Translator.parse_source(g) print t
def compile_pyva(source): grammar = Grammar.parse(source) return Translator.parse(grammar)
try: from pyvascript.grammar import Grammar, Translator from pymeta.runtime import ParseError def compile(request): if not request.method == 'POST' or not 'code' in request.POST: return HttpResponseForbidden() code = request.POST['code'] if not code: return HttpResponseForbidden() response_dict = {} success = False try: g = Grammar.parse(code) except ParseError, error: response_dict.update({'error': error.message}) else: success = True response_dict.update({'code': Translator.parse(g)}) response_dict.update({'success': success}) return JsonResponse(response_dict) except ImportError: def compile(request): return JsonResponse({'error': 'pyvascript not found'}) def documentation(request): return render(request, 'documentation/python.html')
#!/usr/bin/env python from pyvascript.grammar import Grammar, Translator import sys if len(sys.argv) != 2: print >> sys.stderr, 'Usage: compile-pyva.py <script>' sys.exit(1) file_name = sys.argv[1].rsplit('.', 1)[0] fp = open(sys.argv[1], 'r') source = fp.read() fp.close() g = Grammar.parse(source) output = Translator.parse(g) new_file = open(file_name + '.js', 'w') new_file.write(output) new_file.close()