Esempio n. 1
0
int coertion(int x, int exp){
/*Quando é necessario atribuir a x uma expressao de outro tipo
	retorna o tipo da exp apos a coerção	*/
	if(x==exp)
		return x;
	else if(x==IKS_FLOAT && exp==IKS_INT)
		return IKS_FLOAT;
	else if(x==IKS_INT && exp==IKS_FLOAT)
		return IKS_INT; 		
	else if(x==IKS_FLOAT && exp==IKS_BOOL)
		return IKS_FLOAT;		
	else if(x==IKS_BOOL && exp==IKS_FLOAT)
		return IKS_BOOL;	
	else if(x==IKS_INT && exp==IKS_BOOL)
		return IKS_INT;
	else if(x==IKS_BOOL && exp==IKS_INT)
		return IKS_BOOL;
	else if(exp==IKS_STRING){
		printf("Impossivel fazer coerção para o tipo String (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_STRING_TO_X);	
	}
	else if(exp==IKS_CHAR){
		printf("Impossivel fazer coerção para o tipo Char (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_CHAR_TO_X);	
	}
	else if(x==IKS_STRING || x==IKS_CHAR ){
		printf("Tipos incompativeis (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_WRONG_TYPE);	
	}
}
Esempio n. 2
0
int inference(int val1, int val2){				  
	if(val1==val2)
		return val1;
	else if((val1==IKS_INT && val2==IKS_FLOAT) || (val2==IKS_INT && val1==IKS_FLOAT))
		return IKS_FLOAT;
	else if((val1==IKS_INT && val2==IKS_BOOL) || (val2==IKS_INT && val1==IKS_BOOL))
		return IKS_INT;
	else if((val1==IKS_BOOL && val2==IKS_FLOAT) || (val2==IKS_BOOL && val1==IKS_FLOAT))
		return IKS_FLOAT;
	else if(val2==IKS_STRING){
		printf("Impossivel fazer coerção para o tipo String (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_STRING_TO_X);	
	}
	else if(val2==IKS_CHAR){
		printf("Impossivel fazer coerção para o tipo Char (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_CHAR_TO_X);	
	}
	else if(val1==IKS_STRING){
		printf("Tipos incompativeis (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_WRONG_TYPE);	
	}
	else if(val1==IKS_CHAR){
		printf("Tipos incompativeis (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_WRONG_TYPE);	
	}
}
Esempio n. 3
0
ASTREE* ParamLookup(ASTREE* param_i, List* param_list){
	/*Precisaremos fazer um caminhamento a direita da arvore*/
	List* ListNode;
	if(param_i == NULL && param_list==NULL) /*chegou ao fim dos parametros*/{ 
		return NULL;
	}
	else if(param_i== NULL && param_list!= NULL){
		printf("Faltando argumentos na função (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_MISSING_ARGS);
	}
	else if(param_i!= NULL && param_list== NULL){
		printf("Excesso de argumentos na funcao (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_EXCESS_ARGS);
	}
	else if(param_list->type == param_i->symbol->type){

		param_i = param_i->scc[0];
		param_list = param_list->next;
		return  ParamLookup(param_i,param_list);
	}	
	else if(inference_three(param_list->type,param_i->symbol->type)){
		param_i->symbol->type = inference_three(param_list->type,param_i->symbol->type);
		param_i = param_i->scc[0];
		param_list = param_list->next;
		return  ParamLookup(param_i,param_list);
	}
	else{	
		printf("Argumentos com tipos nao condizentes (linha %d)\n", getLineNumber()-1);
		exit(IKS_ERROR_WRONG_TYPE_ARGS);
	}
}
Esempio n. 4
0
NodePointer Parser::factor()
{
	NodePointer result;
	SymbolType type = currentSymbol_.symbolType_;
	if (TheOperatorFactory::getInstance().isOperator(type))
	{
		if (type == SUBSTRACTION)
		{
			type = MINUS;
		}

		OperatorPointer theOperator = TheOperatorFactory::getInstance().create(type);
		if (!theOperator->isUnary())
		{
			throw ErrorMessage("Unary operator expected", getLineNumber());
		}

		getNextSymbol();
		NodePointer subExpressionTree = expression(theOperator->precedence());
		result = NodePointer(new Expression(theOperator, NodePointerInserter()(subExpressionTree), getLineNumber()));
	}
	else if (type == LEFT_PARENTHESIS)
	{
		getNextSymbol();
		NodePointer subExpressionTree = expression();
		accept(RIGHT_PARENTHESIS);
		result = subExpressionTree;
	}
	else if (type == IDENTIFIER || type == GLOBAL)
	{
		result = NodePointer(new Variable(currentSymbol_.value_.toString(), tables_, type == GLOBAL));
		getNextSymbol();
	}
	else if (type == ARGUMENT)
	{
		result = NodePointer(new Argument(tables_.subroutineStack_, currentSymbol_.value_, getLineNumber()));
		getNextSymbol();
	}
	else if (type == CONSTANT)
	{
		result = NodePointer(new Constant(currentSymbol_.value_));
		getNextSymbol();
	}
	else if (type == CALL)
	{
		return procedureCall();
	}
	else
	{
		throw ErrorMessage("Unexpected symbol " + symbolToString(currentSymbol_), getLineNumber());
	}

	return result;
}
Esempio n. 5
0
bool SourceLocation::operator< (const SourceLocation& other) const {
	if (fileName < other.fileName)
		return true;
	if (fileName > other.fileName)
		return false;
	return (getLineNumber() < other.getLineNumber());
}
Esempio n. 6
0
	bool KCFFile::readEDGE_(KCFFile::IndexAtomMap& index_to_atom)
	{
		if (!getLine().hasPrefix(EDGE_TAG))
		{
			throw Exception::ParseError(__FILE__, __LINE__,
																	String("'") + getLine() + "' (line " + String(getLineNumber()) + " of "  + getName() + "'",
																	String("Expected EDGE tag: "));
		}

		Size number_of_edges = getLine().getField(1).toInt();
		bool ok = true;
		for (Position i = 0; ok && (i < number_of_edges); i++)
		{
			// Get the next line
			readLine();
			
			// Make sure the line starts with a blank
			ok &= getLine().hasPrefix(CONTINUED_LINE);
			
			// ??? Comments still mising
			Position first = getLine().getField(1).toInt();
			Position second = getLine().getField(2).toInt();
			Position order = getLine().getField(3).toInt();
			
			// Make sure the indices refered to do exist
			ok &= index_to_atom.has(first) && index_to_atom.has(second);
			if (ok)
			{
				Bond* bond = index_to_atom[first]->createBond(*index_to_atom[second]);
				bond->setOrder(order);
			}
		}
		
		return (ok && readLine());
	}
Esempio n. 7
0
	bool KCFFile::read(System& system) throw(Exception::ParseError)
	{
		Molecule* molecule = 0;
		bool read_anything = false;

		// Read all molecules.
		try
		{
			while ((molecule = read()) != 0)
			{
				// add the molecule to the system
				system.append(*molecule);
				molecule = 0;
				read_anything = true;
			}
		}
		catch (Exception::ParseError& e)
		{
			#ifdef DEBUG
				Log.info() << "KCFFile::read(System&): caught exception while parsing line " << getLineNumber() << ": " << e << std::endl;
			#endif

			// clean up and rethrow
			delete molecule;
			throw e;
		}

		// Make sure to return false if nothing could be read.
		return read_anything;
	}
Esempio n. 8
0
bool Unit::compileTimeFatal(const StringData*& msg, int& line) const {
  // A compile-time fatal is encoded as a pseudomain that contains precisely:
  //
  //   String <id>; Fatal;
  //
  // Decode enough of pseudomain to determine whether it contains a
  // compile-time fatal, and if so, extract the error message and line number.
  const Opcode* entry = getMain()->getEntry();
  const Opcode* pc = entry;
  // String <id>; Fatal;
  // ^^^^^^
  if (*pc != OpString) {
    return false;
  }
  pc++;
  // String <id>; Fatal;
  //        ^^^^
  Id id = *(Id*)pc;
  pc += sizeof(Id);
  // String <id>; Fatal;
  //              ^^^^^
  if (*pc != OpFatal) {
    return false;
  }
  msg = lookupLitstrId(id);
  line = getLineNumber(Offset(pc - entry));
  return true;
}
Esempio n. 9
0
void
frame_get_location(FrameIndex index, SerialNumber *pserial_num,
                   jmethodID *pmethod, jlocation *plocation, jint *plineno)
{
    FrameKey  *pkey;
    FrameInfo *info;
    jint       lineno;

    pkey       = get_pkey(index);
    *pmethod   = pkey->method;
    *plocation = pkey->location;
    info       = get_info(index);
    lineno     = (jint)info->lineno;
    if ( info->lineno_state == LINENUM_UNINITIALIZED ) {
        info->lineno_state = LINENUM_UNAVAILABLE;
        if ( gdata->lineno_in_traces ) {
            if ( pkey->location >= 0 && !isMethodNative(pkey->method) ) {
                lineno = getLineNumber(pkey->method, pkey->location);
                if ( lineno >= 0 ) {
                    info->lineno = (unsigned short)lineno; /* save it */
                    info->lineno_state = LINENUM_AVAILABLE;
                }
            }
        }
    }
    if ( info->lineno_state == LINENUM_UNAVAILABLE ) {
        lineno = -1;
    }
    *plineno     = lineno;
    *pserial_num = info->serial_num;
}
Esempio n. 10
0
int main(int argv, char **argc)
{
	initMe();
    //extern int yydebug;
    //int simb;

    if (argv < 2) 
    {
        printf("Digite o nome do arquivo!\n");
        exit(1);
    }
    
    yyin = fopen(argc[1],"r");
    printf("Arquivo de entrada: %s\n",argc[1]);

   
	//yydebug = 1;
    yyparse();
    //printTokens();
    
    printf("╔═╗╦ ╦╔═╗╔═╗╔═╗╔═╗╔═╗\n");
    printf("╚═╗║ ║║  ║╣ ╚═╗╚═╗║ ║\n");
    printf("╚═╝╚═╝╚═╝╚═╝╚═╝╚═╝╚═╝\n");
    printf("Analise sintatica feita com sucesso. Nenhum erro encontrado.\n");
    printf("Numero de linhas do arquivo de entrada: %d\n", getLineNumber());
    printf("TABELA HASH\n-----------\n");
    hashPrint();
    exit(0);
}
Esempio n. 11
0
/***************************************
 * Function: astCreate
 * Description:
 * Input:
 * Output:
 ***************************************/
ast_t* astCreate(int type, hash_t *symbol, ast_t *s0,ast_t *s1, ast_t *s2, ast_t *s3)
{
	ast_t *newNode;
	newNode = (ast_t*) calloc(1,sizeof(ast_t));
	newNode->type = type;
	newNode->symbol = symbol;
	newNode->son[0]= s0;
	newNode->son[1]= s1;
	newNode->son[2]= s2;
	newNode->son[3]= s3;
	newNode->printFlag = 0;
	newNode->lineNumber = getLineNumber();

    if (symbol) {
        gv_declare(type,newNode,symbol->text);
    }
    else {
      	gv_declare(type,newNode,NULL);
    }

    if(newNode->son[0] !=NULL) gv_connect(newNode,newNode->son[0]);
    if(newNode->son[1] !=NULL) gv_connect(newNode,newNode->son[1]);
    if(newNode->son[2] !=NULL) gv_connect(newNode,newNode->son[2]);
    if(newNode->son[3] !=NULL) gv_connect(newNode,newNode->son[3]);

	return newNode;
}
Esempio n. 12
0
void SkDisplayXMLParserError::setInnerError(SkAnimateMaker* parent, const SkString& src) {
    SkString inner;
    getErrorString(&inner);
    inner.prepend(": ");
    inner.prependS32(getLineNumber());
    inner.prepend(", line ");
    inner.prepend(src);
    parent->setErrorNoun(inner);
}
Esempio n. 13
0
/*! @decl int getLineNumber()
 */
static void f_getLineNumber(INT32 args)
{
  pop_n_elems(args);
  
  if (!THIS->ctxt)
    push_int(-1);
  else
    push_int(getLineNumber(THIS->ctxt));
}
Esempio n. 14
0
void Exception::formatEntry(std::ostream &stream, size_t depth) const {
	LocaleUtils::CLocaleScope localeScope(stream);

	if (depth > maxDepth_) {
		return;
	}

	if (hasTypeName(depth)) {
		formatTypeName(stream, depth);
	}
	else {
		stream << "(Unknown exception)";
	}

	if (hasFileName(depth)) {
		stream << " ";
		formatFileName(stream, depth);
	}

	if (hasFunctionName(depth)) {
		stream << " ";
		formatFunctionName(stream, depth);
	}

	if (hasLineNumber(depth)) {
		stream << " line=" << getLineNumber(depth);
	}

	if (hasErrorCode(depth)) {
		stream << " [";

		if (!hasErrorCodeName(depth)) {
			stream << "Code:";
		}

		stream << getErrorCode(depth);

		if (hasErrorCodeName(depth)) {
			stream << ":";
			formatErrorCodeName(stream, depth);
		}

		stream << "]";
	}

	if (hasMessage(depth)) {
		stream << " " ;
		formatMessage(stream, depth);
	}
#ifdef UTIL_STACK_TRACE_ENABLED

	if (hasStackTrace(depth)) {
		stream << " : " ;
		formatStackTrace(stream, depth);
	}
#endif
}
Esempio n. 15
0
   void ExceptionLocation::dump(ostream& s) const
      throw()
   { 
      s << getFileName() << ":" 
#ifdef __FUNCTION__
        << getFunctionName() << ":" 
#endif
        << getLineNumber(); 
   }
Esempio n. 16
0
List* FunctionListInsert(List* function_list,DICT_NODE* node, int type, int size, int label){
	if(list_lookup(function_list,node->text)==NULL){
		function_list=list_insert(function_list,type,size,node->text,label);
	} 
	else{
		printf("->Redeclaracao de funcao (linha %d)\n", getLineNumber());
		exit(IKS_ERROR_DECLARED);
	}
	return function_list;
}
Esempio n. 17
0
List* LocalVarListInsert(List* local_var,DICT_NODE* node, int type, int size, List* function_list){
	if(list_lookup(local_var,node->text)==NULL){
		local_var=list_insert(local_var,type,size,node->text,0);
	} 
	else{
		printf("->Redeclaracao de variavel local (linha %d)\n", getLineNumber());
		exit(IKS_ERROR_DECLARED);
	}
	return local_var;
}
Esempio n. 18
0
void Parser::accept(SymbolType symbolType)
{
	if (currentSymbol_.symbolType_ == symbolType)
	{
		getNextSymbol();
	}
	else
	{
		throw ErrorMessage("Expected " + keywordToString(symbolType), getLineNumber());
	}
}
Esempio n. 19
0
static Variant HHVM_FUNCTION(assert, const Variant& assertion,
                             const Variant& message /* = null */) {
  if (!s_option_data->assertActive) return true;

  CallerFrame cf;
  Offset callerOffset;
  auto const fp = cf(&callerOffset);

  auto const passed = [&]() -> bool {
    if (assertion.isString()) {
      if (RuntimeOption::EvalAuthoritativeMode) {
        // We could support this with compile-time string literals,
        // but it's not yet implemented.
        throw_not_supported("assert()",
          "assert with strings argument in RepoAuthoritative mode");
      }
      return eval_for_assert(fp, assertion.toString()).toBoolean();
    }
    return assertion.toBoolean();
  }();
  if (passed) return true;

  if (!s_option_data->assertCallback.isNull()) {
    auto const unit = fp->m_func->unit();

    PackedArrayInit ai(3);
    ai.append(String(const_cast<StringData*>(unit->filepath())));
    ai.append(Variant(unit->getLineNumber(callerOffset)));
    ai.append(assertion.isString() ? assertion : empty_string_variant_ref);
    HHVM_FN(call_user_func)(s_option_data->assertCallback, ai.toArray());
  }
  if (s_option_data->assertException) {
    if (message.isObject()) {
      Object exn = message.toObject();
      if (exn.instanceof(SystemLib::s_AssertionErrorClass)) {
        throw_object(exn);
      }
    }

    SystemLib::throwExceptionObject(message.toString());
  }
  if (s_option_data->assertWarning) {
    String name(message.isNull() ? "Assertion" : message.toString());
    auto const str = !assertion.isString()
      ? " failed"
      : concat3(" \"",  assertion.toString(), "\" failed");
    raise_warning("assert(): %s%s", name.data(),  str.data());
  }
  if (s_option_data->assertBail) {
    throw ExitException(1);
  }

  return init_null();
}
/*
 LLBVHLoader::LLBVHLoader(const char* buffer)
{
	reset();

	mStatus = loadTranslationTable("anim.ini");

	if (mStatus == LLBVHLoader::ST_NO_XLT_FILE)
	{
		LL_WARNS() << "NOTE: No translation table found." << LL_ENDL;
		return;
	}
	else
	{
		if (mStatus != LLBVHLoader::ST_OK)
		{
			LL_WARNS() << "ERROR: [line: " << getLineNumber() << "] " << mStatus << LL_ENDL;
			return;
		}
	}

	char error_text[128];		// Flawfinder: ignore 
	S32 error_line;
	mStatus = loadBVHFile(buffer, error_text, error_line);
	if (mStatus != LLBVHLoader::ST_OK)
	{
		LL_WARNS() << "ERROR: [line: " << getLineNumber() << "] " << mStatus << LL_ENDL;
		return;
	}

	applyTranslations();
	optimize();

	mInitialized = TRUE;
}
*/
LLBVHLoader::LLBVHLoader(const char* buffer, ELoadStatus &loadStatus, S32 &errorLine)
{
	reset();
	errorLine = 0;
	mStatus = loadTranslationTable("anim.ini");
	loadStatus = mStatus;
	LL_INFOS() << "Load Status 00 : " << loadStatus << LL_ENDL;
	if (mStatus == E_ST_NO_XLT_FILE)
	{
		//LL_WARNS() << "NOTE: No translation table found." << LL_ENDL;
		loadStatus = mStatus;
		return;
	}
	else
	{
		if (mStatus != E_ST_OK)
		{
			//LL_WARNS() << "ERROR: [line: " << getLineNumber() << "] " << mStatus << LL_ENDL;
			errorLine = getLineNumber();
			loadStatus = mStatus;
			return;
		}
	}
	
	char error_text[128];		/* Flawfinder: ignore */
	S32 error_line;
	mStatus = loadBVHFile(buffer, error_text, error_line);
	
	if (mStatus != E_ST_OK)
	{
		//LL_WARNS() << "ERROR: [line: " << getLineNumber() << "] " << mStatus << LL_ENDL;
		loadStatus = mStatus;
		errorLine = getLineNumber();
		return;
	}
	
	applyTranslations();
	optimize();
	
	mInitialized = TRUE;
}
Esempio n. 21
0
int sserror(int errCode, DictItem *symEntry) {
	switch(errCode) {
			/* Verificação de declarações */
		case IKS_ERROR_UNDECLARED:
			printf("IKS-ssa:@l:%d Identificador ' %s ' não declarado. \n", symEntry->occLine, symEntry->symbol.name); break;
		case IKS_ERROR_DECLARED:
			printf("IKS-ssa:@l:%d Redefinindo identificador ' %s ' (definido originalmente @l:%d). \n", getLineNumber(), symEntry->symbol.name, symEntry->occLine); break;
			
			/* Uso correto de identificadores */
		case IKS_ERROR_VARIABLE:
			printf("IKS-ssa:@l:%d Identificador ' %s ' deve ser utilizado como variável. \n", getLineNumber(), symEntry->symbol.name); break;
		case IKS_ERROR_VECTOR:
			printf("IKS-ssa:@l:%d Identificador ' %s ' deve ser utilizado como vetor.\n", getLineNumber(), symEntry->symbol.name); break;
		case IKS_ERROR_FUNCTION :
			printf("IKS-ssa:@l:%d Identificador ' %s ' deve ser utilizado como função.\n",getLineNumber(), symEntry->symbol.name); break;
			
			/* Tipos e tamanho de dados */
		case IKS_ERROR_WRONG_TYPE: 
			printf("IKS-ssa:@l:%d Tipos incompatíveis.\n", getLineNumber()); break;
		case IKS_ERROR_STRING_TO_X:
			printf("IKS-ssa:@l:%d Coerção impossível do tipo string.\n", getLineNumber()); break;
		case IKS_ERROR_CHAR_TO_X:  
			printf("IKS-ssa:@l:%d Coerção impossível do tipo char.\n", getLineNumber()); break;
			
			/* Argumentos e parâmetros */
		case IKS_ERROR_MISSING_ARGS:
			printf("IKS-ssa:@l:%d Faltam argumentos para funcao.\n", getLineNumber()); break;
		case IKS_ERROR_EXCESS_ARGS: 
			printf("IKS-ssa:@l:%d Excesso de argumentos para funcao. \n", getLineNumber()); break;
		case IKS_ERROR_WRONG_TYPE_ARGS: 
			printf("IKS-ssa:@l:%d Argumentos incompatíveis para funcao. \n", getLineNumber()); break;
			
			/* Verificação de tipos em comandos */
		case IKS_ERROR_WRONG_PAR_INPUT: 
			printf("IKS-ssa:@l:%d Parâmetro no comando 'input' não é identificador. \n", getLineNumber()); break;
		case IKS_ERROR_WRONG_PAR_OUTPUT: 
			printf("IKS-ssa:@l:%d Parâmetro no comando 'output' não é literal string ou expressão.\n", getLineNumber()); break;
		case IKS_ERROR_WRONG_PAR_RETURN: 
			printf("IKS-ssa:@l:%d - Parâmetro no comando 'return' não é expressão compatível com tipo do retorno . \n", getLineNumber()); break;
	}
}
Esempio n. 22
0
List* GlobalVarListInsert(List* list,DICT_NODE* node,int control,int type, int size){
	switch(control){
		case GLOBAL_VAR_DEC_IDENTIFIER_CONTROL:		if(list_lookup(list,node->text)==NULL)
									list=list_insert(list,type,size,node->text,0); 
								else{
									printf("->Redeclaracao de variavel global (linha = %d)\n", getLineNumber());
									exit(IKS_ERROR_DECLARED);
								}		
								break;

		case GLOBAL_VET_DEC_IDENTIFIER_CONTROL:		if(list_lookup(list,node->text)==NULL){
									list=list_insert(list,type,size,node->text,0);
								}
								else{
									printf("->Redeclaracao de vetor (linha %d)\n", getLineNumber());
									exit(IKS_ERROR_DECLARED); 
								}
								break;
	}
	return list;
}
Esempio n. 23
0
NodePointer Parser::localVariable()
{
	accept(MY);
	if (currentSymbol_.symbolType_ == IDENTIFIER)
	{
		return NodePointer(new LocalVariable(currentSymbol_.value_.toString(), tables_));
	}
	else
	{
		throw ErrorMessage("Variable expected", getLineNumber());
	}
}
Esempio n. 24
0
static int64_t HHVM_FUNCTION(xdebug_call_line) {
  // PHP5 xdebug returns 0 when it can't determine the line number.
  Offset pc;
  auto fp = get_call_fp(&pc);
  if (fp == nullptr) {
    return 0;
  }

  auto const unit = fp->m_func->unit();
  assert(unit);
  return unit->getLineNumber(pc);
}
Esempio n. 25
0
std::string show(SrcKey sk) {
  auto func = sk.func();
  auto unit = sk.unit();
  const char *filepath = "*anonFile*";
  if (unit->filepath()->data() && unit->filepath()->size()) {
    filepath = unit->filepath()->data();
  }
  return folly::format("{}:{} in {}(id 0x{:#x})@{: >6}",
                       filepath, unit->getLineNumber(sk.offset()),
                       func->isPseudoMain() ? "pseudoMain"
                                            : func->fullName()->data(),
                       (unsigned long long)sk.getFuncId(), sk.offset()).str();
}
Esempio n. 26
0
NodePointer Parser::procedureDefinition()
{
	getNextSymbol();
	std::string name = "&" + currentSymbol_.value_.toString();
	accept(DEFINITION);
	NodePointer definition = blockStatement();
	if (tables_.subroutineTable_.find(name) != tables_.subroutineTable_.end())
	{
		throw ErrorMessage("Multiple definition of subroutine " + name, getLineNumber());
	}
	tables_.subroutineTable_[name] = definition;
	return NodePointer(new EmptyNode());
}
Esempio n. 27
0
int main (int argc, char ** argv)
{
    FILE *srcFilePointer = NULL;

    if (argc != 3)
    {
        fprintf(stderr, "ERROR! Input and output files must be defined! \nUsage: etapa6 inputFile outputFile\n");
        exit(2);
    }

    initMe();

    srcFilePointer = fopen(argv[1], "r");

    if (srcFilePointer == NULL)
    {
        fprintf(stderr, "ERROR! The input file could not be opened! \nUsage: etapa6 inputFile outputFile\n");
        exit(2);
    }

    yyin = srcFilePointer;
    if (yyparse() != 0)
    {
        fprintf(stderr, "Syntax error in line: %i\n\n", getLineNumber()+1);
        exit(3);
    }

    DEST_FILE = fopen(argv[2], "w");

    if (DEST_FILE == NULL)
    {
        fprintf(stderr, "ERROR! The output file could not be opened! \nUsage: etapa6 inputFile outputFile\n");
        exit(2);
    }

    //descompileTree(astTree);
    //astPrint(astTree, 0);
    hashPrint();

    if (semanticErrors > 0)
    {
        printf("\n\nSemantic error!\n");
        exit(4);
    }
    else
    {
        printf("\n\nProgram sucessful!\n\n");
        exit(0);
    }
}
Esempio n. 28
0
list<string> getOutgroup(string fn){
    list<string> result;
    int lineNb=getLineNumber(fn);
    FILE * o = fopen(fn.c_str(),"rt");
    if (o==NULL) cout<<"Impossible to open outgroup file"<<endl;
    else{
        int ino=readInt(o,"Error in the outgroup file, the file should begin with an integer (the number of outgroups)");
        if (lineNb-1<ino) {
            cout<<"The number of given outgroups is small than the number of outgroups to read. Please change the number of outgroups to read at the first line of the outgroup file."<<endl;
            exit(EXIT_FAILURE);
        }
        for (int i=0;i<ino;i++) result.push_back(readWord(o,fn));
    }
    return result;
}
Esempio n. 29
0
void QFCompleterTextEditWidget::cursorChanged() {
    emit cursorMoved(getLineNumber(), getColumnNumber());
    QString s=validTextUnderCursor().trimmed();
    //std::cout<<s.toLatin1().data()<<std::endl;
    if (currentTextUnderCursor!=s) {
        currentTextUnderCursor=s;
        emit wordUnderCursorChanged(s);
    }

    /*std::cout<<"document()->documentLayout()->documentSize() = "<<document()->documentLayout()->documentSize().width()<<"   "<<document()->documentLayout()->documentSize().height()<<std::endl;
    std::cout<<"verticalScrollBar()->value() = "<<verticalScrollBar()->value()<<std::endl;
    std::cout<<"verticalScrollBar()->min  max = "<<verticalScrollBar()->minimum()<<"  "<<verticalScrollBar()->maximum()<<std::endl;
    std::cout<<"viewport()->height() = "<<viewport()->height()<<std::endl;
    std::cout<<"viewport()->width() = "<<viewport()->width()<<std::endl;*/
}
Esempio n. 30
0
int getLineNumber(ASTNode* AT)
{
    if(AT == NULL)
        return -1;
    if(isTerminal(AT->nodeid))
        return AT->tk.lineNum;
    int i;
    for (i = 0; i < AT->child_cnt; ++i)
    {
        int ln = getLineNumber(AT->children[i]);
        if(ln != -1)
            return ln;
    }
    return -1;
}