def basic_type(token): if ( token[0] == "int" or token[0] == "char" or token[0] == "boolean" or tokanizer.token_type(token[0]) == "identifier" ): return token[0]
def var_dec(token): # Variable Declaration Method,Grammer: 'var' type varName (',' varName)* ';' print "<varDec>" print_token(token[0], token[1]) token = tokanizer.next_token() if token[0] == basic_type(token) or tokanizer.token_type(token[0]) == "identifier": print_token(token[0], token[1]) token = tokanizer.next_token() var_dec_token_type(token) token = tokanizer.next_token() while token[0] != ";": if token[0] == ",": print_token(token[0], token[1]) token = tokanizer.next_token() var_dec_token_type(token) token = tokanizer.next_token() if token[0] == ";": print_token(token[0], token[1]) print "</varDec>" return token