⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parser.tab.c

📁 蒙特卡罗模拟光子成像C语言版,代码简洁专业
💻 C
📖 第 1 页 / 共 4 页
字号:
/* A Bison parser, made from parser.y
   by GNU bison 1.35.  */

#define YYBISON 1  /* Identify Bison output.  */

# define	NPHOTONS	257
# define	SEED	258
# define	SEGFILE	259
# define	FREQUENCY	260
# define	CLIGHT	261
# define	STIME	262
# define	NTIME	263
# define	DTIME	264
# define	TISSUETYPE	265
# define	MUS	266
# define	MUA	267
# define	G	268
# define	N	269
# define	SOURCE	270
# define	DETECTOR	271
# define	SDPOS	272
# define	SDDIR	273
# define	SDRAD	274
# define	SDNA	275
# define	DX	276
# define	DY	277
# define	DZ	278
# define	IMGX	279
# define	IMGY	280
# define	IMGZ	281
# define	NXSTEP	282
# define	NYSTEP	283
# define	NZSTEP	284
# define	SETFLAG	285
# define	FTWOPT	286
# define	FSMOVE	287
# define	FDMOVE	288
# define	FXMOVE	289
# define	FXTIME	290
# define	FMATLAB	291
# define	FMIRROR	292
# define	FILENAME	293
# define	REALNUMBER	294
# define	DECNUMBER	295

#line 1 "parser.y"

/*
 * 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "config.h"
#include "tMCimg.h"

#if (HAVE_ASSERT_H)
#include <assert.h>
#endif

static double tmpmus, tmpmua, tmpn, tmpg;
static double tmppos[3], tmpdir[3], tmprad, tmpna;
static struct Config *config = NULL;
 
void init_config(void);
int  checkconfig(void);
void add_tissue(double mus, double mua, double g, double n);
void add_detector(double r[3], double d[3], double rad, double na);
void   add_source(double r[3], double d[3], double rad, double na);

#define YYDEBUG 0

extern void parsefile(FILE *);
extern int yylex();

void yyerror(const char *s)
{
  extern int linenumber;
  extern char *yytext;

  fprintf(stderr, "%s\n", (s == NULL) ? "" : s);
  fprintf(stderr, "Error on line %d near text \"%s\"\n", 
          linenumber, (yytext == NULL) ? "" : yytext);

  return;
}

#line 60 "parser.y"
#ifndef YYSTYPE
typedef union {
  double      real;
  int         integer;
  const char *string;
  char        character;
  int        *ipointer;
  double     *rpointer;
} yystype;
# define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1
#endif
#ifndef YYDEBUG
# define YYDEBUG 0
#endif



#define	YYFINAL		99
#define	YYFLAG		-32768
#define	YYNTBASE	46

/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
#define YYTRANSLATE(x) ((unsigned)(x) <= 295 ? yytranslate[x] : 59)

/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
static const char yytranslate[] =
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,    44,     2,    45,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,    42,     2,    43,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     3,     4,     5,
       6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
      36,    37,    38,    39,    40,    41
};

#if YYDEBUG
static const short yyprhs[] =
{
       0,     0,     1,     4,     7,     9,    11,    13,    15,    17,
      20,    23,    26,    29,    32,    35,    38,    41,    44,    47,
      50,    53,    56,    59,    62,    65,    68,    71,    75,    79,
      83,    87,    91,    95,    99,   102,   105,   108,   111,   114,
     117,   120,   123,   126,   129,   132,   135,   138,   141,   144,
     147,   150,   156,   159,   161,   163
};
static const short yyrhs[] =
{
      -1,    46,    47,     0,    46,     1,     0,    49,     0,    48,
       0,    50,     0,    52,     0,    51,     0,     3,    41,     0,
       4,    41,     0,     5,    39,     0,     6,    58,     0,     7,
      58,     0,     8,    58,     0,    10,    58,     0,     9,    58,
       0,    25,    56,     0,    26,    56,     0,    27,    56,     0,
      22,    58,     0,    23,    58,     0,    24,    58,     0,    28,
      58,     0,    29,    58,     0,    30,    58,     0,    31,    49,
       0,    31,    32,    57,     0,    31,    33,    57,     0,    31,
      34,    57,     0,    31,    35,    57,     0,    31,    36,    57,
       0,    31,    37,    57,     0,    31,    38,    57,     0,    11,
      42,     0,    50,    53,     0,    50,    43,     0,    17,    42,
       0,    51,    54,     0,    51,    43,     0,    16,    42,     0,
      52,    54,     0,    52,    43,     0,    12,    58,     0,    13,
      58,     0,    14,    58,     0,    15,    58,     0,    20,    58,
       0,    21,    58,     0,    18,    55,     0,    19,    55,     0,
      44,    58,    58,    58,    45,     0,    41,    41,     0,    41,
       0,    40,     0,    41,     0
};

#endif

#if YYDEBUG
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const short yyrline[] =
{
       0,   125,   126,   127,   129,   130,   131,   132,   133,   135,
     136,   137,   138,   139,   140,   141,   142,   143,   144,   145,
     146,   147,   148,   149,   150,   151,   152,   154,   159,   164,
     169,   174,   179,   184,   190,   192,   193,   202,   206,   207,
     210,   214,   215,   218,   219,   220,   221,   223,   224,   225,
     227,   230,   240,   247,   252,   253
};
#endif


#if (YYDEBUG) || defined YYERROR_VERBOSE

/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
static const char *const yytname[] =
{
  "$", "error", "$undefined.", "NPHOTONS", "SEED", "SEGFILE", "FREQUENCY", 
  "CLIGHT", "STIME", "NTIME", "DTIME", "TISSUETYPE", "MUS", "MUA", "G", 
  "N", "SOURCE", "DETECTOR", "SDPOS", "SDDIR", "SDRAD", "SDNA", "DX", 
  "DY", "DZ", "IMGX", "IMGY", "IMGZ", "NXSTEP", "NYSTEP", "NZSTEP", 
  "SETFLAG", "FTWOPT", "FSMOVE", "FDMOVE", "FXMOVE", "FXTIME", "FMATLAB", 
  "FMIRROR", "FILENAME", "REALNUMBER", "DECNUMBER", "'{'", "'}'", "'['", 
  "']'", "input", "statement", "option", "flag", "tissue", "detector", 
  "source", "tissue_prop", "sd_prop", "vector", "range", "bool", "number", 0
};
#endif

/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const short yyr1[] =
{
       0,    46,    46,    46,    47,    47,    47,    47,    47,    48,
      48,    48,    48,    48,    48,    48,    48,    48,    48,    48,
      48,    48,    48,    48,    48,    48,    48,    49,    49,    49,
      49,    49,    49,    49,    50,    50,    50,    51,    51,    51,
      52,    52,    52,    53,    53,    53,    53,    54,    54,    54,
      54,    55,    56,    57,    58,    58
};

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const short yyr2[] =
{
       0,     0,     2,     2,     1,     1,     1,     1,     1,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     3,     3,     3,
       3,     3,     3,     3,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     5,     2,     1,     1,     1
};

/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
   doesn't specify something else to do.  Zero means the default is an
   error. */
static const short yydefact[] =
{
       1,     0,     3,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     2,     5,     4,     6,     8,     7,
       9,    10,    11,    54,    55,    12,    13,    14,    16,    15,
      34,    40,    37,    20,    21,    22,     0,    17,    18,    19,
      23,    24,    25,     0,     0,     0,     0,     0,     0,     0,
       0,    26,     0,     0,     0,     0,    36,    35,     0,     0,
       0,     0,    39,    38,    42,    41,    52,    53,    27,    28,
      29,    30,    31,    32,    33,    43,    44,    45,    46,     0,
      49,    50,    47,    48,     0,     0,     0,    51,     0,     0
};

static const short yydefgoto[] =
{
       1,    24,    25,    26,    27,    28,    29,    67,    73,    90,
      47,    78,    35
};

static const short yypact[] =
{
  -32768,    16,-32768,   -35,   -29,   -21,   -36,   -36,   -36,   -36,
     -36,    12,    17,    18,   -36,   -36,   -36,    11,    11,    11,
     -36,   -36,   -36,    43,-32768,-32768,-32768,    22,    10,    30,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,-32768,    20,-32768,-32768,-32768,
  -32768,-32768,-32768,    34,    21,    21,    21,    21,    21,    21,
      21,-32768,   -36,   -36,   -36,   -36,-32768,-32768,    39,    39,
     -36,   -36,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   -36,
  -32768,-32768,-32768,-32768,   -36,   -36,    40,-32768,    84,-32768
};

static const short yypgoto[] =
{
  -32768,-32768,-32768,    63,-32768,-32768,-32768,-32768,    60,    27,
      -8,    35,    -7
};


#define	YYLAST		96


static const short yytable[] =
{
      36,    37,    38,    39,    33,    34,    30,    43,    44,    45,
      48,    49,    31,    50,    51,    52,    98,     2,    32,     3,
       4,     5,     6,     7,     8,     9,    10,    11,    68,    69,
      70,    71,    12,    13,    62,    63,    64,    65,    14,    15,
      16,    17,    18,    19,    20,    21,    22,    23,    68,    69,
      70,    71,    46,    72,    40,    85,    86,    87,    88,    41,
      42,    76,    77,    92,    93,    66,    54,    55,    56,    57,
      58,    59,    60,    74,    53,    54,    55,    56,    57,    58,
      59,    60,    94,    89,    99,    97,    61,    95,    96,    75,
      79,    80,    81,    82,    83,    84,    91
};

static const short yycheck[] =
{
       7,     8,     9,    10,    40,    41,    41,    14,    15,    16,
      18,    19,    41,    20,    21,    22,     0,     1,    39,     3,
       4,     5,     6,     7,     8,     9,    10,    11,    18,    19,
      20,    21,    16,    17,    12,    13,    14,    15,    22,    23,
      24,    25,    26,    27,    28,    29,    30,    31,    18,    19,
      20,    21,    41,    43,    42,    62,    63,    64,    65,    42,
      42,    41,    41,    70,    71,    43,    32,    33,    34,    35,
      36,    37,    38,    43,    31,    32,    33,    34,    35,    36,
      37,    38,    89,    44,     0,    45,    23,    94,    95,    29,
      55,    56,    57,    58,    59,    60,    69
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/share/bison/bison.simple"

/* Skeleton output parser for bison,

   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
   Foundation, Inc.

   This program 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, 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.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

/* This is the parser code that is written into each bison parser when
   the %semantic_parser declaration is not specified in the grammar.
   It was written by Richard Stallman by simplifying the hairy parser
   used when %semantic_parser is specified.  */

/* All symbols defined below should begin with yy or YY, to avoid
   infringing on user name space.  This should be done even for local
   variables, as they might otherwise be expanded by user macros.
   There are some unavoidable exceptions within include files to
   define necessary library symbols; they are noted "INFRINGES ON
   USER NAME SPACE" below.  */

#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# if YYSTACK_USE_ALLOCA
#  define YYSTACK_ALLOC alloca
# else
#  ifndef YYSTACK_USE_ALLOCA
#   if defined (alloca) || defined (_ALLOCA_H)
#    define YYSTACK_ALLOC alloca
#   else
#    ifdef __GNUC__
#     define YYSTACK_ALLOC __builtin_alloca
#    endif
#   endif
#  endif
# endif

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's `empty if-body' warning. */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# else
#  if defined (__STDC__) || defined (__cplusplus)
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   define YYSIZE_T size_t
#  endif
#  define YYSTACK_ALLOC malloc
#  define YYSTACK_FREE free
# endif
#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */


#if (! defined (yyoverflow) \
     && (! defined (__cplusplus) \
	 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  short yyss;
  YYSTYPE yyvs;
# if YYLSP_NEEDED
  YYLTYPE yyls;
# endif
};

/* The size of the maximum gap between one aligned stack and the next.  */
# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# if YYLSP_NEEDED
#  define YYSTACK_BYTES(N) \
     ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))	\
      + 2 * YYSTACK_GAP_MAX)
# else
#  define YYSTACK_BYTES(N) \
     ((N) * (sizeof (short) + sizeof (YYSTYPE))				\
      + YYSTACK_GAP_MAX)
# endif

/* Copy COUNT objects from FROM to TO.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if 1 < __GNUC__
#   define YYCOPY(To, From, Count) \
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
#  else
#   define YYCOPY(To, From, Count)		\
      do					\
	{					\
	  register YYSIZE_T yyi;		\
	  for (yyi = 0; yyi < (Count); yyi++)	\
	    (To)[yyi] = (From)[yyi];		\
	}					\
      while (0)
#  endif
# endif

/* Relocate STACK from its old location to the new one.  The
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   elements in the stack, and YYPTR gives the new location of the
   stack.  Advance YYPTR to a properly aligned location for the next
   stack.  */
# define YYSTACK_RELOCATE(Stack)					\
    do									\
      {									\
	YYSIZE_T yynewbytes;						\
	YYCOPY (&yyptr->Stack, Stack, yysize);				\
	Stack = &yyptr->Stack;						\
	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;	\
	yyptr += yynewbytes / sizeof (*yyptr);				\
      }									\
    while (0)

#endif


#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -