Exemplo n.º 1
0
Arquivo: package.cpp Projeto: hyln9/nV
var Sym2(const wchar *x)
{
	const wchar *c = wcsrchr(x,L'`');
	if(c)
	{
		wstring t;
		if(x[0] == L'`')
		{
			t.append(ContextName[Context()]);
			++x;
		}
		t.append(x,++c);
		return Sym(c,Ctx(t));
	}
	return Sym(x);
}
Exemplo n.º 2
0
void
begin (int argc, const char * argv[])
{
  size_t output;
  size_t pos;

  output = Outfile ("-");

  Add_field (output, Sym ("uint4"), Sym ("bp0"));
  Add_field (output, Sym ("uint4"), Sym ("bp1"));
  File_fix (output, 1, 0);


  pos = 0;
  while (1)
    {
      const int char_in = getchar ();

      if (char_in == EOF)
        {
          if (ferror (stdin))
            Fatal ("input error");
          else
            {
              if (pos % 2)
                {
                  Poke (output, 0, 1, uInt4 (bp_letter_to_int4 (0)));
                  Advance (output, 1);
                }
              break;
            }
        }

      Poke (output, 0, (pos % 2),
            uInt4 (bp_letter_to_int4 (char_in)));

      ++pos;

      if (!(pos % 2))
        Advance (output, 1);
    }

  Close (output);
}
Exemplo n.º 3
0
Arquivo: dt.c Projeto: pkuwwt/Detri
void dt_save (const char path_name[], int type, Trist *s, const Trist_num *q)
{
  Dt dt;
  int h1, h2;
  int saved_max = s->max_triangle;
  Assert_always (s->magic == MAGIC);
  ;
  { /* using binary format */
    FILE *f = basic_fopen (path_name, "w");
    print ("Saving binary file \"%s\" ...\n", path_name);
    ;
    h2 = trist_pack ();
    h1 = EdFacet (1, 0);  /* trist_pack*() moves hull facets to: [1..h2] */
    if (NOT trist_hull_facet (h1))
      h1 = Sym (h1);
#ifdef __DEBUG__
    trist_io_check (s, *q);
#endif
    ;
    dt.bpt = (short) sizeof (Trist_record);
    dt.type = (short) type;
    dt.hull_ef = h1;
    dt.last_hull = h2;
    dt.num = *q;
    dt.n = s->max_org;
    dt.redundant  = s->max_org - dt.num.v;
    dt.trist = NULL;
    s->max_triangle = s->last_triangle;
    Assert_always (dt.n == dt.num.v + dt.redundant);
    ;
    /* binfwrite (&dt, 1, f); */
    Write1f (dt.type);
    Write1f (dt.bpt);
    Write1f (dt.n);
    Write1f (dt.redundant);
    Write1f (dt.hull_ef);
    Write1f (dt.last_hull);
    Write1f (dt.num);
    Write1f (dummy_word);
    ;
    /* binfwrite (s, 1, f); */
    Write1f (s->magic);
    Write1f (dummy_word);
    Write1f (s->last_triangle);
    Write1f (s->max_triangle);
    Write1f (s->max_org);
    Write1f (dummy_word);
    Write1f (s->used_triangles);
    Write1f (s->next_reusable_triangle);
    ;
    binfwrite (s->triangle, s->max_triangle + 1, f);
    ;
    basic_fclose (f);
  }
  s->max_triangle = saved_max;  /* such that s leaves unchanged! */
}
Exemplo n.º 4
0
var ParametricRegionPlot::exportGraphics() {
    var shapelist = Vec(polynum);
    for (int i = 0; i < polynum; i++) {
        At(shapelist, i) = makeIndexedPolygon(polys[i], i);
    }
    var shape = Ex(Sym(L"Shape"), shapelist);
    var opts = makeGlobalOptions();
    var graphics = makeGraphics(shape, opts);
    return graphics;
}
Exemplo n.º 5
0
void initSymbols(int idx)
      {
      if (symbolsInitialized[idx])
            return;
      symbolsInitialized[idx] = true;
      symbols[idx] = QVector<Sym>(lastSym);

      symbols[idx][clefEightSym] = Sym(0x38, 2);
      symbols[idx][clefOneSym]   = Sym(0x31, 2);
      symbols[idx][clefFiveSym]  = Sym(0x35, 2);
      symbols[idx][letterTSym]   = Sym('T',  2);
      symbols[idx][letterSSym]   = Sym('S',  2);
      symbols[idx][letterPSym]   = Sym('P',  2);

      QString path;
#ifdef Q_OS_IOS
      {
      extern QString resourcePath();
      QString rpath = resourcePath();
      path = rpath + QString(idx == 0 ? "/mscore20.xml" : "/mscore/gonville.xml");
      }
#else
      path = idx == 0 ? ":/fonts/mscore20.xml" : ":/fonts/gonville.xml";
#endif
      QFile f(path);
      if (!f.open(QFile::ReadOnly)) {
            qDebug("cannot open symbols file %s", qPrintable(path));
            if (!MScore::debugMode)
                  exit(-1);
            }
      XmlReader e(&f);
      int fid = idx == 0 ? 0 : 3;

      while (e.readNextStartElement()) {
            if (e.name() == "museScore") {
                  while (e.readNextStartElement()) {
                        if (e.name() == "Glyph") {
                              QString name;
                              int code = -1;
                              QPointF p;
                              QRectF b;
                              while (e.readNextStartElement()) {
                                    const QStringRef& tag(e.name());
                                    if (tag == "name")
                                          name = e.readElementText();
                                    else if (tag == "code") {
                                          QString val(e.readElementText());
                                          bool ok;
                                          code = val.mid(2).toInt(&ok, 16);
                                          if (!ok)
                                                qDebug("cannot read code");
                                          }
                                    else if (tag == "attach")
                                          p = e.readPoint();
                                    else if (tag == "bbox")
                                          b = e.readRect();
                                    else
                                          e.unknown();
                                    }
                              if (code == -1)
                                    qDebug("no code for glyph <%s>", qPrintable(name));
                              SymId idx1 = Sym::name2id(name);
                              if (idx1 != noSym)
                                    symbols[idx][idx1] = Sym(code, fid, p, b);
                              else {
                                    qDebug("symbol <%s> declared in %s for symbol set %d not used",
                                       qPrintable(name), qPrintable(path), idx);
                                    }
                              }
                        else
                              e.unknown();
                        }
                  }
            else
                  e.unknown();
            }
      for (int i = 0; i < lastSym; ++i) {
            Sym* sym = &symbols[idx][i];
            if (sym->code() == -1) {
                  qDebug("no code for symbol %s", Sym::id2name(SymId(i)));
                  if (idx > 0) {
                        //fallback to default font
                        symbols[idx][i] = symbols[0][i];
                        }
                  }
            }
      }
Exemplo n.º 6
0
Arquivo: edge.cpp Projeto: dose78/FRPA
Point *QuadEdge::Dest() { return Sym()->Org(); }
Exemplo n.º 7
0
Arquivo: edge.cpp Projeto: dose78/FRPA
void QuadEdge::setDest( Point *p ) { Sym()->setOrg(p); }
Exemplo n.º 8
0
Arquivo: edge.cpp Projeto: dose78/FRPA
QuadEdge *QuadEdge::Dnext() { return Sym()->Onext()->Sym(); }
Exemplo n.º 9
0
Arquivo: edge.cpp Projeto: dose78/FRPA
QuadEdge *QuadEdge::Rprev() { return Sym()->Onext(); }
Exemplo n.º 10
0
DEM read_dem ()
{
int c;
DEM f, a, b, d, x;
int i;
char buf[200];
DEM s;
DEM d1;
int flags1;
DEM used1;
extern DEM used;
loop:
	do c = readchar ();
	while (c==' ' || c=='\t' || c=='\n' || c==0);

	switch (c)
	{
		case 'I': return I;
		case 'K': return K;
		case 'S': return S;
		case 'E': return E;
		case 'F': return If;
		case 'O': return Ord;

		case '-':
			f = read_dem ();
			a = read_dem ();
			return ap (f, a);

		case '/':
			a = read_dem ();
			b = read_dem ();
			return transym (a, b);

                case 'T':
                        a = read_dem ();
                        b = read_dem ();
                        return trans (a, b);

                case 'X':
                        a = read_dem ();
                        return sym (a);

                case '#':
                        a = read_dem ();
                        b = read_dem ();
                        return Axm (a, b);

		case 'i':
			a = read_dem ();
			return defI (a);

		case 'k':
			a = read_dem ();
			b = read_dem ();
			return defK (a, b);

		case 's':
			a = read_dem ();
			b = read_dem ();
                        d = read_dem ();
                        return defS (a, b, d);           

                case ')':
                        a = read_dem ();
                        b = read_dem ();
                        return IfNode (a, b);

                case '1': return Ext1;
                case '2': return Ext2;
                case '3': return Ext3;
                case '4': return Ext4;
                case '5': return Ext5;
                case '6': return Ext6;

		case 'e': return AE;
                case 'f': return EA0;
                        /*
                        a = read_dem ();        
                        return EA (a);
                        */
                case 'm': return MP;
                case 'a': return AI;
                case 'b': return AK;
                case 'c': return AS;
                case 'r': return RPA;

                case '0': return ZeroIsOrd;
                case '+': return SucIsOrd;
                case 'w': return LimIsOrd;
                case 'p': return PredIsOrd;
                case 'n': return StepIsOrd;
                case 'W': return TfI;                

                case '<':
                        a = read_dem ();
                        return left (a);

                case '>':
                        a = read_dem ();
                        return right (a);

                case '\'':
                        a = read_dem ();
                        return rep(a);

		case '%':
/*printf ("*1*");*/
			a = read_dem ();
/*printf ("*2*");*/
                        trace_dem ("read", a);
/*printf ("*3*");*/
                        b = red (a);
/*printf ("*4*");*/
                        trace_dem ("red", b);
                        return b;
			/* return red (a); */
            
                case 'R':
                        a = read_dem ();
                        return red1 (a, 0);

                case '@':
                        a = read_dem ();
                        return reduc (a, 1);
         
		case '~':
			a = read_dem ();
			return reduc (a, 0);

		case '$':
			a = read_dem ();
			return redu (a);

                case 'x':
			a = read_dem ();
			b = read_dem ();
			return ext (a, b);

                case '\\':
			a = read_dem ();
			b = read_dem ();
                        trace_dem ("^(0)", a);
                        trace_dem ("^(1)", b);
                        d = exten (a, b);
                        trace_dem ("^(r)", d);
                        return d;

                case ']':
                	a = read_dem ();
                        b = read_dem ();
                        d = dbextens (a, b);
                        return d;

                case 'l':
                        a = read_dem ();
                        b = read_dem ();
                        return Ext (a, b);
                        /* return Lambda (a, b); */

                case 'L':
                        a = read_dem ();
                        b = read_dem ();
                        return Lambda (a, b);

                case '.':
                        a = read_dem ();
                        return DBLambda (a);

                case '!':
                        a = read_dem ();
                        b = read_dem ();
                        return DB_lambda (a, b);
                        /* return DBLambda (DBname (0, a, b)); */

                case '?':
                        a = read_dem ();
                        b = read_dem ();
                        return DB_Subst (a, b);

                case '_':
                        a = read_dem ();
                        b = read_dem ();
                        d = read_dem ();
                        return Subst (a, b, d);

                case ':':
                        a = read_dem ();
                        b = read_dem ();
                        d = read_dem ();
                        return ap (exten(a,d) ,b);

                case 'V':
                        x = read_dem ();
                        d = read_dem ();
                        a = mk_dem (node(d), 0, NULL,
                                DB_lambda (x, subdem(0,d)),
                                DB_lambda (x, subdem(1,d)),
                                subdem(2,d) == NULL ? NULL :
                                DB_lambda (x, subdem(2,d)),
                                NULL, NULL, NULL);
                        return a;

                case 'A':
                        x = read_dem ();
                        d = read_dem ();
                        a = mk_dem (node(d), 0, NULL,
                                ap (x, subdem(0,d)),
                                ap (x, subdem(1,d)),
                                subdem(2,d) == NULL ? NULL :
                                ap (x, subdem(2,d)),
                                NULL, NULL, NULL);
                        return a;


                case '"':
                        a = read_dem ();
                        /* return NoRed (a); */
                        no_red[nnr++] = a;
                        return a;

                case '|':
                     a = read_dem ();
                     no_red[nnr++] = a;
                     b = read_dem ();
                     return b;

                case 'u':
                	used1 = used;
                    used = read_dem ();
                    a = read_dem ();
                    used = used1;
                    return a;
                    
                case '(':
                        flags1 = flags;
                        i = 0;
                        for (;;)
                        {
                            c = readchar ();
                            if (c == ')')
                                break;
                            buf[i++] = c;
                        }
                        buf[i] = 0;
                        sscanf (buf, "%x", &flags);
                        a = read_dem ();
                        if ((flags & FLAG_PERM) == 0)
                            flags = flags1;
                        return a;

                case ',':
                        a = read_dem ();
                        return step (a);

                case '*':
                        a = read_dem ();
                        return rstep (a);
                
                case '`':
                        a = read_dem ();
                        return list_ap (a, nil);

                case '&':
                        c = readchar ();
                        switch (c)
                        {
                                case '/': return itransym;
                                case 'i': return idefI;
                                case 'k': return idefK;
                                case 's': return idefS;
                                case '<': return ileft;
                                case '>': return iright;
                                case '=': return ieq;
                                case '#': return inode;
                                case '0': return isubdem0;
                                case '1': return isubdem1;
                                case '2': return isubdem2;
                                case '%': return ired;
                                case '$': return iredu;
                                case '\\': return iext;
                                case ',': return istep;
                                case '*': return irstep;
                                default:
                                        fprintf (stderr, "Undefined &%c.\n",
                                                 c);
                                        return I;
                        }
                        break;

                    case '[':
                        /* trace_dem ("read symbol", I); */
                        for (i=0; i<sizeof(buf); i++)
                        {
                            c = readchar();
                            if (c == ']')
                            {
                                buf[i] = 0;
#ifdef TRACE1
                                printf ("buf=<%s>\n", buf);
#endif
                                if (buf[0] >= '0' && buf[0] <= '9')
                                {
#ifdef TRACE
                                    printf ("\nDBVar <%s>", buf);
#endif
                                    d1 = DBVar (atoi(buf));
                                    trace_dem ("", d);
                                    return d1;
                                }
                                s = Sym(buf);
#ifdef TRACE1
                                trace_dem ("read symbol", s);
#endif
                                if (subdem(0,s) == NULL)
                                {
#ifdef TRACE1
                                    trace_dem ("return symbol", s);
#endif
                                    return s;
                                }
                                else
                                {
#ifdef TRACE
                                    trace_dem ("return value of", s);
#endif
                                    return subdem(0,s);
                                }

                            }
                            buf[i] = c;
                        }
                        fprintf (stderr, "Symbol too long\n");
                        return Sym(buf);

		default:
                        return defined_dems[(unsigned char)c];
                        /*
                        printf ("Illegal character 0x%02X\n", c);
			goto loop;
                        */
	}

}
Exemplo n.º 11
0
void Edge::setRight(Face *right) {
    // add this edge to the (face) orbit of _right_
    InvRot()->face = right;
    right->addEdge(Sym());
}
Exemplo n.º 12
0
void Edge::setDest(Vertex *dest) {
    // add this edge to the (vertex) orbit of _dest_
    Sym()->vertex = dest;
    dest->addEdge(Sym());
}
Exemplo n.º 13
0
void
begin (int argc, const char * argv[])
{
  size_t infile;
  size_t n_fields;
  size_t field;
  size_t n_params;
  size_t param;
  const char * comment;
  int mer_field[256] = {0, };

  infile = Infile ("-");
  File_fix (infile, 1, 0);

  puts ("#: taql-0.1/text");

  n_fields = N_fields (infile);
  for (field = 0; field < n_fields; ++field)
    {
      Taql name;
      Taql type;

      fputs ("# field ", stdout);
      name = Field_name (infile, field);
      Fprint (stdout, name);
      fputs (" ", stdout);
      type = Field_type (infile, field);
      Fprint (stdout, type);
      fputc ('\n', stdout);

      if (   Eq (type, Sym ("uint64"))
          && ('m' == Sym_ref(name, 0))
          && ('e' == Sym_ref(name, 1))
          && ('r' == Sym_ref(name, 2))
          && isdigit (Sym_ref(name, 3)))
        {
          mer_field[field] = 1;
        }
    }

  n_params = N_params (infile);
  for (param = 0; param < n_params; ++param)
    {
      fputs ("# param ", stdout);
      Fprint (stdout, Param_name (infile, param));
      fputs (" ", stdout);
      Fprint (stdout, Param_value (infile, param));
      fputc ('\n', stdout);
    }

  comment = Comment (infile);
  if (!comment || !comment[0])
    {
      fputs ("#.\n", stdout);
    }
  else
    {
      const char * c;
      fputs ("#-\n# ", stdout);

      for (c = comment; *c; ++c)
        {
          if (*c == '\n')
            fputs ("\n# ", stdout);
          else
            fputc (*c, stdout);
        }
      fputs ("\n#.\n", stdout);
    }

  while (N_ahead (infile))
    {
      for (field = 0; field < n_fields; ++field)
        {
          Taql value;

          if (field)
            fputc (' ', stdout);

          value = Peek (infile, 0, field);

          if (!mer_field [field])
            {
              Fprint (stdout, value);
            }
          else
            {
              t_taql_uint64 mer;
              char in_ascii[17];

              mer = as_uInt64 (value);
              mer_to_ascii (in_ascii, mer);
              fputs (in_ascii, stdout);
            }
        }
      fputc ('\n', stdout);
      Advance (infile, 1);
    }
}