static void parse_schema_decl(fb_parser_t *P) { switch(P->token->id) { case tok_kw_namespace: next(P); parse_namespace(P); break; case tok_kw_file_extension: next(P); parse_file_extension(P, &P->schema.file_extension); break; case tok_kw_file_identifier: next(P); parse_file_identifier(P, &P->schema.file_identifier); break; case tok_kw_root_type: next(P); parse_root_type(P, &P->schema.root_type); break; case tok_kw_attribute: next(P); parse_attribute(P, fb_add_attribute(P)); break; case tok_kw_struct: next(P); parse_compound_type(P, fb_add_struct(P)); break; case tok_kw_table: next(P); parse_compound_type(P, fb_add_table(P)); break; case tok_kw_enum: next(P); parse_enum_decl(P, fb_add_enum(P)); break; case tok_kw_union: next(P); parse_union_decl(P, fb_add_union(P)); break; case '{': error_tok(P, P->token, "JSON objects are not supported by this implementation"); break; default: error_tok(P, P->token, "unexpected token in schema definition"); break; } }
bool CScriptStorage::load_buffer (lua_State *L, LPCSTR caBuffer, size_t tSize, LPCSTR caScriptName, LPCSTR caNameSpaceName) { int l_iErrorCode; if (caNameSpaceName && xr_strcmp("_G",caNameSpaceName)) { string512 insert, a, b; LPCSTR header = file_header; if (!parse_namespace(caNameSpaceName,a,b)) return (false); sprintf_s (insert,header,caNameSpaceName,a,b); u32 str_len = xr_strlen(insert); LPSTR script = xr_alloc<char>(str_len + tSize); strcpy_s (script, str_len + tSize, insert); CopyMemory (script + str_len,caBuffer,u32(tSize)); // try { l_iErrorCode= luaL_loadbuffer(L,script,tSize + str_len,caScriptName); } // catch(...) { // l_iErrorCode= LUA_ERRSYNTAX; // } xr_free (script); } else { // try { l_iErrorCode= luaL_loadbuffer(L,caBuffer,tSize,caScriptName); } // catch(...) { // l_iErrorCode= LUA_ERRSYNTAX; // } } if (l_iErrorCode) { #ifdef DEBUG print_output (L,caScriptName,l_iErrorCode); #endif on_error (L); return (false); } return (true); }
static void parse_schema_decl(fb_parser_t *P) { switch(P->token->id) { case tok_kw_namespace: next(P); parse_namespace(P); break; case tok_kw_file_extension: next(P); parse_file_extension(P, &P->schema.file_extension); break; case tok_kw_file_identifier: next(P); parse_file_identifier(P, &P->schema.file_identifier); break; case tok_kw_root_type: next(P); parse_root_type(P, &P->schema.root_type); break; case tok_kw_attribute: next(P); parse_attribute(P, fb_add_attribute(P)); break; case tok_kw_struct: next(P); parse_compound_type(P, fb_add_struct(P), tok_kw_struct); break; case tok_kw_table: next(P); parse_compound_type(P, fb_add_table(P), tok_kw_table); break; case tok_kw_rpc_service: next(P); parse_compound_type(P, fb_add_rpc_service(P), tok_kw_rpc_service); break; case tok_kw_enum: next(P); parse_enum_decl(P, fb_add_enum(P)); break; case tok_kw_union: next(P); parse_union_decl(P, fb_add_union(P)); break; case tok_kw_include: error_tok(P, P->token, "include statements must be placed first in the schema"); break; case '{': error_tok(P, P->token, "JSON objects in schema file is not supported - but a schema specific JSON parser can be generated"); break; case LEX_TOK_CTRL: error_tok_as_string(P, P->token, "unexpected control character in schema definition", "?", 1); break; case LEX_TOK_COMMENT_CTRL: if (lex_isblank(P->token->text[0])) { /* This also strips tabs in doc comments. */ next(P); break; } error_tok_as_string(P, P->token, "unexpected control character in comment", "?", 1); break; case LEX_TOK_COMMENT_UNTERMINATED: error_tok_as_string(P, P->token, "unterminated comment", "<eof>", 5); break; default: error_tok(P, P->token, "unexpected token in schema definition"); break; } }