📄 parser.l
字号:
%{
/*
* This file is part of tMCimg.
*
* tMCimg is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdlib.h>
#include "parser.tab.h"
extern void yyerror(const char *);
int linenumber = 0;
/* Clean up behavior of parser a bit */
#define YY_NO_UNPUT 1
#define YY_NEVER_INTERACTIVE 1
%}
/* Characters allowed in unquoted filenames */
FILENAME [-_#.+a-zA-Z0-9/]
%option caseless
%option noyywrap
%s INQ ENDQ
%%
/* Tokens, most of which can be abreviated */
nphotons return NPHOTONS;
seed return SEED;
seg[mentation_file]* return SEGFILE;
freq return FREQUENCY;
c0 return CLIGHT;
start_?time return STIME;
gate_?width return DTIME;
ngates? return NTIME;
tissue return TISSUETYPE;
mus return MUS;
mua return MUA;
g return G;
index return N;
n return N;
det return DETECTOR;
detector return DETECTOR;
src return SOURCE;
source return SOURCE;
pos return SDPOS;
position return SDPOS;
dir return SDDIR;
direction return SDDIR;
rad return SDRAD;
radius return SDRAD;
na return SDNA;
img_?x return IMGX;
img_?y return IMGY;
img_?z return IMGZ;
image_?x return IMGX;
image_?y return IMGY;
image_?z return IMGZ;
dx return DX;
dy return DY;
dz return DZ;
nxvox return NXSTEP;
nyvox return NYSTEP;
nzvox return NZSTEP;
set_?flag return SETFLAG;
gen_twopt return FTWOPT;
source_move return FSMOVE;
detector_move return FDMOVE;
exiting_move return FXMOVE;
exact_exit_time return FXTIME;
matlab_order return FMATLAB;
mirror return FMIRROR;
/* Quoted filenames must start with a normal */
/* FILENAME character but may contain embedded */
/* special characters (space, etc.) after that */
\"/{FILENAME} BEGIN(INQ);
<INQ>.*/\" { yylval.string = yytext; BEGIN(ENDQ);
return FILENAME; }
<ENDQ>\" BEGIN(INITIAL);
/* Primitives */
[-+0-9]+ { yylval.integer = atoi(yytext); return DECNUMBER; }
[-+.eE0-9]+ { yylval.real = atof(yytext); return REALNUMBER; }
{FILENAME}+ { yylval.string = yytext; return FILENAME; }
"[" return '['; /* begin vector */
"]" return ']'; /* end vector */
"{" return '{'; /* begin grouping */
"}" return '}'; /* end grouping */
, /* IGNORE: optional separator */
= /* IGNORE: optional assignment */
;.* /* IGNORE: comment */
[ \t]+ /* IGNORE: whitespace */
\r?\n linenumber++; /* End of line */
<*><<EOF>> return 0; /* Done, returns zero */
. yyerror("Unrecognized token");
%%
void parsefile(FILE *fp)
{
extern int yyparse(void *);
/* Reset the parser with a new file pointer */
yyrestart(fp);
/* Parse this file */
yyparse(NULL);
/* Done */
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -