?? exolex.l
字號:
/* * exolex.l - EXO library lexor * * This file is a part of the SimpleScalar tool suite written by * Todd M. Austin as a part of the Multiscalar Research Project. * * The tool suite is currently maintained by Doug Burger and Todd M. Austin. * * Copyright (C) 1997 by Todd M. Austin * * This source file is distributed "as is" in the hope that it will be * useful. The tool set comes with no warranty, and no author or * distributor accepts any responsibility for the consequences of its * use. * * Everyone is granted permission to copy, modify and redistribute * this tool set under the following conditions: * * This source code is distributed for non-commercial use only. * Please contact the maintainer for restrictions applying to * commercial use. * * Permission is granted to anyone to make or distribute copies * of this source code, either as received or modified, in any * medium, provided that all copyright notices, permission and * nonwarranty notices are preserved, and that the distributor * grants the recipient permission for further redistribution as * permitted by this document. * * Permission is granted to distribute this file in compiled * or executable form under the same conditions that apply for * source code, provided that either: * * A. it is accompanied by the corresponding machine-readable * source code, * B. it is accompanied by a written offer, with no time limit, * to give anyone a machine-readable copy of the corresponding * source code in return for reimbursement of the cost of * distribution. This written offer must permit verbatim * duplication by anyone, or * C. it is distributed by someone who received only the * executable form, and is accompanied by a copy of the * written offer of source code that they received concurrently. * * In other words, you are welcome to use, share and improve this * source file. You are forbidden to forbid anyone else to use, share * and improve what you give them. * * INTERNET: dburger@cs.wisc.edu * US Mail: 1210 W. Dayton Street, Madison, WI 53706 * */%{/* C-style lexor. */#include <stdio.h>#include <stdlib.h>#include "base/misc.hh"#include "encumbered/eio/libexo.h"#include "sim/host.hh"/* maximum size token (including strings) for lex */#undef YYLMAX#define YYLMAX (16*1024)/* disable interactive features, as they are non-portable */#define YY_NEVER_INTERACTIVE 1#define YY_ALWAYS_INTERACTIVE 0#define YY_MAIN 0#define YY_STACK_USED 0unsigned line = 1; /* line of last recognized token */static void lex_eat_comment(void);%}%s BLOB_MODE%p 3000D [0-9]L [a-zA-Z_]H [a-fA-F0-9]E [Ee][+-]?{D}+C1 "/"C2 "*"P (~|!|@|#|\$|%|\^|&|\*|-|\+|\||\/|\?)%%<BLOB_MODE>{H}{H} { return lex_byte; }<INITIAL>{C1}{C2} { lex_eat_comment(); }<INITIAL>[\-]?0[xX]{H}+ { return lex_address; }<INITIAL>[\-]?0{D}+ { return lex_integer; }<INITIAL>[\-]?{D}+ { return lex_integer; }<INITIAL>[\-]?{D}+{E} { return lex_float; }<INITIAL>[\-]?{D}*"."{D}+({E})? { return lex_float; }<INITIAL>[\-]?{D}+"."{D}*({E})? { return lex_float; }<INITIAL>'(\\.|[^\\'])+' { return lex_char; }<INITIAL>\"(\\.|[^\\"])*\" /*"*/ { return lex_string; }<INITIAL>{L}({L}|{D})* { return lex_token; }<INITIAL>{P}+ { return lex_token; }<INITIAL>"{" { return '{'; }<INITIAL>"}" { return '}'; }<INITIAL>"," { return ','; }<INITIAL>"(" { return '('; }<INITIAL>")" { return ')'; }<INITIAL>"[" { return '['; }<INITIAL>"]" { return ']'; }<INITIAL>"<" { BEGIN(BLOB_MODE); return '<'; }<BLOB_MODE>">" { BEGIN(INITIAL); return '>'; }[ \t\v\f] { /* nada */; }[\n] { line++; }<<EOF>> { return lex_eof; }. { /* bogus char */ fatal("bogus character in input"); }%%intyywrap(void){ return 1;}static voidlex_eat_comment(void){ char c, c1;loop: while ((c = yyinput()) != '*' && c != 0) { if (c == '\n') line++; } if ((c1 = yyinput()) != '/' && c1 != 0) { unput(c1); goto loop; }}intyy_nextchar(void){ int c; do { c = yyinput(); } while (c == ' ' || c == '\t' || c == '\v' || c == '\f' || c == '\n'); unput(c); return c;}/* FIXME: this is a total KLUDGE (but well contained...) that I will someday address when I have copious amounts of free time... */voidyy_setstream(FILE *stream){ int i;#define MAX_STREAMS 16 static struct { FILE *stream; YY_BUFFER_STATE buffer; } streams[MAX_STREAMS] = { {NULL, NULL}, }; static int num_streams = 0; static FILE *last_stream = NULL; /* same stream? */ if (stream == last_stream) return; /* else, switch to new stream */ for (i=0; i < num_streams; i++) { if (streams[i].stream == stream) { yy_switch_to_buffer(streams[i].buffer); return; } } /* hrmmm... not found, create a new buffer for this stream */ if (num_streams == MAX_STREAMS) fatal("out of lex buffer streams, increase MAX_STREAMS"); streams[num_streams].stream = stream; streams[num_streams].buffer = yy_create_buffer(stream, YY_BUF_SIZE); yy_switch_to_buffer(streams[num_streams].buffer); num_streams++;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -