Exemplo n.º 1
0
void ASNLexer::SkipComment(void)
{
    CComment& comment = AddComment();
    while ( true ) {
        // wait for end of comments
        char c = Char();
        switch ( c ) {
        case '\n':
            SkipChar();
            NextLine();
            return;
        case 0:
            if ( Eof() )
                return;
            break;
        case '-':
            if ( Char(1) == '-' ) {
                SkipChars(2);
                return;
            }
            break;
        case '*':
            if ( Char(1) == '/' ) {
                SkipChars(2);
                return;
            }
            break;
        }
        comment.AddChar(c);
        SkipChar();
    }
}
Exemplo n.º 2
0
void ASNLexer::LookupComments(void)
{
    while ( true ) {
        char c = Char();
        switch ( c ) {
        case ' ':
        case '\t':
        case '\r':
            SkipChar();
            break;
        case '\n':
            SkipChar();
            NextLine();
            break;
        case '-':
            if ( Char(1) == '-' ) {
                // comments
                SkipChars(2);
                SkipComment();
                break;
            }
            return;
        case '/':
            if ( Char(1) == '*' ) {
                // comments
                SkipChars(2);
                SkipComment();
                break;
            }
            return;
        default:
            return;
        }
    }
}
Exemplo n.º 3
0
// -----------------------------------------------------------------------------
int Action_NMRrst::ReadNmrRestraints( std::string const& rstfilename )
{
  BufferedLine infile;
  if (infile.OpenFileRead( rstfilename )) return 1;
  // Try to determine what kind of file.
  const char* ptr = infile.Line();
  // Try to skip past any blank lines and comments
  while ( SkipChar( ptr ) )
    ptr = infile.Line();
  if (ptr == 0) {
    mprinterr("Error: Unexpected end of restraint file.\n");
    return 1; 
  }
  std::string inputLine( ptr );
  infile.CloseFile();
  // Re-open file
  if (infile.OpenFileRead( rstfilename )) return 1;
  int err = 0;
  if ( inputLine.compare(0, 7, "*HEADER")==0 ||
       inputLine.compare(0, 6, "*TITLE")==0 ||
       inputLine.compare(0, 6, "assign")==0 )
    // XPLOR
    err = ReadXplor( infile );
  else
    // Assume DIANA/Amber
    err = ReadAmber( infile );
  infile.CloseFile();
  if (err != 0) {
    mprinterr("Error: Could not parse restraint file.\n");
    return 1;
  }
  return 0;
}
Exemplo n.º 4
0
static Int32 ArrayValue(Int32 size)
{
	Int32 repeat;
	
	vm_gen0(op_dup);					/* var */

	if( Token==tINTCONST && LookAheadChar()=='x' )
	{
		/* Handle array repeat operator.
		   We must use an intconst because 
		   we need to know the array size 
		   at compile time. */
		repeat = GetInt();
		SkipChar();
		SkipToken(tINTCONST);
		vm_genI(op_pushint,size);		/* start-idx */
		size += repeat;
		vm_genI(op_pushint,size-1); 	/* end-idx   */
		Expr(); 						/* val       */
		vm_gen0(op_setslice);
	}
	else
	{
		/* single expression */
		vm_genI(op_pushint,size++); 	/* idx */
		Expr(); 						/* val */
		vm_gen0(op_setarray);
	}
	
	return size;
}
Exemplo n.º 5
0
/* This routine extracts tokens from a string that are separated by one or
   more spaces.  It returns the number of tokens found. */
int tokenize(char *ptr, char *tokens[])
{
    int num = 0;

    while (*ptr)
    {
        ptr = SkipChar(ptr, ' ');
        if (*ptr == 0) break;
        if (ptr[0] == '>')
        {
            ptr++;
            if (ptr[0] == '>')
            {
                tokens[num++] = ">>";
                ptr++;
            }
            else
                tokens[num++] = ">";
            continue;
        }
        if (ptr[0] == '<')
        {
            ptr++;
            tokens[num++] = "<";
            continue;
        }
        tokens[num++] = ptr;
        ptr = FindChar(ptr, ' ');
        if (*ptr) *ptr++ = 0;
    }
    return num;
}
Exemplo n.º 6
0
	bool Parser::SkipString(const char * s)
	{
		for (; *s != '\0'; ++s)
		{
			if (!SkipChar(*s))
			{
				return false;
			}
		}

		return true;
	}
