-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add method to verify string is a number for number format Check that the input string for a number format complies with the JSON number standard. https://tools.ietf.org/html/rfc7159#section-6
- Loading branch information
Showing
8 changed files
with
242 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
/* Generated by re2c 0.16 on Tue Mar 14 22:35:40 2017 */ | ||
#line 1 "yaltcllex.re" | ||
#include <stdio.h> | ||
#include "yajltcllex.h" | ||
|
||
/* | ||
* Method: numberValidator | ||
* | ||
* Parameters: | ||
* char *YYCURSOR - Input string buffer | ||
* | ||
* Returns: | ||
* 1 if valid Number | ||
* 0 if invalid Number | ||
* | ||
* This function is generated by re2c from the | ||
* yajltcllex.re file. It is an expression based | ||
* lexer that validates the input conforms to a | ||
* number format as specified by: | ||
* https://tools.ietf.org/html/rfc7159#section-6 | ||
* | ||
* The original regex validation is: | ||
* [-]?([0]|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)? | ||
* | ||
*/ | ||
int numberValidator(const char *YYCURSOR) | ||
{ | ||
const char *YYMARKER; | ||
|
||
#line 10 "numberParser.c" | ||
{ | ||
char yych; | ||
yych = *YYCURSOR; | ||
switch (yych) { | ||
case '-': goto yy4; | ||
case '0': goto yy5; | ||
case '1': | ||
case '2': | ||
case '3': | ||
case '4': | ||
case '5': | ||
case '6': | ||
case '7': | ||
case '8': | ||
case '9': goto yy6; | ||
default: goto yy2; | ||
} | ||
yy2: | ||
++YYCURSOR; | ||
yy3: | ||
#line 13 "numberParser.re" | ||
{ return 0; } | ||
#line 33 "numberParser.c" | ||
yy4: | ||
yych = *(YYMARKER = ++YYCURSOR); | ||
switch (yych) { | ||
case '0': goto yy7; | ||
case '1': | ||
case '2': | ||
case '3': | ||
case '4': | ||
case '5': | ||
case '6': | ||
case '7': | ||
case '8': | ||
case '9': goto yy9; | ||
default: goto yy3; | ||
} | ||
yy5: | ||
yych = *(YYMARKER = ++YYCURSOR); | ||
switch (yych) { | ||
case 0x00: goto yy11; | ||
case '.': goto yy13; | ||
case 'E': | ||
case 'e': goto yy14; | ||
default: goto yy3; | ||
} | ||
yy6: | ||
yych = *(YYMARKER = ++YYCURSOR); | ||
switch (yych) { | ||
case 0x00: goto yy11; | ||
case '.': goto yy13; | ||
case '0': | ||
case '1': | ||
case '2': | ||
case '3': | ||
case '4': | ||
case '5': | ||
case '6': | ||
case '7': | ||
case '8': | ||
case '9': goto yy9; | ||
case 'E': | ||
case 'e': goto yy14; | ||
default: goto yy3; | ||
} | ||
yy7: | ||
yych = *++YYCURSOR; | ||
switch (yych) { | ||
case 0x00: goto yy11; | ||
case '.': goto yy13; | ||
case 'E': | ||
case 'e': goto yy14; | ||
default: goto yy8; | ||
} | ||
yy8: | ||
YYCURSOR = YYMARKER; | ||
goto yy3; | ||
yy9: | ||
++YYCURSOR; | ||
yych = *YYCURSOR; | ||
switch (yych) { | ||
case 0x00: goto yy11; | ||
case '.': goto yy13; | ||
case '0': | ||
case '1': | ||
case '2': | ||
case '3': | ||
case '4': | ||
case '5': | ||
case '6': | ||
case '7': | ||
case '8': | ||
case '9': goto yy9; | ||
case 'E': | ||
case 'e': goto yy14; | ||
default: goto yy8; | ||
} | ||
yy11: | ||
++YYCURSOR; | ||
#line 14 "numberParser.re" | ||
{ return 1; } | ||
#line 113 "numberParser.c" | ||
yy13: | ||
yych = *++YYCURSOR; | ||
switch (yych) { | ||
case '0': | ||
case '1': | ||
case '2': | ||
case '3': | ||
case '4': | ||
case '5': | ||
case '6': | ||
case '7': | ||
case '8': | ||
case '9': goto yy15; | ||
default: goto yy8; | ||
} | ||
yy14: | ||
yych = *++YYCURSOR; | ||
switch (yych) { | ||
case 0x00: goto yy8; | ||
case '+': | ||
case '-': goto yy17; | ||
default: goto yy19; | ||
} | ||
yy15: | ||
++YYCURSOR; | ||
yych = *YYCURSOR; | ||
switch (yych) { | ||
case 0x00: goto yy11; | ||
case '0': | ||
case '1': | ||
case '2': | ||
case '3': | ||
case '4': | ||
case '5': | ||
case '6': | ||
case '7': | ||
case '8': | ||
case '9': goto yy15; | ||
case 'E': | ||
case 'e': goto yy14; | ||
default: goto yy8; | ||
} | ||
yy17: | ||
yych = *++YYCURSOR; | ||
if (yych <= 0x00) goto yy8; | ||
goto yy19; | ||
yy18: | ||
++YYCURSOR; | ||
yych = *YYCURSOR; | ||
yy19: | ||
switch (yych) { | ||
case 0x00: goto yy11; | ||
case '0': | ||
case '1': | ||
case '2': | ||
case '3': | ||
case '4': | ||
case '5': | ||
case '6': | ||
case '7': | ||
case '8': | ||
case '9': goto yy18; | ||
default: goto yy8; | ||
} | ||
} | ||
#line 15 "numberParser.re" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* | ||
* Include file for yajllex parser | ||
* | ||
* Copyright (C) 2010 by FlightAware, All Rights Reserved | ||
* | ||
* Freely redistributable under the Berkeley copyright, see license.terms | ||
* for details. | ||
*/ | ||
|
||
/* | ||
* Validates that the input string is a valid number | ||
*/ | ||
|
||
int | ||
numberValidator(const char *YYCURSOR); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <stdio.h> | ||
|
||
int numberValidator(const char *YYCURSOR) | ||
{ | ||
const char *YYMARKER; | ||
/*!re2c | ||
re2c:define:YYCTYPE = char; | ||
re2c:yyfill:enable = 0; | ||
end = "\x00"; | ||
num = [-]?([0]|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?; | ||
* { return 0; } | ||
num end { return 1; } | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters