示例#1
0
Cell *execute(Node *u)	/* execute a node of the parse tree */
{
	Cell *(*proc)(Node **, int);
	Cell *x;
	Node *a;

	if (u == NULL)
		return(true);
	for (a = u; ; a = a->nnext) {
		curnode = a;
		if (isvalue(a)) {
			x = (Cell *) (a->narg[0]);
			if ((x->tval & FLD) && !donefld)
				fldbld();
			else if ((x->tval & REC) && !donerec)
				recbld();
			return(x);
		}
		if (notlegal(a->nobj))	/* probably a Cell* but too risky to print */
			ERROR "illegal statement" FATAL;
		proc = proctab[a->nobj-FIRSTTOKEN];
		x = (*proc)(a->narg, a->nobj);
		if ((x->tval & FLD) && !donefld)
			fldbld();
		else if ((x->tval & REC) && !donerec)
			recbld();
		if (isexpr(a))
			return(x);
		if (isjump(x))
			return(x);
		if (a->nnext == NULL)
			return(x);
		tempfree(x);
	}
}
示例#2
0
文件: misc.c 项目: funny-falcon/lwc
/*****************************************************************************
	check syntax patterns.
*****************************************************************************/
bool syntax_pattern (NormPtr p, Token first, ...)
{
	va_list ap;
	va_start (ap, first);
	for (;first != -1; first = va_arg (ap, Token))
		switch (first) {
		default: if (CODE [p++] != first) return 0;
		ncase VERIFY_symbol: if (!issymbol (CODE [p++])) return 0;
		ncase VERIFY_string: if (!isvalue (CODE [p++])) return 0;
		}
	va_end (ap);
	return 1;
}
示例#3
0
Node *makearr(Node *p)
{
	Cell *cp;

	if (isvalue(p)) {
		cp = (Cell *) (p->narg[0]);
		if (isfcn(cp))
			SYNTAX( "%s is a function, not an array", cp->nval );
		else if (!isarr(cp)) {
			xfree(cp->sval);
			cp->sval = (char *) makesymtab(NSYMTAB);
			cp->tval = ARR;
		}
	}
	return p;
}
示例#4
0
 std::string basis_req_parcel::value_cast<std::string>() const {
     return (isvalue()) ? value_.value<std::string > () : "";
 }
示例#5
0
文件: utils.cpp 项目: irox/subnav
int getopt(int argc, char * const argv[], const char * optstring)
{
  static int argument_index = 1;  // Pozice zpracovaneho parametru.
  static int option_index = 1; // Pozice zpracovavane volby v parametru.

  /* Kontrola zadaneho parametru a apripadne nulovani cyklu. */
  if (optstring == NULL)
  {
    optarg = NULL;
    argument_index = 1;
    option_index = 1;
    return -1;
  }

  /* Je-li co zpracovavat. */
  while (argument_index < argc)
  {
    char * argument = argv[argument_index]; // Zpracovavany parametr.
    char * value = NULL; // Potencialni hodnota zpracovan�o parametru.

    /* Zjisteni potencialni hodntoty parametru. */
    if ((argument_index  + 1) < argc)
    {
      if (isvalue(argv[argument_index + 1]))
      {
        value = argv[argument_index + 1];
      }
    }

    /* Je-li zpracovavany parametr seznam kratkch voleb. */
    if (isshort(argument))
    {
      int I = option_index;  // Index kratke volby.

      /* Cyklus pres vsechny kratke volby zpracovan�o parametru. */
      while (argument[I] != '\0')
      {
        char option = argument[I]; // Kratka volba.
        int J = 0; // Index definovane volby.

        /* Cyklus pres vsechny definovane volby. */
        while (optstring[J] != '\0')
        {
          char def_option = optstring[J]; // Definovana volba.

          /* Preskoceni symbolu pro pritomnost hodnoty. */
          if (def_option != ':')
          {
            /* Pasuje-li zpracovavana volba s definovanou. */
            if (option == def_option)
            {
              // Priznak hodnoty definovane volby.
              bool def_value = optstring[J + 1] == ':';

              /* Kontrola zda je kratka volba s hodnotou na konci seznamu. */
              if (def_value && (argument[I + 1] != '\0'))
              {
                fprintf(stderr, "Chyba: Volba s hodnotou musi byt na konci"
                 " seznamu voleb!\n");
                optarg = NULL;
                return -1;
              }

              /* Nastaveni pripadne hodnoty parametru. */
              optarg = def_value ? value : NULL;
              option_index++;
              return def_option;
            }
          }

          /* Na dalsi definovanou volbu. */
          J++;
        }

        /* Zadna volba v parametru nepasovala. */
        optarg = NULL;
        option_index++;
        return '?';
      }

      /* Ukonceni zpracovani seznamu voleb. */
      option_index = 1;
      argument_index++;
    }
    else
    {
      /* Preskoceni nekratkeho parametru. */
      option_index = 1;
      argument_index++;
    }
  }

  optarg = NULL;
  return -1;
}