示例#1
0
int main(int argc, char** argv)
{
	FILE *f;
	if (argc != 2)
	{
		fprintf(stderr, "Spatny pocet parametru\n");
		return INTERN_ERROR;
	}
	if (argc == 1)
   {
      fprintf(stderr, "Neni zadan vstupni soubor\n");
      return INTERN_ERROR;
   }
   if ((f = fopen(argv[1], "r")) == NULL)
   {
      fprintf(stderr, "Soubor se nepodarilo otevrit\n");
      return INTERN_ERROR;
   }   
   setSourceFile(f);
   int tokenn=0;
   do
   {
      tokenn = getNextToken();  //TOHLE SE VOLA V PARSERU
      printf("token je: %d\n",tokenn);
   } while(tokenn != 101);


   /////////////////////////////////////////////////
   ////////////TADY PO SOBĚ UKLÍZÍME////////////////
   ////////////////////////////////////////////////
   strFree(&token.data); //uvolním řetezec
   fclose(f); //zavřeme soubor
	
   return 0;
}
示例#2
0
文件: main.c 项目: adamVass/IFJ
int main (int argc, char *argv[]) {

    /** Osetreni vstupnich parametru */
    if (argc != 2) {
        fprintf(stderr,"Byly spatne zadany parametry.\n");
        return S_INTERNI_CHYBA;
    }

    /** Otevreni zdrojoveho souboru */
    FILE *f;
    if ((f = fopen(argv[1], "r")) == NULL) {
        fprintf(stderr, "Soubor nejde otevrit\n");
        return S_INTERNI_CHYBA;
    }
	setSourceFile(f);

    /** Provedeni syntakticke analyzy */
    int navrat;
    navrat = syntakticka_anal();

    /** Pokud vse probehne v poradku, tak se zavola interpret */
    if(navrat == S_BEZ_CHYB)
        navrat = interpret();
    else {
        fprintf(stderr, "Navrat syntakticke: %d\n", navrat);
        return navrat;
    }

    fprintf(stderr, "Navrat interpretu: %d\n", navrat);
    return navrat;
}
示例#3
0
ReferenceBrowser::ReferenceBrowser( QWidget * parent )
    : QTextBrowser( parent )
{
    nif = NULL;

    // Search for reference documentation in different locations.

    // First, try the application path, for windows install.
    docFolder.setPath( qApp->applicationDirPath() );
    docFolderPresent = docFolder.exists( "doc" );
    
    // Next, try the docsys path (if application is run from the nifskope
    // repository directory, as in linux build).
    if( ! docFolderPresent ) {
        docFolder.setPath( qApp->applicationDirPath() );
        docFolder.cd( "docsys" );
        docFolderPresent = docFolder.exists( "doc" );
    }
    
    // Again, try the docsys path (if application is run from the
    // nifskope/release repository directory, as in windows build).
    if( ! docFolderPresent ) {
        docFolder.setPath( qApp->applicationDirPath() );
        docFolder.cd( "../docsys" );
        docFolderPresent = docFolder.exists( "doc" );
    }
    
    // Again, try the docsys path when build dir != source dir
    // which is default in recent versions of Qt SDK,
    // i.e. "shadow build" option in Qt Creator.
    if( ! docFolderPresent ) {
	docFolder.setPath( qApp->applicationDirPath() );
	docFolder.cd( "../../nifskope/docsys" );
	docFolderPresent = docFolder.exists( "doc" );
    }

    // Try the /usr/share/nifskope path, for linux install.
    if ( ! docFolderPresent ) {
        docFolder.cd( "/usr/share/nifskope" );
        docFolderPresent = docFolder.exists( "doc" );
    }
    
    if( docFolderPresent ) {
        docFolder.cd( "doc" );
    }

    if( ! docFolderPresent || ! QFileInfo( docFolder.filePath( "index.html" ) ).exists() )
    {
        setText( tr("Please install the reference documentation into the 'doc' folder.") );
        return;
    }
        
    setSearchPaths( QStringList() << docFolder.absolutePath() );
    setStyleSheet( "docsys.css" );
    setSourceFile( "index.html" );
}
示例#4
0
static void
clearMetainfo( tr_ctor * ctor )
{
    if( ctor->isSet_metainfo )
    {
        ctor->isSet_metainfo = 0;
        tr_bencFree( &ctor->metainfo );
    }

    setSourceFile( ctor, NULL );
}
示例#5
0
static void
clearMetainfo (tr_ctor * ctor)
{
    if (ctor->isSet_metainfo)
    {
        ctor->isSet_metainfo = false;
        tr_variantFree (&ctor->metainfo);
    }

    setSourceFile (ctor, NULL);
}
示例#6
0
文件: main.c 项目: dakov/ifj-13
int main(int argc, char** argv) {
  if (argc != 2) { // ocekavame PRAVE JEDEN argument (+ nazev souboru)
    fprintf(stderr, "Nespravny pocet argumentu testovaciho programu.\n");
    return -1; //!! predelat na spravnou konstantu
  }

  FILE * f = fopen(argv[1], "r");
  if (f == NULL ) {
    fprintf(stderr, "Testovacimu souboru se nepodarilo otevrit soubor s aplikaci.\n");
    return internalError();
  }

  initGarbageCollector();

  //nastav soubor, ze ktereho scanner cte
  setSourceFile(f);

  htable_t* fT;
  tIlist iL;
  listInit(&iL);
  fT = htable_init(HTABLE_SIZE);

  htableStack *sS = gcMalloc(sizeof(htableStack));
  if (sS == NULL) return internalError();
  sS = htable_stack_init();

  htable_t *mainTable ;
  mainTable = htable_init(HTABLE_SIZE);
  htable_stack_push(sS,mainTable);

  int result = parse(fT, &iL,sS);

  if (result != EOK)
    {
      fclose(f);
      freeGarbage();
      return result;
      // jinak probehlo vse v poradku, muzeme provadet kod
    }


  result = (interpret(&iL,fT,sS));

  freeGarbage();
  fclose(f);

  if(result != EOK){
    return result;
    }


  return EOK;
}
示例#7
0
coConfigEditorImport::coConfigEditorImport(const QString &source,
        const QString &dest,
        const QString &transform)
    : QObject()
{

    setTransformInstructionFile(transform);
    setDestinationFile(dest);
    setSourceFile(source);

    wizard = 0;
}
示例#8
0
int main() {
   TTable mujTable;
   table = &mujTable;
   tableInit(table);

   tableInsertFunction(table, strCreateString("fce"));
   functionInsertVar(table->lastAddedFunc, strCreateString("x"));
   functionInsertVar(table->lastAddedFunc, strCreateString("y"));
   functionInsertVar(table->lastAddedFunc, strCreateString("z"));

   printf("\nJedna funkce: \n");
   tablePrintOrder(*table);
   printf("\n----------------------------\n");


//tiskniPrecTab();
   FILE *f = fopen("testy/test-expr2.txt","r");
   setSourceFile(f);
   strInit(&attr);
   listInit(&table->lastAddedFunc->tmpVar);

   int err = EOK;
   TVar *x = NULL;
   int test = 1;
   token = 1;

   while(token != END_OF_FILE) {
      token = getNextToken(&attr);
      x = NULL;
      err = parseExpression(table, &x);
      printf("Test %d skoncil s chybou: %d a vysledkem: %d \n", test,err, (int)x);
      test++;

      while (token != END_OF_FILE && token != L_SEMICOLON) {
         token = getNextToken(&attr);
      }
   }
   tiskniList(&table->lastAddedFunc->instructions);

   listDataDelete(&table->lastAddedFunc->tmpVar);
   listDispose(&table->lastAddedFunc->tmpVar);

   fclose(f);
   tableClear(table);
   strFree(&attr);
   return EXIT_SUCCESS;
}
示例#9
0
void ReferenceBrowser::browse( const QModelIndex & index )
{
    if( !nif || !docFolderPresent ) {
        return;
    }

    QString blockType = nif->getBlockType( index );
    if( blockType == "NiBlock" ) {
        blockType = nif->getBlockName( index );
    }

    if( ! QFileInfo( docFolder.filePath( "%1.html" ).arg( blockType ) ).exists() ) {
        setText( tr("The reference file for '%1' could not be found.").arg( blockType ) );
        return;
    }
    
    setSourceFile( QString( "%1.html" ).arg( blockType ) );
}
示例#10
0
void QgsHtmlAnnotation::readXml( const QDomElement &itemElem, const QgsReadWriteContext &context )
{
  mHtmlFile = itemElem.attribute( QStringLiteral( "htmlfile" ), QString() );
  QDomElement annotationElem = itemElem.firstChildElement( QStringLiteral( "AnnotationItem" ) );
  if ( !annotationElem.isNull() )
  {
    _readXml( annotationElem, context );
  }

  // upgrade old layer
  if ( !mapLayer() && itemElem.hasAttribute( QStringLiteral( "vectorLayer" ) ) )
  {
    setMapLayer( QgsProject::instance()->mapLayer( itemElem.attribute( QStringLiteral( "vectorLayer" ) ) ) );
  }

  if ( mWebPage )
  {
    setSourceFile( mHtmlFile );
  }
}
示例#11
0
int
tr_ctorSetMetainfoFromFile( tr_ctor *    ctor,
                            const char * filename )
{
    uint8_t * metainfo;
    size_t    len;
    int       err;

    metainfo = tr_loadFile( filename, &len );
    if( metainfo && len )
        err = tr_ctorSetMetainfo( ctor, metainfo, len );
    else
    {
        clearMetainfo( ctor );
        err = 1;
    }

    setSourceFile( ctor, filename );

    /* if no `name' field was set, then set it from the filename */
    if( ctor->isSet_metainfo )
    {
        tr_benc * info;
        if( tr_bencDictFindDict( &ctor->metainfo, "info", &info ) )
        {
            const char * name;
            if( !tr_bencDictFindStr( info, "name.utf-8", &name ) )
                if( !tr_bencDictFindStr( info, "name", &name ) )
                    name = NULL;
            if( !name || !*name )
            {
                char * base = tr_basename( filename );
                tr_bencDictAddStr( info, "name", base );
                tr_free( base );
            }
        }
    }

    tr_free( metainfo );
    return err;
}
示例#12
0
bool Transpiler::translate(const ShaderDesc& shaderDesc, Shader *shader)
{
   auto state = Transpiler {};

   if (shaderDesc.type == ShaderType::Vertex) {
      state.mType = Transpiler::Type::Vertex;
   } else if (shaderDesc.type == ShaderType::Geometry) {
      state.mType = Transpiler::Type::Geometry;
   } else if (shaderDesc.type == ShaderType::Pixel) {
      state.mType = Transpiler::Type::Pixel;
   } else {
      decaf_abort("Unexpected shader type");
   }

   spv::ExecutionModel spvExecModel;
   if (shaderDesc.type == ShaderType::Vertex) {
      spvExecModel = spv::ExecutionModel::ExecutionModelVertex;
   } else if (shaderDesc.type == ShaderType::Geometry) {
      spvExecModel = spv::ExecutionModel::ExecutionModelGeometry;
   } else if (shaderDesc.type == ShaderType::Pixel) {
      spvExecModel = spv::ExecutionModel::ExecutionModelFragment;
   } else {
      decaf_abort("Unexpected shader type");
   }

   auto spvGen = ShaderSpvBuilder(spvExecModel);
   spvGen.setSourceFile("none");

   state.mSpv = &spvGen;
   state.mDesc = &shaderDesc;
   state.mBinary = shaderDesc.binary;
   state.mAluInstPreferVector = shaderDesc.aluInstPreferVector;

   if (shaderDesc.type == ShaderType::Vertex) {
      auto &vsDesc = *reinterpret_cast<const VertexShaderDesc*>(&shaderDesc);

      state.mTexInput = vsDesc.texDims;

      spvGen.setDescriptorSetIdx(0);
      Transpiler::writeVertexProlog(spvGen, vsDesc);
   } else if (shaderDesc.type == ShaderType::Geometry) {
      auto &gsDesc = *reinterpret_cast<const GeometryShaderDesc*>(&shaderDesc);

      state.mTexInput = gsDesc.texDims;

      spvGen.setDescriptorSetIdx(1);
      Transpiler::writeGeometryProlog(spvGen, gsDesc);
   } else if (shaderDesc.type == ShaderType::Pixel) {
      auto &psDesc = *reinterpret_cast<const PixelShaderDesc*>(&shaderDesc);

      state.mTexInput = psDesc.texDims;

      spvGen.setDescriptorSetIdx(2);
      Transpiler::writePixelProlog(spvGen, psDesc);
   }

   state.translate();
   spvGen.makeReturn(true);

   if (shaderDesc.type != ShaderType::Vertex) {
      if (spvGen.hasFunction("fs_main")) {
         decaf_abort("Non-vertex-shader called into a FS function, wat?");
      }
   }

   if (shaderDesc.type == ShaderType::Vertex) {
      auto& vsDesc = *reinterpret_cast<const VertexShaderDesc*>(&shaderDesc);
      auto vsShader = reinterpret_cast<VertexShader*>(shader);

      if (spvGen.hasFunction("fs_main")) {
         auto fsFunc = spvGen.getFunction("fs_main");
         spvGen.setBuildPoint(fsFunc->getEntryBlock());

         auto fsState = Transpiler {};
         fsState.mSpv = &spvGen;
         fsState.mDesc = &shaderDesc;
         fsState.mType = ShaderParser::Type::Fetch;
         fsState.mBinary = vsDesc.fsBinary;
         fsState.mAluInstPreferVector = vsDesc.aluInstPreferVector;
         fsState.translate();
         spvGen.makeReturn(true);

         // Copy the FS attribute buffer stuff over.  We check to make sure that
         // the vertex shader didn't also try to read stuff (this would be an error).
         decaf_check(state.mVsInputAttribs.size() == 0);
         state.mVsInputBuffers = fsState.mVsInputBuffers;
         state.mVsInputAttribs = fsState.mVsInputAttribs;
      }

      // For each exported parameter, we need to exports the semantics for
      // later matching up by the pixel shaders
      int numExports = spvGen.getNumParamExports();
      for (auto i = 0; i < numExports; ++i) {
         uint32_t semanticId;

         // TODO: This should probably be moved into the actual export generation
         // code instead of being calculated later and assuming the order of the
         // exports matches up with the code...
         if ((i & 3) == 0) {
            semanticId = vsDesc.regs.spi_vs_out_ids[i >> 2].SEMANTIC_0();
         } else if ((i & 3) == 1) {