hapy/token_parser.py
def parse_class():
        """
        read a class definition.
        1. Look for the classname
        2. Check if there is an inherited class. Only get the first one!
        3. Look for instance methods.
        4. Look for instance properties.
        5. Look for special class methods... constructor, etc...
        5. Collect all and send back dict...

        thank you Jesus!
        """
        # skip 'class' first! Thank you Jesus!

        skip_kw(keywords[input.settings["lang"]]["class"])

        # next, get the class name
        classname = parse_varname()

        ret = {"type": "class", "name": classname}

        # if the next token is 'inherits' then get parent class name!...
        # thank you Jesus!
        if is_kw(keywords[input.settings["lang"]]["inherits"]):
            skip_kw(keywords[input.settings["lang"]]["inherits"])
            # get parent class name...
            parent_classname = parse_varname()
            ret["inherits"] = parent_classname
        # then get the class body expressions...

        expressions = delimited("{", "}", ";", parse_expression)

        # check if there are no expressions. If so, just return pass
        if len(expressions) == 0:
            # just for things that are not class stuff...
            ret["body"] = {"type": "var", "value": "pass"}

        ret["class_properties"] = []
        ret["class_special_methods"] = []
        ret["class_methods"] = []

        # now find all attributes, class_functions and methods
        for e in expressions:
            """
            for every expression,
            1. if type == 'class_property' put in properties array
            2. if type == 'class_special_method' put in class special functions array
            3. if type == 'function' put in class methods array
            """
            if e["type"] == "var" or e["type"] == "assign":
                ret["class_properties"].append(e)
            elif e["type"] == "class_special_method":
                ret["class_special_methods"].append(e)
            elif e["type"] == "function":
                ret["class_methods"].append(e)
            # this is to initialize the parent class
            elif e["type"] == "use_class":
                ret["init_parent"] = e
                # make sure classes are the same!
                if ret["init_parent"]["func"]["value"] != ret["inherits"][
                        "value"]:
                    input.croak("Parent class not initialized!")

        return ret

        read a class definition.
        1. Look for the classname
        2. Check if there is an inherited class. Only get the first one!
        3. Look for instance methods.
        4. Look for instance properties.
        5. Look for special class methods... constructor, etc...
        5. Collect all and send back dict...

        thank you Jesus!
        
read a class definition.
1. Look for the classname
2. Check if there is an inherited class. Only get the first one.
3. Look for instance methods.
4. Look for instance properties.
5. Look for special class methods... constructor, etc
5. Collect all and send back dict

thank you Jesus!
read a class definition . 1 . Look for the classname 2 . Check if there is an inherited class . Only get the first one . 3 . Look for instance methods . 4 . Look for instance properties . 5 . Look for special class methods ... constructor etc 5 . Collect all and send back dict thank you Jesus!
def parse_class():
        skip_kw(keywords[input.settings["lang"]]["class"])
        classname = parse_varname()
        ret = {"type": "class", "name": classname}
        if is_kw(keywords[input.settings["lang"]]["inherits"]):
            skip_kw(keywords[input.settings["lang"]]["inherits"])
            parent_classname = parse_varname()
            ret["inherits"] = parent_classname
        expressions = delimited("{", "}", ";", parse_expression)
        if len(expressions) == 0:
            ret["body"] = {"type": "var", "value": "pass"}
        ret["class_properties"] = []
        ret["class_special_methods"] = []
        ret["class_methods"] = []
        for e in expressions:
            if e["type"] == "var" or e["type"] == "assign":
                ret["class_properties"].append(e)
            elif e["type"] == "class_special_method":
                ret["class_special_methods"].append(e)
            elif e["type"] == "function":
                ret["class_methods"].append(e)
            elif e["type"] == "use_class":
                ret["init_parent"] = e
                if ret["init_parent"]["func"]["value"] != ret["inherits"][
                        "value"]:
                    input.croak("Parent class not initialized!")
        return ret
def parse_class ( ) : skip_kw ( keywords [ input . settings [ "lang" ] ] [ "class" ] ) classname = parse_varname ( ) ret = { "type" : "class" , "name" : classname } if is_kw ( keywords [ input . settings [ "lang" ] ] [ "inherits" ] ) : skip_kw ( keywords [ input . settings [ "lang" ] ] [ "inherits" ] ) parent_classname = parse_varname ( ) ret [ "inherits" ] = parent_classname expressions = delimited ( "{" , "}" , ";" , parse_expression ) if len ( expressions ) == 0 : ret [ "body" ] = { "type" : "var" , "value" : "pass" } ret [ "class_properties" ] = [ ] ret [ "class_special_methods" ] = [ ] ret [ "class_methods" ] = [ ] for e in expressions : """
            for every expression,
            1. if type == 'class_property' put in properties array
            2. if type == 'class_special_method' put in class special functions array
            3. if type == 'function' put in class methods array
            """ if e [ "type" ] == "var" or e [ "type" ] == "assign" : ret [ "class_properties" ] . append ( e ) elif e [ "type" ] == "class_special_method" : ret [ "class_special_methods" ] . append ( e ) elif e [ "type" ] == "function" : ret [ "class_methods" ] . append ( e ) elif e [ "type" ] == "use_class" : ret [ "init_parent" ] = e if ret [ "init_parent" ] [ "func" ] [ "value" ] != ret [ "inherits" ] [ "value" ] : input . croak ( "Parent class not initialized!" ) return ret
read a class definition.
read a class definition .
"""
        read a class definition.
        1. Look for the classname
        2. Check if there is an inherited class. Only get the first one!
        3. Look for instance methods.
        4. Look for instance properties.
        5. Look for special class methods... constructor, etc...
        5. Collect all and send back dict...

        thank you Jesus!
        """ # skip 'class' first! Thank you Jesus! # next, get the class name # if the next token is 'inherits' then get parent class name!... # thank you Jesus! # get parent class name... # then get the class body expressions... # check if there are no expressions. If so, just return pass # just for things that are not class stuff... # now find all attributes, class_functions and methods """
            for every expression,
            1. if type == 'class_property' put in properties array
            2. if type == 'class_special_method' put in class special functions array
            3. if type == 'function' put in class methods array
            """ # this is to initialize the parent class # make sure classes are the same!