Esempio n. 1
0
#!/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()
Esempio n. 2
0
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
Esempio n. 3
0
def compile_pyva(source):
    grammar = Grammar.parse(source)
    return Translator.parse(grammar)
Esempio n. 4
0
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')
Esempio n. 5
0
#!/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()