wchar_t *GetExtensions(JNIEnv *env, jobject jFilter) { JLObjectArray jExts(env, (jobjectArray)env->CallObjectMethod(jFilter, javaIDs.CommonDialogs.ExtensionFilter.extensionsToArray)); CheckAndClearException(env); jsize size = env->GetArrayLength(jExts); BOOL isHeading = TRUE; // extension without semicolon JLString jExt(env, CreateJString(env, _T(""))); JLString semicolon(env, CreateJString(env, _T(";"))); for (int j = 0; j < size; j++) { if (!isHeading) { jExt.Attach( ConcatJStrings(env, jExt, semicolon) ); } isHeading = FALSE; JLString jExtension(env, (jstring)env->GetObjectArrayElement(jExts, j)); jExt.Attach( ConcatJStrings(env, jExt, jExtension) ); } JString ext(env, jExt, false); return ext; }
TEST(CSSTokenizerTest, CommentToken) { TEST_TOKENS("/*comment*/a", ident("a")); TEST_TOKENS("/**\\2f**//", delim('/')); TEST_TOKENS("/**y*a*y**/ ", whitespace()); TEST_TOKENS(",/* \n :) \n */)", comma(), rightParenthesis()); TEST_TOKENS(":/*/*/", colon()); TEST_TOKENS("/**/*", delim('*')); TEST_TOKENS(";/******", semicolon()); }
TEST(CSSTokenizerTest, SingleCharacterTokens) { TEST_TOKENS("(", leftParenthesis()); TEST_TOKENS(")", rightParenthesis()); TEST_TOKENS("[", leftBracket()); TEST_TOKENS("]", rightBracket()); TEST_TOKENS(",", comma()); TEST_TOKENS(":", colon()); TEST_TOKENS(";", semicolon()); TEST_TOKENS(")[", rightParenthesis(), leftBracket()); TEST_TOKENS("[)", leftBracket(), rightParenthesis()); TEST_TOKENS("{}", leftBrace(), rightBrace()); TEST_TOKENS(",,", comma(), comma()); }
// FIXME: don't discard the qualifier in namespace definitions void Parser::namespaceDefinition(int flags, Qualifier* /*qual*/) { uint32_t pos = position(); if (!(flags & (SFLAG_Function|SFLAG_Toplevel))) // no classes yet... compiler->syntaxError(pos, SYNTAXERR_KWD_NOT_ALLOWED, "namespace"); eat(T_Identifier); Str * name = identifier(); if (match(T_Assign)) { if (hd() == T_Identifier || hd() == T_StringLiteral) addNamespaceBinding(name, primaryExpression()); else compiler->syntaxError(pos, SYNTAXERR_ILLEGAL_NAMESPACE); } else addNamespaceBinding(name, NULL); semicolon(); }
// FIXME: don't discard the qualifier in namespace definitions void Parser::namespaceDefinition(int flags, Qualifier* /*qual*/) { uint32_t pos = position(); if (!(flags & (SFLAG_Function|SFLAG_Toplevel))) // no classes yet... compiler->syntaxError(pos, "'namespace' definition not allowed here"); eat(T_Identifier); Str * name = identifier(); if (match(T_Assign)) { if (hd() == T_Identifier || hd() == T_StringLiteral) addNamespaceBinding(name, primaryExpression()); else compiler->syntaxError(pos, "Illegal 'namespace' definition"); } else addNamespaceBinding(name, NULL); semicolon(); }
void Parser::includeDirective() { eat(T_Identifier); Str* newFile = stringValue(); uint32_t pos = position(); eat(T_StringLiteral); semicolon(); if (!compiler->origin_is_file) compiler->syntaxError(pos, SYNTAXERR_INCLUDE_ORIGIN); // The current lexer state - including the state variables that are a part of the // parser object - gets pushed onto a stack, a new lexer is created for the new // input, and is installed. Then we return, the caller must continue parsing as // if nothing had happened. When the current lexer sees EOS it calls onEOS() // on the parser, which pops the lexer stack and generates a token from the popped // lexer. The normal token processing path does not slow down at all and the // machinery is almost entirely transparent to the parser. pushLexerState(); T0 = T1 = T_LAST; LP = L0 = L1 = 0; uint32_t inputlen; const wchar* input = compiler->context->readFileForEval(compiler->filename, newFile->s, &inputlen); if (input == NULL) compiler->syntaxError(pos, SYNTAXERR_INCLUDE_INACCESSIBLE); included_input = input; // freed in onEOS below #ifdef DEBUG bool doTrace = lexer->getTrace(); #endif lexer = ALLOC(Lexer, (compiler, input, inputlen)); #ifdef DEBUG if (doTrace) lexer->trace(); #endif start(); }
void ft_doublecoms(t_env *env, t_main *w) { char **coms; int i; i = 0; coms = NULL; w->line = NULL; ft_selectinit(w); while (ft_select(w, &w->line)) ; ft_selectend(w); w = ft_keep_main(*w, 0); if (ft_strchr(w->line, '>') != 0 || ft_strchr(w->line, '<') != 0) ft_redirect(w, env); if (ft_strchr(w->line, ';') == 0 && ft_strchr(w->line, '|') == 0) ft_minishell(env, w); else if (ft_strchr(w->line, '|') == 0 && ft_strchr(w->line, ';') != 0) semicolon(w, env, coms); else if (ft_strchr(w->line, '|') != 0) com_pipes(w, env, coms); if (i == 0) ft_doublecoms(env, w); }
// Returns the next token in the character stream. // If no next token can be identified, an error // is emitted and we return the error token. Token Lexer::scan() { // Keep consuming characters until we find // a token. while (true) { space(); // Update the position of the current source location. // This denotes the beginning of the current token. loc_ = in_.location(); switch (peek()) { case 0: return eof(); case '{': return lbrace(); case '}': return rbrace(); case '(': return lparen(); case ')': return rparen(); case '[': return lbrack(); case ']': return rbrack(); case ',': return comma(); case ':': return colon(); case ';': return semicolon(); case '.': return dot(); case '+': return plus(); case '-': return minus(); case '*': return star(); case '/': get(); if (peek() == '/') { comment(); continue; } else { return slash(); } case '%': return percent(); case '=': return equal(); case '!': return bang(); case '<': return langle(); case '>': return rangle(); case '&': return ampersand(); case '|': return bar(); case '^': return hat(); case '0': // if the next character is a 'b' then this // is a binary literal if (peek(1) == 'b') return binary_integer(); // if the next character is an 'x' then this // is a hexadecimal integer if (peek(1) == 'x') return hexadecimal_integer(); // otherwise proceed to regular integer lexing case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return integer(); case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': return word(); case '\'': return character(); case '"': return string(); default: return error(); } } }