slow_blink 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/slow_blink/ext_schema_parser/common.h +27 -0
- data/ext/slow_blink/ext_schema_parser/extconf.rb +3 -0
- data/ext/slow_blink/ext_schema_parser/lexer.c +2701 -0
- data/ext/slow_blink/ext_schema_parser/lexer.h +486 -0
- data/ext/slow_blink/ext_schema_parser/parser.c +3848 -0
- data/ext/slow_blink/ext_schema_parser/parser.h +110 -0
- data/ext/slow_blink/ext_schema_parser/parser.l +139 -0
- data/ext/slow_blink/ext_schema_parser/parser.y +932 -0
- data/lib/slow_blink/annotatable.rb +46 -0
- data/lib/slow_blink/annotation.rb +38 -0
- data/lib/slow_blink/compact_encoder.rb +97 -0
- data/lib/slow_blink/component_reference.rb +50 -0
- data/lib/slow_blink/definition.rb +57 -0
- data/lib/slow_blink/enumeration.rb +105 -0
- data/lib/slow_blink/error.rb +4 -0
- data/lib/slow_blink/field.rb +82 -0
- data/lib/slow_blink/group.rb +129 -0
- data/lib/slow_blink/incremental_annotation.rb +91 -0
- data/lib/slow_blink/message.rb +43 -0
- data/lib/slow_blink/name_with_id.rb +49 -0
- data/lib/slow_blink/schema.rb +135 -0
- data/lib/slow_blink/sym.rb +54 -0
- data/lib/slow_blink/type.rb +448 -0
- data/lib/slow_blink/version.rb +22 -0
- data/lib/slow_blink.rb +20 -0
- data/rakefile +29 -0
- data/test/integration/capture_stderr.rb +20 -0
- data/test/integration/tc_inputs.rb +57 -0
- metadata +36 -5
@@ -0,0 +1,110 @@
|
|
1
|
+
/* A Bison parser, made by GNU Bison 3.0.2. */
|
2
|
+
|
3
|
+
/* Skeleton interface for Bison GLR parsers in C
|
4
|
+
|
5
|
+
Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
6
|
+
|
7
|
+
This program is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
This program is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
19
|
+
|
20
|
+
/* As a special exception, you may create a larger work that contains
|
21
|
+
part or all of the Bison parser skeleton and distribute that work
|
22
|
+
under terms of your choice, so long as that work isn't itself a
|
23
|
+
parser generator using the skeleton or a modified version thereof
|
24
|
+
as a parser skeleton. Alternatively, if you modify or redistribute
|
25
|
+
the parser skeleton itself, you may (at your option) remove this
|
26
|
+
special exception, which will cause the skeleton and the resulting
|
27
|
+
Bison output files to be licensed under the GNU General Public
|
28
|
+
License without this special exception.
|
29
|
+
|
30
|
+
This special exception was added by the Free Software Foundation in
|
31
|
+
version 2.2 of Bison. */
|
32
|
+
|
33
|
+
#ifndef YY_YY_EXT_SLOW_BLINK_EXT_SCHEMA_PARSER_PARSER_H_INCLUDED
|
34
|
+
# define YY_YY_EXT_SLOW_BLINK_EXT_SCHEMA_PARSER_PARSER_H_INCLUDED
|
35
|
+
/* Debug traces. */
|
36
|
+
#ifndef YYDEBUG
|
37
|
+
# define YYDEBUG 0
|
38
|
+
#endif
|
39
|
+
#if YYDEBUG
|
40
|
+
extern int yydebug;
|
41
|
+
#endif
|
42
|
+
|
43
|
+
/* Token type. */
|
44
|
+
#ifndef YYTOKENTYPE
|
45
|
+
# define YYTOKENTYPE
|
46
|
+
enum yytokentype
|
47
|
+
{
|
48
|
+
TOK_I8 = 258,
|
49
|
+
TOK_I16 = 259,
|
50
|
+
TOK_I32 = 260,
|
51
|
+
TOK_I64 = 261,
|
52
|
+
TOK_U8 = 262,
|
53
|
+
TOK_U16 = 263,
|
54
|
+
TOK_U32 = 264,
|
55
|
+
TOK_U64 = 265,
|
56
|
+
TOK_F64 = 266,
|
57
|
+
TOK_DECIMAL = 267,
|
58
|
+
TOK_DATE = 268,
|
59
|
+
TOK_TIME_OF_DAY_MILLI = 269,
|
60
|
+
TOK_TIME_OF_DAY_NANO = 270,
|
61
|
+
TOK_NANO_TIME = 271,
|
62
|
+
TOK_MILLI_TIME = 272,
|
63
|
+
TOK_BOOLEAN = 273,
|
64
|
+
TOK_STRING = 274,
|
65
|
+
TOK_OBJECT = 275,
|
66
|
+
TOK_NAMESPACE = 276,
|
67
|
+
TOK_TYPE = 277,
|
68
|
+
TOK_SCHEMA = 278,
|
69
|
+
TOK_BINARY = 279,
|
70
|
+
TOK_NUMBER = 280,
|
71
|
+
TOK_FIXED = 281,
|
72
|
+
TOK_LEFT_ARROW = 282,
|
73
|
+
TOK_RIGHT_ARROW = 283,
|
74
|
+
TOK_HEX = 284,
|
75
|
+
TOK_UINT = 285,
|
76
|
+
TOK_INT = 286,
|
77
|
+
TOK_NAME = 287,
|
78
|
+
TOK_NC_NAME = 288,
|
79
|
+
TOK_ESCAPED_NC_NAME = 289,
|
80
|
+
TOK_C_NAME = 290,
|
81
|
+
TOK_LITERAL = 291
|
82
|
+
};
|
83
|
+
#endif
|
84
|
+
|
85
|
+
/* Value type. */
|
86
|
+
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
87
|
+
typedef VALUE YYSTYPE;
|
88
|
+
# define YYSTYPE_IS_TRIVIAL 1
|
89
|
+
# define YYSTYPE_IS_DECLARED 1
|
90
|
+
#endif
|
91
|
+
|
92
|
+
/* Location type. */
|
93
|
+
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
94
|
+
typedef struct YYLTYPE YYLTYPE;
|
95
|
+
struct YYLTYPE
|
96
|
+
{
|
97
|
+
int first_line;
|
98
|
+
int first_column;
|
99
|
+
int last_line;
|
100
|
+
int last_column;
|
101
|
+
};
|
102
|
+
# define YYLTYPE_IS_DECLARED 1
|
103
|
+
# define YYLTYPE_IS_TRIVIAL 1
|
104
|
+
#endif
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
int yyparse (yyscan_t scanner, VALUE filename, VALUE *tree);
|
109
|
+
|
110
|
+
#endif /* !YY_YY_EXT_SLOW_BLINK_EXT_SCHEMA_PARSER_PARSER_H_INCLUDED */
|
@@ -0,0 +1,139 @@
|
|
1
|
+
/* Blink Protocol Flex Configuration
|
2
|
+
*
|
3
|
+
* Cameron Harper 2016
|
4
|
+
*
|
5
|
+
* */
|
6
|
+
%{
|
7
|
+
|
8
|
+
/* includes ***********************************************************/
|
9
|
+
|
10
|
+
#include <float.h>
|
11
|
+
#include <ruby.h>
|
12
|
+
#include "parser.h"
|
13
|
+
|
14
|
+
/* static prototypes **************************************************/
|
15
|
+
|
16
|
+
/**
|
17
|
+
* - Inserted into lexer as part of the YY_USER_ACTION macro
|
18
|
+
* -
|
19
|
+
*
|
20
|
+
* @param[in] loc pointer to Bison location record
|
21
|
+
* @param[in] text
|
22
|
+
* @param[in] textLen length of text in bytes
|
23
|
+
*
|
24
|
+
* */
|
25
|
+
static void updateLocation(YYLTYPE *loc, const char *text, int textLen);
|
26
|
+
|
27
|
+
/* macros *************************************************************/
|
28
|
+
|
29
|
+
#define YY_USER_ACTION updateLocation(yylloc, yytext, yyleng);
|
30
|
+
|
31
|
+
/* generated **********************************************************/
|
32
|
+
|
33
|
+
%}
|
34
|
+
|
35
|
+
%top{
|
36
|
+
|
37
|
+
#include "common.h"
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
%option nounput
|
42
|
+
%option noinput
|
43
|
+
%option bison-bridge bison-locations
|
44
|
+
%option reentrant
|
45
|
+
%option noyywrap
|
46
|
+
%option debug
|
47
|
+
|
48
|
+
|
49
|
+
%x LITERAL_C
|
50
|
+
%x LITERAL_A
|
51
|
+
|
52
|
+
%%
|
53
|
+
|
54
|
+
"#"[^\r\n]* { /* skip comments */ }
|
55
|
+
|
56
|
+
"\"" { BEGIN(LITERAL_C); }
|
57
|
+
<LITERAL_C>[^\"]* { *yylval = rb_str_new(yytext, yyleng); return TOK_LITERAL; }
|
58
|
+
<LITERAL_C>"\"" { BEGIN(INITIAL); }
|
59
|
+
|
60
|
+
"'" { BEGIN(LITERAL_A); }
|
61
|
+
<LITERAL_A>[^']* { *yylval = rb_str_new(yytext, yyleng); return TOK_LITERAL; }
|
62
|
+
<LITERAL_A>"'" { BEGIN(INITIAL); }
|
63
|
+
|
64
|
+
"=" |
|
65
|
+
"," |
|
66
|
+
"?" |
|
67
|
+
"[" |
|
68
|
+
"]" |
|
69
|
+
"(" |
|
70
|
+
")" |
|
71
|
+
"*" |
|
72
|
+
"|" |
|
73
|
+
"." |
|
74
|
+
"/" |
|
75
|
+
"@" |
|
76
|
+
":" { return *yytext; }
|
77
|
+
|
78
|
+
"i8" { return TOK_I8; }
|
79
|
+
"i16" { return TOK_I16; }
|
80
|
+
"i32" { return TOK_I32; }
|
81
|
+
"i64" { return TOK_I64; }
|
82
|
+
"u8" { return TOK_U8; }
|
83
|
+
"u16" { return TOK_U16; }
|
84
|
+
"u32" { return TOK_U32; }
|
85
|
+
"u64" { return TOK_U64; }
|
86
|
+
"f64" { return TOK_F64; }
|
87
|
+
"decimal" { return TOK_DECIMAL; }
|
88
|
+
"date" { return TOK_DATE; }
|
89
|
+
"timeOfDayMilli" { return TOK_TIME_OF_DAY_MILLI; }
|
90
|
+
"timeOfDayNano" { return TOK_TIME_OF_DAY_NANO; }
|
91
|
+
"nanotime" { return TOK_NANO_TIME; }
|
92
|
+
"millitime" { return TOK_MILLI_TIME; }
|
93
|
+
"bool" { return TOK_BOOLEAN; }
|
94
|
+
"string" { return TOK_STRING; }
|
95
|
+
"object" { return TOK_OBJECT; }
|
96
|
+
"namespace" { return TOK_NAMESPACE; }
|
97
|
+
"type" { return TOK_TYPE; }
|
98
|
+
"schema" { return TOK_SCHEMA; }
|
99
|
+
"number" { return TOK_NUMBER; }
|
100
|
+
"fixed" { return TOK_FIXED; }
|
101
|
+
"binary" { return TOK_BINARY; }
|
102
|
+
|
103
|
+
"->" { return TOK_RIGHT_ARROW; }
|
104
|
+
"<-" { return TOK_LEFT_ARROW; }
|
105
|
+
|
106
|
+
[0][x][0-9a-fA-F]+ { unsigned int tmp = 0; sscanf(yytext, "%x", &tmp); *yylval = UINT2NUM(tmp); return TOK_HEX; }
|
107
|
+
[0-9]+ { unsigned int tmp = 0; sscanf(yytext, "%u", &tmp); *yylval = UINT2NUM(tmp); return TOK_UINT; }
|
108
|
+
[-][1-9][0-9]* { int tmp = 0; sscanf(yytext, "%i", &tmp); *yylval = INT2NUM(tmp); return TOK_INT; }
|
109
|
+
|
110
|
+
[_a-zA-Z][_a-zA-Z0-9]*[:][_a-zA-Z][_a-zA-Z0-9]* { *yylval = rb_str_new(yytext, yyleng); return TOK_C_NAME; }
|
111
|
+
[_a-zA-Z][_a-zA-Z0-9]* { *yylval = rb_str_new(yytext, yyleng); return TOK_NC_NAME; }
|
112
|
+
[\\][_a-zA-Z][_a-zA-Z0-9]* { *yylval = rb_str_new(yytext, yyleng); return TOK_ESCAPED_NC_NAME; }
|
113
|
+
|
114
|
+
.|\n {}
|
115
|
+
|
116
|
+
%%
|
117
|
+
|
118
|
+
/* static functions ***************************************************/
|
119
|
+
|
120
|
+
static void updateLocation(YYLTYPE *loc, const char *text, int textLen)
|
121
|
+
{
|
122
|
+
int i;
|
123
|
+
|
124
|
+
loc->first_line = loc->last_line;
|
125
|
+
loc->first_column = loc->last_column;
|
126
|
+
|
127
|
+
for(i=0; i < textLen; i++){
|
128
|
+
|
129
|
+
if(text[i] == '\n'){
|
130
|
+
|
131
|
+
loc->last_line++;
|
132
|
+
loc->last_column = 0;
|
133
|
+
}
|
134
|
+
else{
|
135
|
+
|
136
|
+
loc->last_column++;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|