token.c File Reference
`#include "ruby/ruby.h"`
`#include "syck.h"`
`#include "gram.h"`

Go to the source code of this file.

## Macros

#define | QUOTELEN 1024
#define | YYCTYPE char
#define | YYCURSOR parser->cursor
#define | YYMARKER parser->marker
#define | YYLIMIT parser->limit
#define | YYTOKEN parser->token
#define | YYTOKTMP parser->toktmp
#define | YYLINEPTR parser->lineptr
#define | YYLINECTPTR parser->linectptr
#define | YYLINE parser->linect
#define | YYFILL(n) syck_parser_read(parser)
#define | YYPOS(n) YYCURSOR = YYTOKEN + n
#define | NEWLINE(ptr) YYLINEPTR = ptr + newline_len(ptr); if ( YYLINEPTR > YYLINECTPTR ) { YYLINE++; YYLINECTPTR = YYLINEPTR; }
#define | ADD_LEVEL(len, status) syck_parser_add_level( parser, len, status )
#define | POP_LEVEL() syck_parser_pop_level( parser )
#define | CURRENT_LEVEL() syck_parser_current_level( parser )
#define | FORCE_NEXT_TOKEN(tok) parser->force_token = tok;
#define | ENSURE_YAML_IOPEN(last_lvl, to_len, reset)
#define | ENSURE_YAML_IEND(last_lvl, to_len)
#define | QUOTECAT(s, c, i, l)
#define | QUOTECATS(s, c, i, cs, cl)
#define | RETURN_IMPLICIT()
#define | PLAIN_NOT_INL()
#define | PLAIN_IS_INL()
#define | RETURN_YAML_BLOCK()
#define | GOBBLE_UP_YAML_INDENT(ict, start)
#define | GET_TRUE_YAML_INDENT(indt_len)

## Functions

void | eat_comments (SyckParser *)
char | escape_seq (char)
int | is_newline (char *ptr)
int | newline_len (char *ptr)
int | sycklex_yaml_utf8 (YYSTYPE *, SyckParser *)
int | sycklex_bytecode_utf8 (YYSTYPE *, SyckParser *)
int | syckwrap ()
int | sycklex (YYSTYPE *sycklval, SyckParser *parser)
void | syckerror (const char *msg)

## Variables

SyckParser * | syck_parser_ptr = NULL

## Macro Definition Documentation

#define ADD_LEVEL | ( |  | len,
|  |  | status
| ) |  | syck_parser_add_level( parser, len, status )

Definition at line 47 of file token.c.

Referenced by sycklex_yaml_utf8().

#define CURRENT_LEVEL | ( |  | ) | syck_parser_current_level( parser )

Definition at line 49 of file token.c.

Referenced by sycklex_yaml_utf8().

#define ENSURE_YAML_IEND | ( |  | last_lvl,
|  |  | to_len
| ) |  |

Value:
if ( last_lvl->spaces > to_len ) \
{ \
syck_parser_pop_level( parser ); \
YYPOS(0); \
return YAML_IEND; \
}

Definition at line 79 of file token.c.

Referenced by sycklex_yaml_utf8().

#define ENSURE_YAML_IOPEN | ( |  | last_lvl,
|  |  | to_len,
|  |  | reset
| ) |  |

Value:
if ( last_lvl->spaces < to_len ) \
{ \
if ( last_lvl->status == syck_lvl_iseq || last_lvl->status == syck_lvl_imap ) \
{ \
goto Document; \
} \
else \
{ \
ADD_LEVEL( to_len, syck_lvl_doc ); \
if ( reset == 1 ) YYPOS(0); \
return YAML_IOPEN; \
} \
}

Definition at line 60 of file token.c.

Referenced by sycklex_yaml_utf8().

#define FORCE_NEXT_TOKEN | ( |  | tok | ) | parser->force_token = tok;

Definition at line 54 of file token.c.

Referenced by sycklex_yaml_utf8().

#define GET_TRUE_YAML_INDENT | ( |  | indt_len | ) |

Value:
{ \
SyckLevel *lvl_deep = CURRENT_LEVEL(); \
indt_len = lvl_deep->spaces; \
if ( lvl_deep->status == syck_lvl_seq || ( indt_len == YYCURSOR - YYLINEPTR && lvl_deep->status != syck_lvl_map ) ) \
{ \
SyckLevel *lvl_over; \
parser->lvl_idx--; \
lvl_over = CURRENT_LEVEL(); \
indt_len = lvl_over->spaces; \
parser->lvl_idx++; \
} \
}

Definition at line 216 of file token.c.

Referenced by sycklex_yaml_utf8().

#define GOBBLE_UP_YAML_INDENT | ( |  | ict,
|  |  | start
| ) |  |

Value:
char *indent = start; \
NEWLINE(indent); \
while ( indent < YYCURSOR ) \
{ \
if ( is_newline( ++indent ) ) \
{ \
NEWLINE(indent); \
} \
} \
ict = 0; \
if ( *YYCURSOR == '\0' ) \
{ \
ict = -1; \
start = YYCURSOR - 1; \
} \
else if ( *YYLINEPTR == ' ' ) \
{ \
ict = (int)(YYCURSOR - YYLINEPTR); \
}

Definition at line 192 of file token.c.

Referenced by sycklex_yaml_utf8().

#define NEWLINE | ( |  | ptr | ) | YYLINEPTR = ptr + newline_len(ptr); if ( YYLINEPTR > YYLINECTPTR ) { YYLINE++; YYLINECTPTR = YYLINEPTR; }

Definition at line 42 of file token.c.

#define PLAIN_IS_INL | ( |  | ) |

Value:
char *walker = qstr + qidx - 1; \
while ( walker > qstr && ( *walker == '\n' || *walker == ' ' || *walker == '\t' ) ) \
{ \
qidx--; \
walker[0] = '\0'; \
walker--; \
}

Definition at line 143 of file token.c.

Referenced by sycklex_yaml_utf8().

#define PLAIN_NOT_INL | ( |  | ) |

Value:
if ( *(YYCURSOR - 1) == ' ' || is_newline( YYCURSOR - 1 ) ) \
{ \
YYCURSOR--; \
} \
QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN); \
goto Plain2;

Definition at line 134 of file token.c.

Referenced by sycklex_yaml_utf8().

#define POP_LEVEL | ( |  | ) | syck_parser_pop_level( parser )

Definition at line 48 of file token.c.

Referenced by sycklex_yaml_utf8().

#define QUOTECAT | ( |  | s,
|  |  | c,
|  |  | i,
|  |  | l
| ) |  |

Value:
{ \
if ( i + 1 >= c ) \
{ \
c += QUOTELEN; \
S_REALLOC_N( s, char, c ); \
} \
s[i++] = l; \
s[i] = '\0'; \
}

Definition at line 91 of file token.c.

Referenced by sycklex_yaml_utf8().

#define QUOTECATS | ( |  | s,
|  |  | c,
|  |  | i,
|  |  | cs,
|  |  | cl
| ) |  |

Value:
{ \
while ( i + cl >= c ) \
{ \
c += QUOTELEN; \
S_REALLOC_N( s, char, c ); \
} \
S_MEMCPY( s + i, cs, char, cl ); \
i += cl; \
s[i] = '\0'; \
}

Definition at line 102 of file token.c.

Referenced by sycklex_yaml_utf8().

#define QUOTELEN 1024

Definition at line 17 of file token.c.

#define RETURN_IMPLICIT | ( |  | ) |

Value:
{ \
SyckNode *n = syck_alloc_str(); \
YYCURSOR = YYTOKEN; \
n->data.str->ptr = qstr; \
n->data.str->len = qidx; \
n->data.str->style = scalar_plain; \
sycklval->nodeData = n; \
if ( parser->implicit_typing == 1 ) \
{ \
try_tag_implicit( sycklval->nodeData, parser->taguri_expansion ); \
} \
return YAML_PLAIN; \
}

Definition at line 118 of file token.c.

Referenced by sycklex_yaml_utf8().

#define RETURN_YAML_BLOCK | ( |  | ) |

Definition at line 156 of file token.c.

Referenced by sycklex_yaml_utf8().

#define YYCTYPE char

Definition at line 22 of file token.c.

Referenced by eat_comments(), and sycklex_yaml_utf8().

#define YYCURSOR parser->cursor

Definition at line 23 of file token.c.

Referenced by eat_comments(), and sycklex_yaml_utf8().

#define YYFILL | ( |  | n | ) | syck_parser_read(parser)

Definition at line 31 of file token.c.

Referenced by eat_comments(), and sycklex_yaml_utf8().

#define YYLIMIT parser->limit

Definition at line 25 of file token.c.

Referenced by eat_comments(), and sycklex_yaml_utf8().

#define YYLINE parser->linect

Definition at line 30 of file token.c.

#define YYLINECTPTR parser->linectptr

Definition at line 29 of file token.c.

#define YYLINEPTR parser->lineptr

Definition at line 28 of file token.c.

Referenced by sycklex_yaml_utf8().

#define YYMARKER parser->marker

Definition at line 24 of file token.c.

Referenced by eat_comments(), and sycklex_yaml_utf8().

#define YYPOS | ( |  | n | ) | YYCURSOR = YYTOKEN + n

Definition at line 37 of file token.c.

Referenced by sycklex_yaml_utf8().

#define YYTOKEN parser->token

Definition at line 26 of file token.c.

Referenced by eat_comments(), and sycklex_yaml_utf8().

#define YYTOKTMP parser->toktmp

Definition at line 27 of file token.c.

Referenced by sycklex_yaml_utf8().

## Function Documentation

void eat_comments | ( | SyckParser * | parser | ) |

