summaryrefslogtreecommitdiff
path: root/jsmn.c
diff options
context:
space:
mode:
authorSerge A. Zaitsev <devnull@localhost>2010-12-27 17:05:22 +0200
committerSerge A. Zaitsev <devnull@localhost>2010-12-27 17:05:22 +0200
commitc4d9412483bc561cef53a784e9f28b827e010e7b (patch)
tree1aa751b620e68de7c3ad18995d08ae04512c1bf1 /jsmn.c
parentc955364a952c5ad5158637b77c75edcf010d49af (diff)
Some comments added in json.c
Diffstat (limited to 'jsmn.c')
-rw-r--r--jsmn.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/jsmn.c b/jsmn.c
index d02c2bb6f..3f2b149c2 100644
--- a/jsmn.c
+++ b/jsmn.c
@@ -2,6 +2,9 @@
#include "jsmn.h"
+/**
+ * Allocates a fresh unused token from the token pull.
+ */
static jsmntok_t *jsmn_get_token(jsmn_parser *parser) {
unsigned int i;
jsmntok_t *tokens = parser->tokens;
@@ -14,12 +17,20 @@ static jsmntok_t *jsmn_get_token(jsmn_parser *parser) {
return NULL;
}
-static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, int start, int end) {
+/**
+ * Fills token type and boundaries.
+ */
+static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
+ int start, int end) {
token->type = type;
token->start = start;
token->end = end;
}
+/**
+ * Creates a new parser based over a given buffer with an array of tokens
+ * available.
+ */
void jsmn_init_parser(jsmn_parser *parser, const char *js,
jsmntok_t *tokens, unsigned int num_tokens) {
unsigned int i;
@@ -35,6 +46,9 @@ void jsmn_init_parser(jsmn_parser *parser, const char *js,
}
}
+/**
+ * Fills next available token with JSON primitive.
+ */
static int jsmn_parse_primitive(jsmn_parser *parser) {
const char *js;
jsmntok_t *token;
@@ -64,6 +78,9 @@ static int jsmn_parse_primitive(jsmn_parser *parser) {
return JSMN_ERROR_PART;
}
+/**
+ * Filsl next token with JSON string.
+ */
static int jsmn_parse_string(jsmn_parser *parser) {
const char *js;
jsmntok_t *token;
@@ -110,6 +127,9 @@ static int jsmn_parse_string(jsmn_parser *parser) {
return JSMN_ERROR_PART;
}
+/**
+ * Parse JSON string and fill tokens.
+ */
jsmnerr_t jsmn_parse(jsmn_parser *parser) {
int r;
unsigned int i;