Baseline commit for thrift, which is pillar v2
Reviewed By: aditya
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664711 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/src/thrift.l b/compiler/src/thrift.l
new file mode 100644
index 0000000..5164c89
--- /dev/null
+++ b/compiler/src/thrift.l
@@ -0,0 +1,59 @@
+/**
+ * Thrift scanner.
+ *
+ * Tokenizes a thrift definition file.
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+%{
+
+#include "main.h"
+#include "parse/t_program.h"
+
+/** Must be included AFTER parse/t_program.h */
+#include "thrift.tab.hh"
+
+%}
+
+/** Provides yylineno global */
+%option lex-compat
+
+/** Helper definitions */
+intconstant ([0-9]+)
+identifier ([a-zA-Z_][a-zA-Z_0-9]*)
+whitespace ([ \t\r\n]*)
+multicomm ("/*""/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/")
+comment ("//"[^\n]*)
+symbol ([\,\{\}\(\)\=])
+
+%%
+
+{whitespace} { /* do nothing */ }
+{multicomm} { /* do nothing */ }
+{comment} { /* do nothing */ }
+
+{symbol} { return yytext[0]; }
+
+"byte" { return tok_byte; }
+"string" { return tok_string; }
+"i32" { return tok_i32; }
+"u32" { return tok_u32; }
+"i64" { return tok_i64; }
+"u64" { return tok_u64; }
+
+"map" { return tok_map; }
+"list" { return tok_list; }
+"set" { return tok_set; }
+
+"void" { return tok_void; }
+"async" { return tok_async; }
+
+"typedef" { return tok_typedef; }
+"struct" { return tok_struct; }
+"function" { return tok_function; }
+"service" { return tok_service; }
+"enum" { return tok_enum; }
+
+{intconstant} { yylval.iconst = atoi(yytext) ; return tok_int_constant; }
+{identifier} { yylval.id = strdup(yytext); return tok_identifier; }
+
+%%