uBlink  0.0.1
TheBlinkProtocol
blink_lexer

Description

Used by blink_schema to convert schema syntax into tokens and values.

Functions

enum blink_token BLINK_Lexer_getToken (blink_stream_t in, char *buffer, size_t max, union blink_token_value *value, struct blink_token_location *location)
 Use this function to convert a stream of characters into a token. More...
 
const char * BLINK_Lexer_tokenToString (enum blink_token token)
 Convert a token enum to a string representation. More...
 

Data Structures

Typedefs

typedef struct blink_streamblink_stream_t
 

Enumerations

enum  blink_token {
  TOK_STRING = 0, TOK_BINARY, TOK_FIXED, TOK_BOOL,
  TOK_U8, TOK_U16, TOK_U32, TOK_U64,
  TOK_I8, TOK_I16, TOK_I32, TOK_I64,
  TOK_F64, TOK_DATE, TOK_TIME_OF_DAY_MILLI, TOK_TIME_OF_DAY_NANO,
  TOK_MILLI_TIME, TOK_NANO_TIME, TOK_DECIMAL, TOK_OBJECT,
  TOK_NAME, TOK_CNAME, TOK_EQUAL, TOK_COMMA,
  TOK_PERIOD, TOK_QUESTION, TOK_LBRACKET, TOK_RBRACKET,
  TOK_LPAREN, TOK_RPAREN, TOK_STAR, TOK_BAR,
  TOK_SLASH, TOK_AT, TOK_COLON, TOK_RARROW,
  TOK_LARROW, TOK_NAMESPACE, TOK_SCHEMA, TOK_TYPE,
  TOK_UINT, TOK_INT, TOK_LITERAL, TOK_UNKNOWN,
  TOK_EOF, TOK_ENOMEM
}
 

Data Structure Documentation

union blink_token_value
Data Fields
struct blink_token_value literal
uint64_t number Initialised for TOK_UINT.
int64_t signedNumber Initialised for TOK_INT.
struct blink_token_value.literal
Data Fields
size_t len
char * ptr
struct blink_token_location
Data Fields
size_t col
size_t row

Enumeration Type Documentation

Enumerator
TOK_STRING 

string

TOK_BINARY 

binary

TOK_FIXED 

fixed

TOK_BOOL 

bool

TOK_U8 

u8

TOK_U16 

u16

TOK_U32 

u32

TOK_U64 

u64

TOK_I8 

i8

TOK_I16 

i16

TOK_I32 

i32

TOK_I64 

i64

TOK_F64 

f64

TOK_DATE 

date

TOK_TIME_OF_DAY_MILLI 

timeOfDayMilli

TOK_TIME_OF_DAY_NANO 

timeOfDayNano

TOK_MILLI_TIME 

milltime

TOK_NANO_TIME 

nanotime

TOK_DECIMAL 

decimal

TOK_OBJECT 

object

TOK_NAME 

[\\]?[A-Za-z_][A-Za-z_0-9]+

TOK_CNAME 

[A-Za-z_][A-Za-z_0-9]+:[A-Za-z_][A-Za-z_0-9]

TOK_EQUAL 

=

TOK_COMMA 

,

TOK_PERIOD 

<period>

TOK_QUESTION 

?

TOK_LBRACKET 

[

TOK_RBRACKET 

]

TOK_LPAREN 

(

TOK_RPAREN 

)

TOK_STAR 

*

TOK_BAR 

|

TOK_SLASH 

/

TOK_AT 

@

TOK_COLON 

:

TOK_RARROW 

->

TOK_LARROW 

<-

TOK_NAMESPACE 

namespace

TOK_SCHEMA 

schema

TOK_TYPE 

type

TOK_UINT 

<uint> [0][x][0-9a-fA-F][0-9a-fA-F]+ | [0-9]+

TOK_INT 

<int> [-][1-9][0-9]*

TOK_LITERAL 

<literal> a string within double or single quotation marks

TOK_UNKNOWN 

<unknown> no match

TOK_EOF 

<eof> end of file

TOK_ENOMEM 

inconclusive token due to not enough memory

Function Documentation

enum blink_token BLINK_Lexer_getToken ( blink_stream_t  in,
char *  buffer,
size_t  max,
union blink_token_value value,
struct blink_token_location location 
)

Use this function to convert a stream of characters into a token.

Parameters
[in]ininput stream
[in]buffera buffer for caching name, cname, or literal
[in]maxbyte length of buffer
[out]valuevalue of token (only initialised for TOK_NAME, TOK_CNAME, TOK_UINT, TOK_INT, TOK_LITERAL)
[out]locationoptional location information
Returns
token
Examples:
tc_blink_lexer_gettoken.c.
const char* BLINK_Lexer_tokenToString ( enum blink_token  token)

Convert a token enum to a string representation.

Parameters
[in]tokentoken to convert to string
Returns
null terminated string