mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-05 13:09:10 +00:00
e62c1185be
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4843 91177308-0d34-0410-b5e6-96231b3b80d8
67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
/*===-- FileLexer.l - Scanner for TableGen Files ----------------*- C++ -*-===//
|
|
//
|
|
//
|
|
//===------------------------------------------------------------------------=*/
|
|
|
|
%option prefix="File"
|
|
%option yylineno
|
|
%option nostdinit
|
|
%option never-interactive
|
|
%option batch
|
|
%option noyywrap
|
|
%option nodefault
|
|
%option 8bit
|
|
%option outfile="Lexer.cpp"
|
|
%option ecs
|
|
%option noreject
|
|
%option noyymore
|
|
|
|
|
|
%{
|
|
#include "Record.h"
|
|
typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
|
|
#include "FileParser.h"
|
|
|
|
// ParseInt - This has to handle the special case of binary numbers 0b0101
|
|
static int ParseInt(const char *Str) {
|
|
if (Str[0] == '0' && Str[1] == 'b')
|
|
return strtol(Str+2, 0, 2);
|
|
return strtol(Str, 0, 0);
|
|
}
|
|
|
|
%}
|
|
|
|
Comment \/\/.*
|
|
|
|
Identifier [a-zA-Z_][0-9a-zA-Z_]*
|
|
Integer [-+]?[0-9]+|0x[0-9a-fA-F]+|0b[01]+
|
|
StringVal \"[^"]*\"
|
|
|
|
%%
|
|
|
|
{Comment} { /* Ignore comments */ }
|
|
|
|
int { return INT; }
|
|
bit { return BIT; }
|
|
bits { return BITS; }
|
|
string { return STRING; }
|
|
list { return LIST; }
|
|
|
|
class { return CLASS; }
|
|
def { return DEF; }
|
|
field { return FIELD; }
|
|
set { return SET; }
|
|
in { return IN; }
|
|
|
|
{Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
|
|
return ID; }
|
|
|
|
{StringVal} { Filelval.StrVal = new std::string(yytext+1, yytext+yyleng-1);
|
|
return STRVAL; }
|
|
|
|
{Integer} { Filelval.IntVal = ParseInt(Filetext); return INTVAL; }
|
|
|
|
[ \t\n]+ { /* Ignore whitespace */ }
|
|
. { return Filetext[0]; }
|
|
%%
|