Created
March 22, 2018 10:50
-
-
Save seanwu1105/034b9cb71d2af9d516ee78fbf0efc1e3 to your computer and use it in GitHub Desktop.
The LEX to filter the IPv4 format.
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
%{ | |
#include <iostream> | |
#include <string> | |
%} | |
integer_in_ipv4 0|1([0-9][0-9]?)?|2([5-9]|[0-4][0-9]?|5[0-5]?)?|[3-9][0-9]? | |
ipv4 {integer_in_ipv4}\.{integer_in_ipv4}\.{integer_in_ipv4}\.{integer_in_ipv4} | |
%% | |
{ipv4} {ECHO; printf("\n");} | |
. | |
\n | |
%% | |
int main(void) | |
{ | |
yylex(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment