/*
* Copyright 2010, Lloyd Hilaiel.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. Neither the name of Lloyd Hilaiel nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "extThree20JSON/private/yajl_lex.h"
#include "extThree20JSON/private/yajl_buf.h"
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#ifdef YAJL_LEXER_DEBUG
static const char *
tokToStr(yajl_tok tok)
{
switch (tok) {
case yajl_tok_bool: return "bool";
case yajl_tok_colon: return "colon";
case yajl_tok_comma: return "comma";
case yajl_tok_eof: return "eof";
case yajl_tok_error: return "error";
case yajl_tok_left_brace: return "brace";
case yajl_tok_left_bracket: return "bracket";
case yajl_tok_null: return "null";
case yajl_tok_integer: return "integer";
case yajl_tok_double: return "double";
case yajl_tok_right_brace: return "brace";
case yajl_tok_right_bracket: return "bracket";
case yajl_tok_string: return "string";
case yajl_tok_string_with_escapes: return "string_with_escapes";
}
return "unknown";
}
#endif
/* Impact of the stream parsing feature on the lexer:
*
* YAJL support stream parsing. That is, the ability to parse the first
* bits of a chunk of JSON before the last bits are available (still on
* the network or disk). This makes the lexer more complex. The
* responsibility of the lexer is to handle transparently the case where
* a chunk boundary falls in the middle of a token. This is
* accomplished is via a buffer and a character reading abstraction.
*
* Overview of implementation
*
* When we lex to end of input string before end of token is hit, we
* copy all of the input text composing the token into our lexBuf.
*
* Every time we read a character, we do so through the readChar function.
* readChar's responsibility is to handle pulling all chars from the buffer
* before pulling chars from input text
*/
struct yajl_lexer_t {
/* the overal line and char offset into the data */
unsigned int lineOff;
unsigned int charOff;
/* error */
yajl_lex_error error;
/* a input buffer to handle the case where a token is spread over
* multiple chunks */
yajl_buf buf;
/* in the case where we have data in the lexBuf, bufOff holds
* the current offset into the lexBuf. */
unsigned int bufOff;
/* are we using the lex buf? */
unsigned int bufInUse;
/* shall we allow comments? */
unsigned int allowComments;
/* shall we validate utf8 inside strings? */
unsigned int validateUTF8;
yajl_alloc_funcs * alloc;
};
#define readChar(lxr, txt, off) \
(((lxr)->bufInUse && yajl_buf_len((lxr)->buf) && lxr->bufOff < yajl_buf_len((lxr)->buf)) ? \
(*((const unsigned char *) yajl_buf_data((lxr)->buf) + ((lxr)->bufOff)++)) : \
((txt)[(*(off))++]))
#define unreadChar(lxr, off) ((*(off) > 0) ? (*(off))-- : ((lxr)->bufOff--))
yajl_lexer
yajl_lex_alloc(yajl_alloc_funcs * alloc,
unsigned int allowComments, unsigned int validateUTF8)
{
yajl_lexer lxr = (yajl_lexer) YA_MALLOC(alloc, sizeof(struct yajl_lexer_t));
memset((void *) lxr, 0, sizeof(struct yajl_lexer_t));
lxr->buf = yajl_buf_alloc(alloc);
lxr->allowComments = allowComments;
lxr->validateUTF8 = validateUTF8;
lxr->alloc = alloc;
return lxr;
}
void
yajl_lex_free(yajl_lexer lxr)
{
yajl_buf_free(lxr->buf);
YA_FREE(lxr->alloc, lxr);
return;
}
/* a lookup table which lets us quickly determine three things:
* VEC - valid escaped conrol char
* IJC - invalid json char
* VHC - valid hex char
* note. the solidus '/' may be escaped or not.
* note. the
*/
#define VEC 1
#define IJC 2
#define VHC 4
static const char charLookupTable[256] =
{
/*00*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC ,
/*08*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC ,
/*10*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC ,
/*18*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC ,
/*20*/ 0 , 0 , VEC|IJC, 0 , 0 , 0 , 0 , 0 ,
/*28*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , VEC ,
/*30*/ VHC , VHC , VHC , VHC , VHC , VHC , VHC , VHC ,
/*38*/ VHC , VHC , 0 , 0 , 0 , 0 , 0 , 0 ,
/*40*/ 0 , VHC , VHC , VHC , VHC , VHC , VHC , 0 ,
/*48*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
/*50*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
/*58*/ 0 , 0 , 0 , 0 , VEC|IJC, 0 , 0 , 0 ,
/*60*/ 0 , VHC , VEC|VHC, VHC , VHC , VHC , VEC|VHC, 0 ,
/*68*/ 0 , 0 , 0 , 0 , 0 , 0 , VEC , 0 ,
/*70*/ 0 , 0 , VEC , 0 , VEC , 0 , 0 , 0 ,
/*78*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
/* include these so we don't have to always check the range of the char */
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
};
/** process a variable length utf8 encoded codepoint.
*
* returns:
* yajl_tok_string - if valid utf8 char was parsed and offset was
* advanced
* yajl_tok_eof - if end
没有合适的资源?快使用搜索试试~ 我知道了~
FaceBook基于Iphone的多个应用源码
共1231个文件
h:425个
m:390个
xcconfig:77个
3星 · 超过75%的资源 需积分: 10 57 下载量 20 浏览量
2011-08-15
18:03:17
上传
评论 2
收藏 11.63MB ZIP 举报
温馨提示
Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码Iphone开发系列源码——FaceBook基于Iphone的多个应用源码
资源推荐
资源详情
资源评论
收起资源包目录
FaceBook基于Iphone的多个应用源码 (1231个子文件)
AUTHORS 1KB
BUILDING 480B
yajl_lex.c 25KB
yajl_parser.c 19KB
yajl_gen.c 10KB
yajl_test.c 8KB
yajl_encode.c 7KB
json_reformat.c 6KB
yajl.c 5KB
json_verify.c 4KB
yajl_buf.c 3KB
yajl_alloc.c 2KB
yajl_version.c 92B
ChangeLog 4KB
YAJLDoc.cmake 846B
yajl_version.h.cmake 399B
Build.command 4KB
Protect.command 1KB
InstallTemplates3.2.2.Command 1KB
InstallTemplates3.2.4.Command 1KB
InstallTemplates3.2.5.Command 1KB
Clean.command 918B
Build.Command 245B
configure 3KB
COPYING 1KB
CssTokenizer.cpp 103KB
CssTokens.cpp 218B
CssTokens.cpp 215B
default.css 2KB
stylesheet.css 1KB
stylesheet.css 782B
testcase.css 653B
CssTokenizerPrefix 50B
project.dev 57B
YAJL.dxy 51KB
elements 1KB
elements 1KB
elements 1KB
.gitignore 276B
.gitignore 26B
deep_arrays.json.gold 31KB
difficult_json_c_test_case_with_comments.json.gold 650B
difficult_json_c_test_case.json.gold 650B
array.json.gold 262B
bogus_char.json.gold 219B
lonely_minus_sign.json.gold 209B
integers.json.gold 204B
string_with_escapes.json.gold 179B
non_utf8_char_in_string.json.gold 171B
dc_simple_with_comments.json.gold 133B
simple.json.gold 128B
simple_with_comments.json.gold 128B
nulls_and_bools.json.gold 126B
leading_zero_in_number.json.gold 123B
escaped_bulgarian.json.gold 119B
string_invalid_escape.json.gold 111B
three_byte_utf8.json.gold 106B
doubles.json.gold 98B
missing_integer_after_decimal_point.json.gold 94B
string_invalid_hex_char.json.gold 92B
unescaped_bulgarian.json.gold 89B
missing_integer_after_exponent.json.gold 89B
invalid_utf8.json.gold 76B
four_byte_utf8.json.gold 74B
map_close.json.gold 72B
array_close.json.gold 72B
string_with_invalid_newline.json.gold 64B
empty_array.json.gold 47B
codepoints_from_unicode_org.json.gold 37B
lonely_number.json.gold 35B
escaped_foobar.json.gold 33B
array_open.json.gold 31B
map_open.json.gold 29B
false.json.gold 28B
isolated_surrogate_marker.json.gold 28B
false_then_garbage.json.gold 28B
empty_string.json.gold 27B
true.json.gold 27B
true_then_garbage.json.gold 27B
null_then_garbage.json.gold 21B
null.json.gold 21B
css.grammar 3KB
TTURLRequest.h 9KB
TTBaseNavigator.h 8KB
yajl_parse.h 8KB
TTCSSRuleSet.h 8KB
TTScrollView.h 7KB
YAJLDocument.h 7KB
yajl_gen.h 7KB
TTMessageController.h 7KB
YAJL.h 7KB
TTURLCache.h 6KB
TTGlobalUICommon.h 6KB
TTModelViewController.h 6KB
GTMBase64.h 6KB
TTURLMap.h 6KB
YAJLParser.h 5KB
SBJsonStreamWriter.h 5KB
Three20UI.h 5KB
NSObject+YAJL.h 5KB
共 1231 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
- kunkunbobo2013-02-25这资源太撮了,就是three20的demo,而且ios6还运行不起,浪费了我那么多积分
- iam_gaowei2012-11-23这明明是three20的demo,跟facebook好像关系不大吧,只有一个下拉刷新的demo
- FatSpiders2012-03-29不错的资料是一些教程里的源码, 是个不入的入门经典,简单易懂,很适合初学者哦. 谢谢楼主共享
jone33
- 粉丝: 79
- 资源: 471
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功