예제 #1
0
파일: testintr.c 프로젝트: Ntropy/DSSP-C
 void	GetWord ()	{	// read next word  in FWORD 
	// Word is the sequence of characters between spaces
	//  or equal symbols (tabs, lf, cr )
	int32	i; 
	i=0;
	
	if (NewLine) {
		printf("\n* "); NewLine=FALSE;
	}
	// skip spaces before WORD
	while (Ch==SP) {
		GetCh();
		if (NewLine) {
				printf("\n? "); NewLine=FALSE;
		}
	}
	// get chars of WORD until next space
	do { 
		FWORD[i]=Ch; i++;
		GetCh();
	} while (Ch!=SP);
	
	FWORD[i]='\0';

 } // GetWord
//////////////////////////////////////////////////////////////////////////
//
// Skips spaces, tabs, newlines, and comments
//
void Tokenizer::SkipWhiteSpace() {
  while (isspace(CurrentCh) && CurrentCh ) {
    GetCh();
  }

  if( '/' == CurrentCh )  // Look for comments
  {
    GetCh();
    if( '/' == CurrentCh )
    {
      // Throw out everything until the end of the line
      while( '\n' != CurrentCh )
      {
        GetCh();
      }
    }
    else if ( '*' == CurrentCh )
    {
      int startLine = CurLine();
      while( true )
      {
        GetCh();
        if( '*' == CurrentCh )
        {
          GetCh();
          if( CondReadCh( '/' ) )
            break;
          else if ( buffer.isEOF() )
          {
            std::ostringstream ost;
            ost << "Unterminated comment in line ";
            ost << startLine;
            throw SyntaxErrorException( ost.str(), *this );
          }
        }
        else if ( buffer.isEOF() )
        {
          std::ostringstream ost;
          ost << "Unterminated comment in line ";
          ost << startLine;
          throw SyntaxErrorException( ost.str(), *this );
        }
      }
    }
    else
    {
      std::ostringstream ost;
      ost << "unexpected character: '" << CurrentCh << "'";
	  throw SyntaxErrorException( ost.str(), *this );
    }

    SkipWhiteSpace();  // We may need to throw out
                       //  more white space/comments
                       // This is admittedly tail recursion...
  }
}
예제 #3
0
파일: html.cpp 프로젝트: pikma/Snap
void THtmlLx::GetMetaTag(){
  Sym=hsyMTag;
  if (Ch=='-'){
    char PCh=' ';
    while ((Ch!=TCh::EofCh) && ((PCh!='-')||(Ch!='>'))){PCh=Ch; GetCh();}
  } else {
    while ((Ch!=TCh::EofCh) && (Ch!='>')){GetCh();}
  }
  if (Ch!=TCh::EofCh){GetEscCh();}
}
예제 #4
0
파일: fl.cpp 프로젝트: andrejmuhic/qminer
bool TSIn::GetNextLn(TChA& LnChA){
  LnChA.Clr();
  while (!Eof()){
    const char Ch=GetCh();
    if (Ch=='\n'){return true;}
    if (Ch=='\r' && PeekCh()=='\n'){GetCh(); return true;}
    LnChA.AddCh(Ch);
  }
  return !LnChA.Empty();
}
Token* Tokenizer::GetQuotedIdent() {
  GetCh();   // Throw out beginning '"'

  std::ostringstream ident;
  while ( '"' != CurrentCh ) {
    if( '\n' == CurrentCh )
      throw SyntaxErrorException( "Unterminated string constant", *this );

    ident << CurrentCh;
    GetCh();
  }
  GetCh();
  return new IdentToken( ident.str() );
}
예제 #6
0
/* GetInLine: read a complete line from source */
static char *GetInLine(char *buf)
{
   int  i, c;

   c = GetCh(&source);
   if (c==EOF)
      return NULL;
   i = 0;
   while (c!='\n' && i<MAXSTRLEN) { 
      buf[i++] = c;
      c = GetCh(&source);
   } 
   buf[i] = '\0';
   return buf;
}
예제 #7
0
파일: lx.cpp 프로젝트: kidaa/Cascade-NETINF
PSIn TILx::GetSIn(const char& SepCh) {
    IAssert(PrevSymStStack.Empty());
    while ((Ch!=TCh::EofCh)&&(Ch!=SepCh)) {
        GetCh();
    }
    return SIn;
}
예제 #8
0
int GetANumber( void )
{
	int accum = 0;
	int len = 0;
	TEXTCHAR ch;
	// make sure the prompt has been issued
	fflush( stdout );
	g.flags.bChoiceNeedsEnter = 1;
	while( 1 )
	{ 
		ch = GetCh();
		if( ch == '\b' )
		{
			accum /= 10;
		}
		if( ch == '\r' || ch == '\n' )
			break;
		if( ch == 3 )
			exit(1);
		if( ch >= '0' && ch <= '9' )
		{
			accum *= 10;
			accum += ch - '0';
		}
		while( len-- )
			printf( WIDE("\b \b") );
		len = printf( WIDE("%d"), accum );
		fflush( stdout );
		if( !accum && ch == '0' )
         break;
	}
	printf( WIDE("\n") );
	g.flags.bChoiceNeedsEnter = 0;
   return accum;
}
예제 #9
0
TStr THttpLx::GetRespReasonPhrase(){
  GetLws();
  TChA RPStr;
  while (!Eof()&&ChDef.IsText(Ch)&&(Ch!=TCh::CrCh)&&(Ch!=TCh::LfCh)){
    RPStr+=Ch; GetCh();}
  return RPStr;
}
예제 #10
0
Reader::Reader(Interpreter* interpreter, const std::string& str)
    : interpreter_(interpreter)
{
    input_.str(str);
    GetCh();
    GetToken();
}
예제 #11
0
int XMLDocument::ParseDocument()
{
    char Ch;
    SkipWhiteSpaces();
    while (currentChar!='\0' && !hasError)
    {
        XMLNodeParser * Node=new XMLNodeParser(this);
        Ch=GetCh();
        if (Ch=='<')
        {
            NextChar();
            if (Node->ParseNode())
            {
                if (Node->type!=Type_Unknown) Childs.push_back(Node);
                SkipWhiteSpaces();
            }
            else
            {
                delete Node;
                break;
            }
        }
        else 
        {
            hasError=true;
            Error="Document should consist only from nodes rounded with <name /> or <name></name> tags";
            break;
        }
    }
    return (int)hasError;
}
예제 #12
0
TWixExpLxSym TWixExpLx::GetSym(const TFSet& Expect){
  Str.Clr();
  while (ChDef.IsSpace(Ch)){GetCh();}
  if (Expect.In(wesyNum)){
    if (!ChDef.IsNum(Ch)){throw EWixExp("Number expected.");}
    Sym=wesyNum;
    do {Str.AddCh(Ch); GetCh();} while (ChDef.IsNum(Ch));
  } else {
    switch (ChDef.GetChTy(Ch)){
      case welctAlpha:
      case welctNum:
        do {Str.AddCh(Ch); GetCh();} while (ChDef.IsAlNum(Ch));
        if (Str=="OR"){Sym=wesyOr;}
        else if (Str=="AND"){Sym=wesyAnd;}
        else if (Str=="NOT"){Sym=wesyNot;}
        else {Sym=wesyWord;}
        break;
      case welctSym:
        Str.AddCh(Ch);
        switch (Ch){
          case ':': Sym=wesyColon; break;
          case '(': Sym=wesyLParen; break;
          case ')': Sym=wesyRParen; break;
          case '|': Sym=wesyOr; break;
          case '&': Sym=wesyAnd; break;
          case '!': Sym=wesyNot; break;
          case '+': Sym=wesyIncl; break;
          case '-': Sym=wesyExcl; break;
          case '*': Sym=wesyWCard; break;
          default: Sym=wesySSym;
        }
        GetCh();
        break;
      case welctEof: Sym=wesyEof; break;
      default: Sym=wesyUndef; GetCh();
    }
  }

  if ((!Expect.In(Sym))&&(!Expect.Empty())){
    if (Sym==wesyEof){
      throw EWixExp("Unexpected end of expression.");
    } else {
      throw EWixExp("Unexpected symbol.");
    }
  }
  return Sym;
}
bool Tokenizer::CondReadCh(char c) {
  if (c == CurrentCh) {
    GetCh();
    return true;
  } else {
    return false;
  }
}
예제 #14
0
TStr THttpLx::GetUrlStr(){
  TChA UrlChA;
  while ((!Eof())&&(!ChDef.IsSp(Ch))){
    UrlChA+=Ch; GetCh();}
  if (UrlChA.Empty()){
    throw THttpEx(heUrlEmpty);}
  return UrlChA;
}
예제 #15
0
NS_IMETHODIMP
HTMLTableCellElement::GetCh(nsAString& aCh)
{
  DOMString ch;
  GetCh(ch);
  ch.ToString(aCh);
  return NS_OK;
}
예제 #16
0
NS_IMETHODIMP
HTMLTableRowElement::GetCh(nsAString& aCh)
{
  nsString ch;
  GetCh(ch);
  aCh = ch;
  return NS_OK;
}
예제 #17
0
파일: html.cpp 프로젝트: pikma/Snap
void THtmlLx::GetEscCh(){
  GetCh();
  EscCh=(Ch=='&');
  if (EscCh){
    EscChA.Clr(); EscChA.AddCh(Ch); GetCh();
    if (Ch=='#'){
      EscChA.AddCh(Ch); GetCh();
      if (('0'<=Ch)&&(Ch<='9')){
        do {EscChA.AddCh(Ch); GetCh();} while (('0'<=Ch)&&(Ch<='9'));
        if (Ch==';'){GetCh();}
        PutStr(ChDef.GetEscStr(EscChA));
      } else {
        PutCh('#'); PutCh('&');
      }
    } else
    if (('a'<=Ch)&&(Ch<='z')||('A'<=Ch)&&(Ch<='Z')){
      do {
        EscChA.AddCh(Ch); GetCh();
      } while (('A'<=Ch)&&(Ch<='Z')||('a'<=Ch)&&(Ch<='z')||('0'<=Ch)&&(Ch<='9'));
      if (Ch==';'){GetCh();}
      PutStr(ChDef.GetEscStr(EscChA));
    } else {
      PutCh('&');
    }
  }
}
Token* Tokenizer::GetScalar() {
  // an INTEGER token
  string ret( "" );
  while (isdigit(CurrentCh) || '-' == CurrentCh || '.' == CurrentCh || 'e' == CurrentCh ) {
    ret += CurrentCh;
    GetCh();
  }
  return new ScalarToken( atof( ret.c_str() ) );
}
void AlignToMovementSteering::DrawDebug() {
	Character * ch = GetCh();
	MOAIGfxDevice& gfxDevice = MOAIGfxDevice::Get();
	gfxDevice.SetPenColor(0.0f, 0.0f, 1.0f, 0.5f);

	//LinearAcc
	/*gfxDevice.SetPenColor(0.0f, 1.0f, 0.0f, 0.5f);
	MOAIDraw::DrawLine(ch->GetLoc(), ch->GetLoc() * ch->GetAngularVelocity());*/

}
Token* Tokenizer::GetIdent() {
  // an IDENTIFIER or a RESERVED WORD token
  std::ostringstream ident;
  while (isalnum(CurrentCh) || '_' == CurrentCh || '-' == CurrentCh) { 
    // While we still have something that can
    ident << CurrentCh;
    GetCh();
  }
  return SearchReserved(ident.str());
}
예제 #21
0
void Reader::GetReal()
{
    std::string real;
    while (isdigit(ch_)) {
        real += ch_;
        GetCh();
    }
    token_ = ReaderTokenType::Real;
    realVal_ = atoi(real.c_str());
}
예제 #22
0
void Reader::GetSymbol()
{
    std::string name;
    while (isalnum(ch_) || ch_ == '-') {
        name += ch_;
        GetCh();
    }
    token_ = ReaderTokenType::Symbol;
    symbolName_ = name;
}
예제 #23
0
bool THttpLx::IsLws(){
  if ((Ch==' ')||(Ch==TCh::TabCh)){
    return true;
  } else
  if (Ch==TCh::CrCh){
    GetCh();
    if (Ch==TCh::LfCh){
      GetCh(); bool Ok=(Ch==' ')||(Ch==TCh::TabCh);
      PutCh(TCh::LfCh); PutCh(TCh::CrCh); return Ok;
    } else {
      PutCh(TCh::CrCh); return false;
    }
  } else
  if (Ch==TCh::LfCh){
    GetCh(); bool Ok=(Ch==' ')||(Ch==TCh::TabCh);
    PutCh(TCh::LfCh); return Ok;
  } else {
    return false;
  }
}
예제 #24
0
THttpRqMethod THttpLx::GetRqMethod(){
  TChA MethodNm;
  while (!Eof() && ChDef.IsAlpha(Ch)){
    MethodNm+=Ch; GetCh();}
  THttpRqMethod Method=hrmUndef;
  if (MethodNm==THttp::GetMethodNm){Method=hrmGet;}
  else if (MethodNm==THttp::HeadMethodNm){Method=hrmHead;}
  else if (MethodNm==THttp::PostMethodNm){Method=hrmPost;}
  if (Method==hrmUndef){throw THttpEx(heMethodNmExpected);}
  return Method;
}
예제 #25
0
PUrl THttpLx::GetUrl(){
  TChA UrlChA;
  while ((!Eof())&&(!ChDef.IsSp(Ch))){
    UrlChA+=Ch; GetCh();}
  if (UrlChA.Empty()){
    throw THttpEx(heUrlEmpty);}
  static TStr LocalBaseUrlStr="http://localhost/";
  PUrl Url=PUrl(new TUrl(UrlChA, LocalBaseUrlStr));
  if (!Url->IsOk()){
    throw THttpEx(heBadUrl);}
  return Url;
}
예제 #26
0
void Reader::GetToken()
{
    while (isspace(ch_)) {
        GetCh();
    }

    switch (ch_) {
    case '(':
        token_ = ReaderTokenType::LParen;
        GetCh();
        break;
    case ')':
        token_ = ReaderTokenType::RParen;
        GetCh();
        break;
    case '*':
    case '+':
        token_ = ReaderTokenType::Symbol;
        symbolName_ = std::string(1, ch_);
        GetCh();
        break;
    case '-':
        GetCh();
        if (isdigit(ch_)) {
            GetReal();
            realVal_ = -realVal_;
        }
        else {
            token_ = ReaderTokenType::Symbol;
            symbolName_ = std::string(1, '-');
        }
        break;
    case '.':
        token_ = ReaderTokenType::Dot;
        GetCh();
        break;
    case EOF:
        token_ = ReaderTokenType::EndOfInput;
        break;
    default:
        if (isdigit(ch_)) {
            GetReal();
        }
        else if (isalpha(ch_)) {
            GetSymbol();
        }
        else {
            token_ = ReaderTokenType::Undefined;
            GetCh();
        }
        break;
    }
}
예제 #27
0
int GetYesNo( void )
{
	TEXTCHAR ch;
   // make sure the prompt has been issued
   fflush( stdout );
	g.flags.bChoiceNeedsEnter = 0;
	ch = GetCh();
   printf( WIDE("\n") );
	if( ch == 'y' || ch == 'Y' )
	{
		return TRUE;
	}
	return FALSE;
}
//45deg of img offset
void AlignToMovementSteering::Update(Accelerations &acc, USVec2D target) {
	Character * ch = GetCh();

	USVec2D direction = ch->GetLinearVelocity();
	direction.Norm();

	float wishAngVel = 0;
	if (direction.mX != 0) {
		wishAngVel = atan2f(direction.mY, direction.mX) * RAD2DEG;
	}
	Params &par = ch->GetParams();
	par.target_rotation = wishAngVel;

	mAlignSteering->Update(acc, target);
}
예제 #29
0
/* ReadLMWord: read a string from input stream */
static char *ReadLMWord(char *buf)
{
   int i, c;
   
   if (rawMITFormat) {
      while (isspace(c=GetCh(&source)));
      i=0;
      while (!isspace(c) && c!=EOF && i<MAXSTRLEN){
         buf[i++] = c; c=GetCh(&source);
      }
      buf[i] = '\0';
      UnGetCh(c,&source);
      if (i>0)
         return buf;
      else
         return NULL;
   }
   else {
      if (ReadString(&source,buf))
         return buf;
      else
         return NULL;
   }
}
예제 #30
0
bool THttpLx::IsRespStatusLn(){
  static const TChA MouldChA="http/N.N NNN ";
  TChA TestChA(MouldChA);
  int TestLen=TestChA.Len();
  if (1+Len()<TestLen){return false;}
  TestChA.PutCh(0, ChDef.GetLcCh(Ch));
  {for (int ChN=1; ChN<TestLen; ChN++){
    TestChA.PutCh(ChN, ChDef.GetLcCh(GetCh()));}}
  {for (int ChN=1; ChN<TestLen; ChN++){
    PutCh(TestChA[TestLen-ChN-1]);}}
  {for (int ChN=0; ChN<MouldChA.Len(); ChN++){
    if (MouldChA[ChN]=='N'){
      if (!ChDef.IsDigit(TestChA[ChN])){return false;}
    } else {
      if (MouldChA[ChN]!=TestChA[ChN]){return false;}
    }
  }}
  return true;
}