Definition at line 2599 of file token.c.

References YYCTYPE, YYCURSOR, YYFILL, YYLIMIT, YYMARKER, and YYTOKEN.

Referenced by sycklex_yaml_utf8().

char escape_seq | ( | char | ch | ) |

Definition at line 2674 of file token.c.

Referenced by sycklex_yaml_utf8().

int is_newline | ( | char * | ptr | ) |

Definition at line 2692 of file token.c.

References newline_len().

Referenced by sycklex_yaml_utf8().

int newline_len | ( | char * | ptr | ) |

Definition at line 2698 of file token.c.

Referenced by is_newline(), and sycklex_yaml_utf8().

void syckerror | ( | const char * | msg | ) |

Definition at line 2716 of file token.c.

References _syck_parser::error_handler, NULL, _syck_parser::root, _syck_parser::root_on_error, and syck_default_error_handler().

Referenced by sycklex().

int sycklex | ( | YYSTYPE * | sycklval,
|  | SyckParser * | parser
| ) |  |

Definition at line 252 of file token.c.

References _syck_parser::input_type, syck_bytecode_utf8, syck_yaml_utf16, syck_yaml_utf32, syck_yaml_utf8, syckerror(), sycklex_bytecode_utf8(), sycklex_yaml_utf8(), and YAML_DOCSEP.

int sycklex_bytecode_utf8 | ( | YYSTYPE * | ,
|  | SyckParser * |
| ) |  |

Definition at line 134 of file bytecode.c.

References ADD_BYTE_LEVEL, CAT, CHK_NL, count, CURRENT_LEVEL, _syck_node::data, _syck_level::domain, ENSURE_YAML_IEND, FORCE_NEXT_TOKEN, _syck_parser::force_token, free(), get_inline(), i, _syck_parser::implicit_typing, YYSTYPE::name, _syck_level::ncount, YYSTYPE::nodeData, NULL, POP_LEVEL, S_ALLOC_N, S_MEMCPY, _syck_level::spaces, _syck_level::status, strscanner::str, _syck_node::str, strlen(), strtod, syck_alloc_str(), syck_hdlr_remove_anchor(), syck_lvl_doc, syck_lvl_header, syck_lvl_map, syck_lvl_open, syck_lvl_seq, syck_lvl_str, syck_parser_read(), syck_strndup(), _syck_parser::taguri_expansion, tok, try_tag_implicit(), YAML_ALIAS, YAML_ANCHOR, YAML_DOCSEP, YAML_IEND, YAML_INDENT, YAML_IOPEN, YAML_ITRANSFER, YAML_PLAIN, YAML_TAGURI, YAML_TRANSFER, YYCTYPE, YYCURSOR, YYFILL, YYLIMIT, YYMARKER, YYPOS, and YYTOKEN.

Referenced by sycklex().

int sycklex_yaml_utf8 | ( | YYSTYPE * | sycklval,
|  | SyckParser * | parser
| ) |  |

Definition at line 277 of file token.c.

References ADD_LEVEL, BLOCK_FOLD, BLOCK_LIT, CURRENT_LEVEL, _syck_node::data, _syck_level::domain, eat_comments(), ENSURE_YAML_IEND, ENSURE_YAML_IOPEN, escape_seq(), FORCE_NEXT_TOKEN, _syck_parser::force_token, free(), GET_TRUE_YAML_INDENT, GOBBLE_UP_YAML_INDENT, i, is_newline(), YYSTYPE::name, newline_len(), NL_CHOMP, NL_KEEP, YYSTYPE::nodeData, NULL, PLAIN_IS_INL, PLAIN_NOT_INL, POP_LEVEL, QUOTECAT, QUOTECATS, rb_long2int, RETURN_IMPLICIT, RETURN_YAML_BLOCK, S_ALLOC_N, scalar_1quote, scalar_2quote, _syck_level::spaces, _syck_level::status, _syck_node::str, strlen(), strtol(), syck_alloc_str(), syck_hdlr_remove_anchor(), syck_lvl_block, syck_lvl_doc, syck_lvl_header, syck_lvl_imap, syck_lvl_iseq, syck_lvl_map, syck_lvl_seq, syck_lvl_str, syck_parser_read(), syck_strndup(), syck_taguri(), tok, _syck_node::type_id, YAML_ALIAS, YAML_ANCHOR, YAML_DOCSEP, YAML_DOMAIN, YAML_INDENT, YAML_IOPEN, YAML_ITRANSFER, YAML_PLAIN, YAML_TRANSFER, YYCTYPE, YYCURSOR, YYFILL, YYLIMIT, YYLINEPTR, YYMARKER, YYPOS, YYTOKEN, and YYTOKTMP.

Referenced by sycklex().

int syckwrap | ( |  | ) |

Definition at line 2710 of file token.c.

## Variable Documentation

SyckParser* syck_parser_ptr = NULL

Definition at line 233 of file token.c.