示例#1
0
 def test_two_funcs_same_param_name(self):
     data = """\
     function f0(int a)
     {}
     function f1(int a)
     {}
     """
     tree = parse(data)
     tree.make_tac(TacState())
示例#2
0
 def test_for_loop(self):
     data = """\
     function test_0()
     {
         for(int i := 0; i < 10; i += 1)
         {
             print(i)
         }
     }
     """
     tree = parse(data)
     tree.sema()
示例#3
0
    def test_function_call_as_parameter(self):
        data = """\
        function test_0(int a) -> int
        {
            return a
        }

        function main()
        {
            print(test_0(10))
        }
        """
        tree = parse(data)
        tree.sema()
示例#4
0
    def test_function_call(self):
        data = """\
        function test_0(int a)
        {
            print(a)
        }

        function main()
        {
            test_0(10)
        }
        """

        tree = parse(data)
        tree.sema()
示例#5
0
    def test_struct_decl_and_use(self):
        data = """\
        struct vector
        {
            int v0
            int v1
            int v2
        }

        function f0()
        {
            vector a
            a.v0 := 1
            a.v1 := 2
            a.v2 := 3
        }
        """
        tree = parse(data)
        tree.sema()
示例#6
0
def save(arg):
    """
    Saves the output file
        Input:
            arg:str = Name of the file
    """
    format = "txt"
    name = ""
    if len(arg) == 3:
        if arg[2] in ["csv", "txt"]:
            format = arg[2]
        else:
            print "%s if not a supported format!" % arg[2]
    if len(arg) >= 2:
        if arg[1] in ["csv", "txt"]:
            format = arg[1]
            name = strftime("%Y-%m-%d_%H.%M.%S.", gmtime()) + format
        else:
            name = arg[1] + "." + format
    else:
        name = strftime("%Y-%m-%d_%H.%M.%S.", gmtime()) + format
    try:
        os.mkdir("saved")
    except:
        pass
    old = open("tmp/output.json", "rb")
    try:
        if "txt" in format or format == "":
            con = parse(json.loads(old.read()))
        elif format == "csv":
            con = csvformat(json.loads(old.read()))
        with open("saved/" + name, "wb") as f:
            f.write(con.encode("utf-8"))
        print "Saved output.json too %s" % name
    except ValueError, e:
        print e
        print "Nothing to be saved!"
示例#7
0
#! /usr/bin/env python3
# ---------------------------------------------------------------------------- #
#  npuzzle.py                                                                  #
#                                                                              #
#  By - jacksonwb                                                              #
#  Created: Sunday August 2019 8:46:34 pm                                      #
#  Modified: Tuesday Sep 2019 2:53:34 pm                                       #
#  Modified By: jacksonwb                                                      #
# ---------------------------------------------------------------------------- #

from src.solver import Puzzle
from src.parse import *
from src.heuristic import heuristic

if __name__ == "__main__":
    args = parse()
    try:
        puzzle = Puzzle(*process_input(args), heuristic[args.function],
                        args.greedy)
        puzzle.solve()
        puzzle.print_solution()
    except (BaseException) as e:
        print("npuzzle:", e)
示例#8
0
from src import parse

__author__ = 'deepak'

f = "/home/deepak/workspace/slob/WebContent/SecOntV2.owl"

subc, superc, eqc = parse(f)


print subc['Threat']
print superc['Threat']
print eqc['Threat']
示例#9
0
 def assertRaisesSemaError(self, data, errortype):
     with self.assertRaises(errortype):
         # Some semantic errors are found during the
         # parse stage.
         tree = parse(data)
         tree.sema()
示例#10
0
def import_string():
    pok = request.form["pok"]
    result = parse(pok)
    return jsonify(result=result)  #TODO: Add error handling site side