コード例 #1
0
ファイル: builder.py プロジェクト: uxvworks/matlab2cpp
    def create_codeblock(self, parent, cur):
        """
Create codeblock Block

| Structure:
|   Assign|Assigns|Bcomment|Ecomment|Lcomment|Statement

`Statements` are handled locally and evoces <expression>

Legal parents:
Case, Catch, Elif, Else, For, Func, If, Main, Otherwise, Switch, Try, While

Args:
    parent (Node): Reference to parent node
    cur (int): position where codeblock is identified

Returns:
    int: position where codeblock ends

See also:
    :py:func:`matlab2cpp.tree.codeblock.codeblock`
    """
        pnames = [ "Case", "Catch", "Elif", "Else", "For", "Func", "If",
                "Main", "Otherwise", "Switch", "Try", "While"]
        pnodes = [getattr(mc.collection, name) for name in pnames]
        ppart = [isinstance(parent, node) for node in pnodes]
        if not any(ppart):
            raise AssertionError(
                    "parent of Block: %s not valid group parent\n%s" %\
                    (parent.cls, str(pnames)))
            
        return codeblock.codeblock(self, parent, cur)
コード例 #2
0
    def create_codeblock(self, parent, cur):
        """
Create codeblock Block

| Structure:
|   Assign|Assigns|Bcomment|Ecomment|Lcomment|Statement

`Statements` are handled locally and evoces <expression>

Legal parents:
Case, Catch, Elif, Else, For, Func, If, Main, Otherwise, Switch, Try, While

Args:
    parent (Node): Reference to parent node
    cur (int): position where codeblock is identified

Returns:
    int: position where codeblock ends

See also:
    :py:func:`matlab2cpp.tree.codeblock.codeblock`
    """
        pnames = [
            "Case", "Catch", "Elif", "Else", "For", "Func", "If", "Main",
            "Otherwise", "Switch", "Try", "While"
        ]
        pnodes = [getattr(mc.collection, name) for name in pnames]
        ppart = [isinstance(parent, node) for node in pnodes]
        if not any(ppart):
            raise AssertionError(
                    "parent of Block: %s not valid group parent\n%s" %\
                    (parent.cls, str(pnames)))

        return codeblock.codeblock(self, parent, cur)