1 /*===-- FileLexer.l - Scanner for TableGen Files ----------------*- C++ -*-===//
4 //===------------------------------------------------------------------------=*/
9 %option never-interactive
14 %option outfile="Lexer.cpp"
22 typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
23 #include "FileParser.h"
25 // ParseInt - This has to handle the special case of binary numbers 0b0101
26 static int ParseInt(const char *Str) {
27 if (Str[0] == '0' && Str[1] == 'b')
28 return strtol(Str+2, 0, 2);
29 return strtol(Str, 0, 0);
36 Identifier [a-zA-Z_][0-9a-zA-Z_]*
37 Integer [-+]?[0-9]+|0x[0-9a-fA-F]+|0b[01]+
42 {Comment} { /* Ignore comments */ }
47 string { return STRING; }
50 class { return CLASS; }
52 field { return FIELD; }
56 {Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
59 {StringVal} { Filelval.StrVal = new std::string(yytext+1, yytext+yyleng-1);
62 {Integer} { Filelval.IntVal = ParseInt(Filetext); return INTVAL; }
64 [ \t\n]+ { /* Ignore whitespace */ }
65 . { return Filetext[0]; }