Ejemplo n.º 1
0
void CIntRangeTestParameter::Construct(TDes& aValue)
	{
	if(aValue.Find(_L("..")) != KErrNotFound)
		{
		TInt pos = aValue.Find(_L(".."));
		TLex startLex(aValue.Left(pos));
		TLex endLex(aValue.Mid(pos+2));

		if(startLex.Val(iStart)!=KErrNone)
			return;
			// checks if startLex is at end of string, if not there was garbage in the string so throw it out
		else if(!startLex.Eos())
			return;

		if(endLex.Val(iFinish)!=KErrNone)
			return;
			// checks if startLex is at end of string, if not there was garbage in the string so throw it out
		else if(!endLex.Eos())
			return;
		// checks if range is doable
		if(iStart > iFinish)
			return;
		}
	else
		return;
	iValid = ETrue;
	}
Ejemplo n.º 2
0
void lisp_main(char *file)
{
	FILE *fp;
	if((fp=fopen(file,"r")) == NULL){
		printf("file open error\n");
		exit(0);
	}

	cons_t *root = Cons_New();
	token_t *lex_buf = (token_t *)malloc(sizeof(token_t));

	//--Lexer
	startLex(lex_buf,fp);
	//dumpLexer(lex_buf);

	//--Parser
	parse(lex_buf,root);
	dumpCons_t(root); //debug

	//--eval
	//printf("\n--answer:%d\n",eval(root)); //AST

	//--run
	printf("\n");
	bytecode_t *bytecode = Bytecode_New();
	hash_table_t *hash = HashTable_init();
	int esp = 1;
	//value_t st[1024];

	compile(root,bytecode,hash);
	vm_exec(bytecode,esp,hash,0);

	HashTable_free(hash);
	Bytecode_free(bytecode);
	token_free(lex_buf);
	freeCons_t(root);
	fclose(fp);
}
Ejemplo n.º 3
0
void main()
{
 clrscr();
 printf("Enter .lex file: ");
 scanf("%s", inputFile);
 myFile = fopen(inputFile,"r");
 //***************************FILE NOT FOUND
 if(myFile == NULL)
 {
 printf("File Not Found.\nPROGRAM EXIT.");
 }
 else
 {
  size_t size = strlen(inputFile);
  if(!(inputFile[size - 1] == 'e' && inputFile[size - 2] == 'o' && inputFile[size - 3] == 'm'))
    printf("File is not in specified format.\nPROGRAM EXIT.");

  else
  {
  printf("FILE FOUND. CREATING SYMBOL TABLE");
  inputFile[size - 4] = '.';
  inputFile[size - 3] = 'm';
  inputFile[size - 2] = 'l';
  inputFile[size - 1] = 'x';
  inputFile[size] = '\0';
  remove(inputFile);
  startLex();
  printf("\nSuccessful.");
  printf("\nRecognized Units: %d", iRec);
  printf("\nUnrecognized Units: %d", iUnrec);

  printf("\nFile Created: %s", inputFile);
  fclose(myFile);
  }
 }

 getch();
}
Ejemplo n.º 4
0
void main(int argc, char *argv[])
{

 if(argc > 1) {
  strcpy(inputFile, argv[1]);
  puts(inputFile);
 } else {
 printf("Enter .lex file: ");
 scanf("%s", inputFile);
}
 //***************************FILE NOT FOUND
 if((myFile = fopen(inputFile,"r")) == NULL)
 {
 printf("File Not Found.\nPROGRAM EXIT.");
 }
 else
 {
  size_t size = strlen(inputFile);
  if(!(inputFile[size - 1] == 'e' && inputFile[size - 2] == 'o' && inputFile[size - 3] == 'm'))
	printf("File is not in specified format.\nPROGRAM EXIT.");

  else
  {
  printf("FILE FOUND. CREATING SYMBOL TABLE");
  strcpy(inputFile, "output.mlx");
  remove(inputFile);
  startLex();
  printf("\nSuccessful.");
  printf("\nRecognized Units: %d", iRec);
  printf("\nUnrecognized Units: %d", iUnrec);

  printf("\nFile Created: %s", inputFile);
  fclose(myFile);
  }
 }

}