Пример #1
0
def p_MessageReceiveSequenceFunction(p):
    """
    MessageReceiveSequenceFunction : Identifier DOT Identifier CURLY_LEFT CURLY_RIGHT
                                   | Identifier DOT Identifier CURLY_LEFT FunctionBody CURLY_RIGHT

                                   | Identifier DOT Identifier LEFT_PAREN FunctionDeclArgList RIGHT_PAREN CURLY_LEFT CURLY_RIGHT
                                   | Identifier DOT Identifier LEFT_PAREN FunctionDeclArgList RIGHT_PAREN CURLY_LEFT FunctionBody CURLY_RIGHT
                                   | OnCompleteFunction
                                   
    """

    if len(p) == 2:
        # means it was an on complete function.  just use that directly
        p[0] = p[1]
        return

    p[0] = AstNode(AST_MESSAGE_RECEIVE_SEQUENCE_FUNCTION, p[1].lineNo, p[1].linePos)

    # specifically parsing for error of putting parens at end of message receive statement
    if (len(p) == 9) or (len(p) == 10):
        funcName = p[1].value + p[2] + p[3].value
        errMsg = '\nError in MessageSequence on "' + funcName + '".  '
        errMsg += "Only the first function can take in arguments.  "
        errMsg += "Subsequent functions are automatically called by "
        errMsg += "the system.  You should remove the parentheses at the end of "
        errMsg += "the function.\n"
        p[0].value = funcName
        raise WaldoParseException(p[0], errMsg)

    p[0].addChildren([p[1], p[3]])
    if len(p) == 7:
        p[0].addChild(p[5])
    else:
        p[0].addChild(AstNode(AST_FUNCTION_BODY, p[1].lineNo, p[1].linePos))
Пример #2
0
def p_Type(p):
    '''
    Type : NUMBER_TYPE
         | STRING_TYPE
         | BOOL_TYPE
         | NOTHING_TYPE
         | FunctionType
         | ListType
         | MapType
         | StructType

         | ENDPOINT 

         | EXTERNAL StructType
         | EXTERNAL NUMBER_TYPE
         | EXTERNAL STRING_TYPE
         | EXTERNAL BOOL_TYPE
         | EXTERNAL ListType
         | EXTERNAL MapType
         '''

    p[0] = AstNode(AST_TYPE,p.lineno(1),p.lexpos(1));    
    if len(p) == 2:
        typeIndex = 1;
    else:
        typeIndex = 2;

    if isinstance(p[typeIndex],basestring):
        p[0].value = p[typeIndex];
    else:
        # means that has function, list type, or struct type
        p[0] = p[typeIndex];

    if len(p) == 3:
        p[0].external = True;