Exemplo n.º 7
0
void Lexer(char* CharSource, Token* TokSource)
{
    char* CurChar = CharSource;
    Token* CurToken = TokSource;

    while (*CurChar != '\0')
    {
        GetNum(&CurChar, &CurToken);
        GetOper(&CurChar, &CurToken);
        GetPar(&CurChar, &CurToken);
        SkipChar(&CurChar);
    }
    CurToken->type = END;

    size_t i = 0;
    while ( TokSource[i].type != END )
    {
        switch (TokSource[i].type)
        {
        /* case OPER */
        case ADDITIVE_OPER:
            ;
        case MULTIPLICATIVE_OPER:
            ;
        case POWER_OPER:
            printf("%c", TokSource[i].value.oper);
            break;

        /* case PAR */
        case LPAR:
        case RPAR:
            printf("%c", TokSource[i].value.par);
            break;

        /* case NUM */
        case NUM:
            printf("[%f]", TokSource[i].value.number);
            break;
        case END:
            break;
        default:
            fprintf(stderr, "unexpected token %d\n", TokSource[i].type);
        }
        i++;
    }

    printf("\n");
}
Exemplo n.º 8
0
/** Read Amber/DIANA style restraints. */
int Action_NMRrst::ReadAmber( BufferedLine& infile ) {
  noeDataType NOE;
  const char* ptr = infile.Line();
  if (ptr == 0) {
    mprinterr("Error: Unexpected end of Amber restraint file.\n");
    return 1;
  }
  char rname1[16], rname2[16], aname1[16], aname2[16];
  double l_bound, u_bound;
  while (ptr != 0) {
    if (!SkipChar(ptr)) {
      int cols = sscanf( ptr, "%d %s %s %d %s %s %lf %lf",
                         &NOE.resNum1_, rname1, aname1,
                         &NOE.resNum2_, rname2, aname2,
                         &l_bound, &u_bound );
      if (cols == 7) { // 7-column, upper-bound only
        NOE.bound_ = 0.0;
        NOE.boundh_ = l_bound;
      } else if (cols == 8) { // 8-column, lower/upper bounds
        NOE.bound_ = l_bound;
        NOE.boundh_ = u_bound;
      } else {
        mprinterr("Error: Expected only 7 or 8 columns in Amber restraint file, got %i.\n", cols);
        return 1;
      }
      NOE.rexp_ = -1.0;
      NOE.dist_ = 0;
      NOE.resNum1_ += resOffset_;
      NOE.resNum2_ += resOffset_;
      if (NOE.resNum1_ < 1 || NOE.resNum2_ < 1) {
        mprinterr("Error: One or both residue numbers are out of bounds (%i, %i)\n"
                  "Error: Line: %s", NOE.resNum1_, NOE.resNum2_, ptr);
      } else {
        NOE.aName1_.assign( aname1 );
        NOE.aName2_.assign( aname2 );
        NOEs_.push_back( NOE );
      }
    }
    ptr = infile.Line();
  }
  return 0;
}
Exemplo n.º 9
0
void    QueryS(uchar  cbIn, uchar  cbOut)
{
  uchar bCrc = MakeCrcSOutBuff(1, cbOut-3);

  InitPush(0);
  PushChar(0xC0);

  uchar i;
  for (i=0; i<cbOut-3; i++) SkipChar();

  PushChar(bCrc);
  PushChar(0xC0);


  for (i=0; i<=cbOut-1; i++)
    mpbOutBuffSave[i] = OutBuff(i);

  uchar j = 0;
  SetOutBuff(j++, 0xC0);
  for (i=1; i<=cbOut-2; i++)
  {
    if (mpbOutBuffSave[i] == 0xC0)
    {
      SetOutBuff(j++, 0xDB);
      SetOutBuff(j++, 0xDC);
    }
    else if (mpbOutBuffSave[i] == 0xDB)
    {
      SetOutBuff(j++, 0xDB);
      SetOutBuff(j++, 0xDD);
    }
    else
    {
      SetOutBuff(j++, mpbOutBuffSave[i]);
    }
  }
  SetOutBuff(j++, 0xC0);


  Query(cbIn,j,true);
}