Beispiel #1
0
def ProgramObjectUnparser(
    arg_map: parse_primitives.ObjectNodeArgMap,
    result: parse_primitives.ObjectToStringResult
):
    had_prev_args = False
    # First add in all the flag args
    for arg in arg_map.implementation.children:
        if not arg_map.is_argname_present(arg.name):
            continue
        if POSITION in arg.arg_data:
            continue
        if had_prev_args:
            result.add_string(" ")
        arg_flag = _get_flag_for_arg_unparse(arg)
        result.add_string(arg_flag)
        if arg.type is not None:
            result.add_string(" ")
            result.add_arg_tostring(arg)
        had_prev_args = True
    # Now do all the positional args in order
    for arg in get_all_positional_args(arg_map.implementation.children):
        if not arg_map.is_argname_present(arg.name):
            continue
        if had_prev_args:
            result.add_string(" ")
        result.add_arg_tostring(arg)
        had_prev_args = True
Beispiel #2
0
def CmdSeqUnparser(
    arg_map: parse_primitives.ObjectNodeArgMap,
    result: parse_primitives.ObjectToStringResult
):
    if arg_map.is_argname_present("ProgramArg"):
        result.add_argname_tostring("ProgramArg")
    if arg_map.is_argname_present("CompoundOp"):
        result.add_string(" ")
        result.add_argname_tostring("CompoundOp")
Beispiel #3
0
def _unparse_visit_identifier(node: ParseTreeNode,
                              result: parse_primitives.ObjectToStringResult,
                              arg_map: parse_primitives.ObjectNodeArgMap):
    arg_name = node.value
    if not arg_map.is_argname_present(arg_name):
        raise UnparseError(f"Arg {arg_name} is not present")
    result.add_argname_tostring(arg_name)