Exemplo n.º 1
0
ErrorState* ImportModule(const std::string& modulePath, ParseResult& parse)
{
  ErrorState* errorState = new ErrorState();
  FILE* f = fopen(modulePath.c_str(), "rb");

  if (!f)
  {
    RaiseError(errorState, ERROR_MALFORMED_MODULE_INFO, modulePath.c_str(), "Couldn't open file");
    return errorState;
  }

  #define CONSUME(byte)\
    if (fgetc(f) != byte)\
    {\
      RaiseError(errorState, ERROR_MALFORMED_MODULE_INFO, modulePath.c_str(), "Format not followed");\
      return errorState;\
    }

  CONSUME(0x7F);
  CONSUME('R');
  CONSUME('O');
  CONSUME('O');

  uint8_t   version         = Read<uint8_t>(f);
  uint32_t  typeCount       = Read<uint32_t>(f);
  uint32_t  codeThingCount  = Read<uint32_t>(f);

  if (version != ROO_MOD_VERSION)
  {
    RaiseError(errorState, ERROR_MALFORMED_MODULE_INFO, modulePath.c_str(), "Unsupported version");
    return errorState;
  }

  for (size_t i = 0u;
       i < typeCount;
       i++)
  {
    parse.types.push_back(Read<TypeDef*>(f));
  }

  for (size_t i = 0u;
       i < codeThingCount;
       i++)
  {
    parse.codeThings.push_back(Read<CodeThing*>(f));
  }

  fclose(f);
  return errorState;
}
Exemplo n.º 2
0
static void uuid_unpack(class_uuid_t in, __u16 *uu, int nr)
{
        __u8 *ptr = in;

	LASSERT(nr * sizeof *uu == sizeof(class_uuid_t));

	while (nr-- > 0)
		CONSUME(uu[nr], &ptr);
}
Exemplo n.º 3
0
bool EitherNodesOrAtomicsIterator::nextImpl(
    store::Item_t& result,
    PlanState& planState) const
{
  EitherNodesOrAtomicsIteratorState* state;
  DEFAULT_STACK_INIT(EitherNodesOrAtomicsIteratorState, state, planState);

  if (CONSUME(result, 0))
  {
    state->atomics = !result->isNode();

    STACK_PUSH(true, state);

    while (CONSUME(result, 0))
    {
      if (state->atomics == result->isNode())
        throw XQUERY_EXCEPTION(err::XPTY0018, ERROR_LOC(loc));

      STACK_PUSH(true, state);
    }
  }

  STACK_END(state);
}
Exemplo n.º 4
0
/** \brief Lexer rule generated by ANTLR3
 *
 * $ANTLR start HEX_CHAR
 *
 * Looks to match the characters the constitute the token HEX_CHAR
 * from the attached input stream.
 *
 *
 * \remark
 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
 */
static ANTLR3_INLINE
void mHEX_CHAR(pbelle_sdpLexer ctx)
{
	ANTLR3_UINT32	_type;

    _type	    = HEX_CHAR;
       
    
    // /Users/huyheo/Documents/Linphone/linphone-iphone/submodules/build/..//belle-sip/src/belle_sdp.g:321:9: ( 'a' .. 'f' | 'A' .. 'F' )
    // /Users/huyheo/Documents/Linphone/linphone-iphone/submodules/build/..//belle-sip/src/belle_sdp.g:
    {
        if ( ((LA(1) >= 'A') && (LA(1) <= 'F')) || ((LA(1) >= 'a') && (LA(1) <= 'f')) )
        {
            CONSUME();

        }
        else 
        {
            CONSTRUCTEX();
            EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
            EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;

            LRECOVER();    goto ruleHEX_CHAREx;
        }


    }

	LEXSTATE->type = _type;

    // This is where rules clean up and exit
    //
    goto ruleHEX_CHAREx; /* Prevent compiler warnings */
    ruleHEX_CHAREx: ;

}
Exemplo n.º 5
0
/** \brief Lexer rule generated by ANTLR3
 *
 * $ANTLR start DIGIT
 *
 * Looks to match the characters the constitute the token DIGIT
 * from the attached input stream.
 *
 *
 * \remark
 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
 */
static ANTLR3_INLINE
void mDIGIT(pbelle_sdpLexer ctx)
{
	ANTLR3_UINT32	_type;

    _type	    = DIGIT;
       
    
    // /Users/huyheo/Documents/Linphone/linphone-iphone/submodules/build/..//belle-sip/src/belle_sdp.g:315:6: ( ZERO | POS_DIGIT )
    // /Users/huyheo/Documents/Linphone/linphone-iphone/submodules/build/..//belle-sip/src/belle_sdp.g:
    {
        if ( ((LA(1) >= '0') && (LA(1) <= '9')) )
        {
            CONSUME();

        }
        else 
        {
            CONSTRUCTEX();
            EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
            EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;

            LRECOVER();    goto ruleDIGITEx;
        }


    }

	LEXSTATE->type = _type;

    // This is where rules clean up and exit
    //
    goto ruleDIGITEx; /* Prevent compiler warnings */
    ruleDIGITEx: ;

}
Exemplo n.º 6
0
/** \brief Lexer rule generated by ANTLR3
 *
 * $ANTLR start ANY_EXCEPT_CR_LF
 *
 * Looks to match the characters the constitute the token ANY_EXCEPT_CR_LF
 * from the attached input stream.
 *
 *
 * \remark
 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
 */
static ANTLR3_INLINE
void mANY_EXCEPT_CR_LF(pbelle_sdpLexer ctx)
{
	ANTLR3_UINT32	_type;

    _type	    = ANY_EXCEPT_CR_LF;
       
    
    // /Users/huyheo/Documents/Linphone/linphone-iphone/submodules/build/..//belle-sip/src/belle_sdp.g:335:17: (~ ( CR | LF ) )
    // /Users/huyheo/Documents/Linphone/linphone-iphone/submodules/build/..//belle-sip/src/belle_sdp.g:335:19: ~ ( CR | LF )
    {
        if ( ((LA(1) >= 0x0000) && (LA(1) <= '\t')) || ((LA(1) >= 0x000B) && (LA(1) <= '\f')) || ((LA(1) >= 0x000E) && (LA(1) <= 0xFFFF)) )
        {
            CONSUME();

        }
        else 
        {
            CONSTRUCTEX();
            EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
            EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;

            LRECOVER();    goto ruleANY_EXCEPT_CR_LFEx;
        }


    }

	LEXSTATE->type = _type;

    // This is where rules clean up and exit
    //
    goto ruleANY_EXCEPT_CR_LFEx; /* Prevent compiler warnings */
    ruleANY_EXCEPT_CR_LFEx: ;

}
Exemplo n.º 7
0
static int
parse_newick (pllStack ** stack, int * inp)
{
  pllNewickNodeInfo * item = NULL;
  int item_active = 0;
  pllLexToken token;
  int input;
  pllLexToken prev_token;
  int nop = 0;          /* number of open parentheses */
  int depth = 0;

  prev_token.tokenType = PLL_TOKEN_UNKNOWN;

  input = *inp;

  NEXT_TOKEN
  
  while (token.tokenType != PLL_TOKEN_EOF && token.tokenType != PLL_TOKEN_UNKNOWN)
  {
    switch (token.tokenType)
     {
       case PLL_TOKEN_OPAREN:
#ifdef PLLDEBUG
       printf ("PLL_TOKEN_OPAREN\n");
#endif
        ++nop;
        memcpy (&prev_token, &token, sizeof (pllLexToken));
        ++depth;
        break;

       case PLL_TOKEN_CPAREN:
#ifdef PLLDEBUG
       printf ("PLL_TOKEN_CPAREN\n");
#endif
        if (prev_token.tokenType != PLL_TOKEN_CPAREN  &&
            prev_token.tokenType != PLL_TOKEN_UNKNOWN &&
            prev_token.tokenType != PLL_TOKEN_STRING  &&
            prev_token.tokenType != PLL_TOKEN_NUMBER  &&
            prev_token.tokenType != PLL_TOKEN_FLOAT) return (0);

        if (!nop) return (0);
        --nop;
        memcpy (&prev_token, &token, sizeof (pllLexToken));

        /* push to the stack */
        if (!item) item = (pllNewickNodeInfo *) rax_calloc (1, sizeof (pllNewickNodeInfo)); // possibly not nec
        //if (item->name   == NULL) item->name   = strdup ("INTERNAL_NODE");
        if (item->name == NULL) 
         {
           item->name = (char *) rax_malloc ((strlen("INTERNAL_NODE") + 1) * sizeof (char));
           strcpy (item->name, "INTERNAL_NODE");
         }

        //if (item->branch == NULL) item->branch = strdup ("0.000000"); 
        if (item->branch == NULL) 
         {
           item->branch = (char *) rax_malloc ((strlen("0.000000") + 1) * sizeof (char));
           strcpy (item->branch, "0.000000");
         }
        item->depth = depth;
        pllStackPush (stack, item);
        item_active  = 1;       /* active = 1 */
        item = NULL;
        --depth;
        break;

       case PLL_TOKEN_STRING:
#ifdef PLLDEBUG
       printf ("PLL_TOKEN_STRING      %.*s\n", token.len, token.lexeme);
#endif
        if (prev_token.tokenType != PLL_TOKEN_OPAREN &&
            prev_token.tokenType != PLL_TOKEN_CPAREN &&
            prev_token.tokenType != PLL_TOKEN_UNKNOWN &&
            prev_token.tokenType != PLL_TOKEN_COMMA) return (0);
        if (!item) item = (pllNewickNodeInfo *) rax_calloc (1, sizeof (pllNewickNodeInfo));
        //item->name = strndup (token.lexeme, token.len);
        item->name = (char *) rax_malloc ((token.len + 1) * sizeof (char));
        strncpy (item->name, token.lexeme, token.len);
        item->name[token.len] = 0;

        item_active = 1;
        item->depth = depth;
        if (prev_token.tokenType == PLL_TOKEN_COMMA  ||
            prev_token.tokenType == PLL_TOKEN_OPAREN ||
            prev_token.tokenType == PLL_TOKEN_UNKNOWN) item->leaf = 1;
        memcpy (&prev_token, &token, sizeof (pllLexToken));
        break;

       case PLL_TOKEN_FLOAT:
       case PLL_TOKEN_NUMBER:
#ifdef PLLDEBUG
       if (token.tokenType == PLL_TOKEN_FLOAT) printf ("PLL_TOKEN_FLOAT\n"); else printf ("PLL_TOKEN_NUMBER\n");
#endif
         if  (prev_token.tokenType != PLL_TOKEN_OPAREN &&
              prev_token.tokenType != PLL_TOKEN_CPAREN &&
              prev_token.tokenType != PLL_TOKEN_COLON  &&
              prev_token.tokenType != PLL_TOKEN_UNKNOWN &&
              prev_token.tokenType != PLL_TOKEN_COMMA) return (0);
        if (!item) item = (pllNewickNodeInfo *) rax_calloc (1, sizeof (pllNewickNodeInfo));
        if (prev_token.tokenType == PLL_TOKEN_COLON)
         {
           //item->branch = strndup (token.lexeme, token.len);
           item->branch = (char *) rax_malloc ((token.len + 1) * sizeof (char));
           strncpy (item->branch, token.lexeme, token.len);
           item->branch[token.len] = 0;
         }
        else
         {
           if (prev_token.tokenType == PLL_TOKEN_COMMA  ||
               prev_token.tokenType == PLL_TOKEN_OPAREN ||
               prev_token.tokenType == PLL_TOKEN_UNKNOWN) item->leaf = 1;
           //if (prev_token.tokenType != PLL_TOKEN_UNKNOWN) ++ indent;
           //item->name = strndup (token.lexeme, token.len);
           item->name = (char *) rax_malloc ((token.len + 1) * sizeof (char));
           strncpy (item->name, token.lexeme, token.len);
           item->name[token.len] = 0;
         }
        item_active = 1;
        item->depth = depth;
        memcpy (&prev_token, &token, sizeof (pllLexToken));
        break;

       case PLL_TOKEN_COLON:
#ifdef PLLDEBUG
       printf ("PLL_TOKEN_COLON\n");
#endif
        if (prev_token.tokenType != PLL_TOKEN_CPAREN &&
            prev_token.tokenType != PLL_TOKEN_STRING &&
            prev_token.tokenType != PLL_TOKEN_FLOAT  &&
            prev_token.tokenType != PLL_TOKEN_NUMBER) return (0);
        memcpy (&prev_token, &token, sizeof (pllLexToken));
        break;

       case PLL_TOKEN_COMMA:
#ifdef PLLDEBUG
       printf ("PLL_TOKEN_COMMA\n");
#endif
        if (prev_token.tokenType != PLL_TOKEN_CPAREN &&
             prev_token.tokenType != PLL_TOKEN_STRING &&
             prev_token.tokenType != PLL_TOKEN_FLOAT && 
             prev_token.tokenType != PLL_TOKEN_NUMBER) return (0);
        memcpy (&prev_token, &token, sizeof (pllLexToken));
        
        /* push to the stack */
        if (!item) item = (pllNewickNodeInfo *) rax_calloc (1, sizeof (pllNewickNodeInfo)); // possibly not nece
        //if (item->name   == NULL) item->name   = strdup ("INTERNAL_NODE");
        if (item->name == NULL) 
         {
           item->name = (char *) rax_malloc ((strlen("INTERNAL_NODE") + 1) * sizeof (char));
           strcpy (item->name, "INTERNAL_NODE");
         }
        //if (item->branch == NULL) item->branch = strdup ("0.000000"); 
        if (item->branch == NULL) 
         {
           item->branch = (char *) rax_malloc ((strlen("0.000000") + 1) * sizeof (char));
           strcpy (item->branch, "0.000000");
         }
        item->depth = depth;
        pllStackPush (stack, item);
        item_active  = 0;
        item = NULL;
        break;

       case PLL_TOKEN_SEMICOLON:
#ifdef PLLDEBUG
        printf ("PLL_TOKEN_SEMICOLON\n");
#endif
        /* push to the stack */
        if (!item) item = (pllNewickNodeInfo *) rax_calloc (1, sizeof (pllNewickNodeInfo));
        //if (item->name   == NULL) item->name   = strdup ("ROOT_NODE");
        if (item->name == NULL) 
         {
           item->name = (char *) rax_malloc ((strlen("ROOT_NODE") + 1) * sizeof (char));
           strcpy (item->name, "ROOT_NODE");
         }
        //if (item->branch == NULL) item->branch = strdup ("0.000000"); 
        if (item->branch == NULL) 
         {
           item->branch = (char *) rax_malloc ((strlen("0.000000") + 1) * sizeof (char));
           strcpy (item->branch, "0.000000");
         }
        pllStackPush (stack, item);
        item_active  = 0;
        item = NULL;
        break;
       default:
#ifdef __DEBUGGING_MODE
         printf ("Unknown token: %d\n", token.tokenType);
#endif
       // TODO: Finish this part and add error codes
        break;
     }
    NEXT_TOKEN
    CONSUME(PLL_TOKEN_WHITESPACE | PLL_TOKEN_NEWLINE);
  }
  if (item_active)
   {
     if (!item) item = (pllNewickNodeInfo *) rax_calloc (1, sizeof (pllNewickNodeInfo));
     //if (item->name   == NULL) item->name   = strdup ("ROOT_NODE");
     if (item->name == NULL) 
      {
        item->name = (char *) rax_malloc ((strlen("ROOT_NODE") + 1) * sizeof (char));
        strcpy (item->name, "ROOT_NODE");
      }
     //if (item->branch == NULL) item->branch = strdup ("0.000000"); 
     if (item->branch == NULL) 
      {
        item->branch = (char *) rax_malloc ((strlen("0.000000") + 1) * sizeof (char));
        strcpy (item->branch, "0.000000");
      }
     pllStackPush (stack, item);
     item_active  = 0;
   }

  if (nop || token.tokenType == PLL_TOKEN_UNKNOWN) 
   {
     return (0);
   }

  return (1);
}
Exemplo n.º 8
0
static int _printf(consumer_t consumer, void *arg, const char *fmt, va_list ap)
{
    char tmpbuf[32]; /* must be at least 32 bytes for _print_base */
    const char *fmtstr = NULL;
    char modifier = 0;
    int n, total = 0;

#define CONSUME(b, c) \
    do { \
        size_t tmp = (size_t)(c); \
        if (tmp == 0) break; \
        total += (n = consumer(arg, (b), tmp)); \
        if (n < 0) goto error; \
        if (n < tmp) goto done; \
    } while (0)

#define FLUSH() \
    do { \
        if (fmtstr) { \
            CONSUME(fmtstr, fmt-fmtstr); \
            fmtstr = NULL; \
        } \
    } while (0)

    while (*fmt)
    {
        int flags = 0;
#define FLAG_ZERO_PADDING 0x01
        unsigned int field_width = 0;

        if (*fmt != '%')
        {
            if (fmtstr == NULL)
                fmtstr = fmt;
            fmt++;
            continue;
        }

        FLUSH();

        fmt++;
        if (*fmt == '%')
        {
            CONSUME(fmt, 1);
            fmt++;
            continue;
        }

        /* process flags */
        while (1)
        {
            switch (*fmt)
            {
            case '0':
                flags |= FLAG_ZERO_PADDING;
                fmt++;
                break;
            default:
                goto flags_done;
            }
        }

flags_done:
        /* process field width */
        field_width = strtoul(fmt, (char **)&fmt, 10);

        /* process modifiers */
        switch (*fmt)
        {
        case 'H':
        case 'h':
        case 'l':
            modifier = *fmt;
            fmt++;
            break;
        }

        /* process conversion */
        char *tmpstr;
        int base, outlen, sv;
        unsigned int uv;
        void *pv;
        switch(*fmt)
        {
        case 'd':
        case 'i':
            sv = va_arg(ap, int);
            if (modifier == 'h') sv = (short)(sv & 0xffff);
            else if (modifier == 'H') sv = (signed char)(sv & 0xff);
            tmpstr = _print_signed(tmpbuf + 32, &outlen, sv);
            while (field_width > outlen)
            {
                CONSUME((flags & FLAG_ZERO_PADDING) ? "0" : " ", 1);
                field_width--;
            }
            CONSUME(tmpstr, outlen);
            fmt++;
            break;
        case 'u':
        case 'o':
        case 'x':
        case 'X':
            if (*fmt == 'u') base = 10;
            else if(*fmt == 'o') base = 8;
            else base = 16;
            uv = va_arg(ap, unsigned int);
            if (modifier == 'h') uv &= 0xffff;
            else if (modifier == 'H') uv &= 0xff;
            tmpstr = _print_base(tmpbuf + 32, &outlen, uv, base, *fmt == 'X');
            while (field_width > outlen)
            {
                CONSUME((flags & FLAG_ZERO_PADDING) ? "0" : " ", 1);
                field_width--;
            }
            CONSUME(tmpstr, outlen);
            fmt++;
            break;
        case 'n':
            pv = va_arg(ap, void *);
            if (modifier == 'h') *(short int *)pv = total;
            else if (modifier == 'H') *(signed char *)pv = total;
            else *(int *)pv = total;
            fmt++;
            break;
        case 's':
            pv = va_arg(ap, void *);
            CONSUME((char *)pv, cgc_strlen((char *)pv));
            fmt++;
            break;
        }
    }
    FLUSH();

done:
    return total;
error:
    return -1;
}
Exemplo n.º 9
0
/** \brief Lexer rule generated by ANTLR3
 *
 * $ANTLR start WS
 *
 * Looks to match the characters the constitute the token WS
 * from the attached input stream.
 *
 *
 * \remark
 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
 */
static ANTLR3_INLINE
void mWS(pExprCppTreeLexer ctx)
{
	ANTLR3_UINT32	_type;

    _type	    = WS;
       
    
    // D:\\message\\ExprCppTree.g:45:4: ( ( ' ' | '\\t' )+ )
    // D:\\message\\ExprCppTree.g:45:6: ( ' ' | '\\t' )+
    {
        // D:\\message\\ExprCppTree.g:45:6: ( ' ' | '\\t' )+
        {
            int cnt5=0;

            for (;;)
            {
                int alt5=2;
        	switch ( LA(1) ) 
        	{
        	case '\t':
        	case ' ':
        		{
        			alt5=1;
        		}
        	    break;

        	}

        	switch (alt5) 
        	{
        	    case 1:
        	        // D:\\message\\ExprCppTree.g:
        	        {
        	            if ( LA(1) == '\t' || LA(1) == ' ' )
        	            {
        	                CONSUME();

        	            }
        	            else 
        	            {
        	                CONSTRUCTEX();
        	                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
        	                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;

        	                LRECOVER();    goto ruleWSEx;
        	            }


        	        }
        	        break;

        	    default:
        	    
        		if ( cnt5 >= 1 )
        		{
        		    goto loop5;
        		}
        		/* mismatchedSetEx()
        		 */
        		CONSTRUCTEX();
        		EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
        		EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;


        		goto ruleWSEx;
        	}
        	cnt5++;
            }
            loop5: ;	/* Jump to here if this rule does not match */
        }
        {
            LEXSTATE->channel = HIDDEN;
        }

    }

	LEXSTATE->type = _type;

    // This is where rules clean up and exit
    //
    goto ruleWSEx; /* Prevent compiler warnings */
    ruleWSEx: ;

}
Exemplo n.º 10
0
/** \brief Lexer rule generated by ANTLR3
 *
 * $ANTLR start ID
 *
 * Looks to match the characters the constitute the token ID
 * from the attached input stream.
 *
 *
 * \remark
 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
 */
static ANTLR3_INLINE
void mID(pExprCppTreeLexer ctx)
{
	ANTLR3_UINT32	_type;

    _type	    = ID;
       
    
    // D:\\message\\ExprCppTree.g:42:3: ( ( 'a' .. 'z' | 'A' .. 'Z' )+ )
    // D:\\message\\ExprCppTree.g:42:5: ( 'a' .. 'z' | 'A' .. 'Z' )+
    {
        // D:\\message\\ExprCppTree.g:42:5: ( 'a' .. 'z' | 'A' .. 'Z' )+
        {
            int cnt1=0;

            for (;;)
            {
                int alt1=2;
        	switch ( LA(1) ) 
        	{
        	case 'A':
        	case 'B':
        	case 'C':
        	case 'D':
        	case 'E':
        	case 'F':
        	case 'G':
        	case 'H':
        	case 'I':
        	case 'J':
        	case 'K':
        	case 'L':
        	case 'M':
        	case 'N':
        	case 'O':
        	case 'P':
        	case 'Q':
        	case 'R':
        	case 'S':
        	case 'T':
        	case 'U':
        	case 'V':
        	case 'W':
        	case 'X':
        	case 'Y':
        	case 'Z':
        	case 'a':
        	case 'b':
        	case 'c':
        	case 'd':
        	case 'e':
        	case 'f':
        	case 'g':
        	case 'h':
        	case 'i':
        	case 'j':
        	case 'k':
        	case 'l':
        	case 'm':
        	case 'n':
        	case 'o':
        	case 'p':
        	case 'q':
        	case 'r':
        	case 's':
        	case 't':
        	case 'u':
        	case 'v':
        	case 'w':
        	case 'x':
        	case 'y':
        	case 'z':
        		{
        			alt1=1;
        		}
        	    break;

        	}

        	switch (alt1) 
        	{
        	    case 1:
        	        // D:\\message\\ExprCppTree.g:
        	        {
        	            if ( ((LA(1) >= 'A') && (LA(1) <= 'Z')) || ((LA(1) >= 'a') && (LA(1) <= 'z')) )
        	            {
        	                CONSUME();

        	            }
        	            else 
        	            {
        	                CONSTRUCTEX();
        	                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
        	                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;

        	                LRECOVER();    goto ruleIDEx;
        	            }


        	        }
        	        break;

        	    default:
        	    
        		if ( cnt1 >= 1 )
        		{
        		    goto loop1;
        		}
        		/* mismatchedSetEx()
        		 */
        		CONSTRUCTEX();
        		EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
        		EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;


        		goto ruleIDEx;
        	}
        	cnt1++;
            }
            loop1: ;	/* Jump to here if this rule does not match */
        }

    }

	LEXSTATE->type = _type;

    // This is where rules clean up and exit
    //
    goto ruleIDEx; /* Prevent compiler warnings */
    ruleIDEx: ;

}
Exemplo n.º 11
0
/** \brief Lexer rule generated by ANTLR3
 *
 * $ANTLR start TEXT
 *
 * Looks to match the characters the constitute the token TEXT
 * from the attached input stream.
 *
 *
 * \remark
 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
 */
static ANTLR3_INLINE
void mTEXT(pMudLexer ctx)
{
	ANTLR3_UINT32	_type;

    _type	    = TEXT;


    // c_src/Mud.g:129:5: ( ( 'a' .. 'z' | 'A' .. 'Z' | '1' .. '0' | '!' | '@' | '#' | '$' | '%' | '^' | '&' | '*' | '(' | ')' )+ )
    // c_src/Mud.g:129:7: ( 'a' .. 'z' | 'A' .. 'Z' | '1' .. '0' | '!' | '@' | '#' | '$' | '%' | '^' | '&' | '*' | '(' | ')' )+
    {
        // c_src/Mud.g:129:7: ( 'a' .. 'z' | 'A' .. 'Z' | '1' .. '0' | '!' | '@' | '#' | '$' | '%' | '^' | '&' | '*' | '(' | ')' )+
        {
            int cnt2=0;

            for (;;)
            {
                int alt2=2;
        	switch ( LA(1) )
        	{
        	case '!':
        	case '#':
        	case '$':
        	case '%':
        	case '&':
        	case '(':
        	case ')':
        	case '*':
        	case '@':
        	case 'A':
        	case 'B':
        	case 'C':
        	case 'D':
        	case 'E':
        	case 'F':
        	case 'G':
        	case 'H':
        	case 'I':
        	case 'J':
        	case 'K':
        	case 'L':
        	case 'M':
        	case 'N':
        	case 'O':
        	case 'P':
        	case 'Q':
        	case 'R':
        	case 'S':
        	case 'T':
        	case 'U':
        	case 'V':
        	case 'W':
        	case 'X':
        	case 'Y':
        	case 'Z':
        	case '^':
        	case 'a':
        	case 'b':
        	case 'c':
        	case 'd':
        	case 'e':
        	case 'f':
        	case 'g':
        	case 'h':
        	case 'i':
        	case 'j':
        	case 'k':
        	case 'l':
        	case 'm':
        	case 'n':
        	case 'o':
        	case 'p':
        	case 'q':
        	case 'r':
        	case 's':
        	case 't':
        	case 'u':
        	case 'v':
        	case 'w':
        	case 'x':
        	case 'y':
        	case 'z':
        		{
        			alt2=1;
        		}
        	    break;

        	}

        	switch (alt2)
        	{
        	    case 1:
        	        // c_src/Mud.g:
        	        {
        	            if ( LA(1) == '!' || ((LA(1) >= '#') && (LA(1) <= '&')) || ((LA(1) >= '(') && (LA(1) <= '*')) || ((LA(1) >= '@') && (LA(1) <= 'Z')) || LA(1) == '^' || ((LA(1) >= 'a') && (LA(1) <= 'z')) )
        	            {
        	                CONSUME();
        	            }
        	            else
        	            {
        	                CONSTRUCTEX();
        	                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
        	                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;

        	                LRECOVER();
        	                goto ruleTEXTEx;
        	            }


        	        }
        	        break;

        	    default:

        		if ( cnt2 >= 1 )
        		{
        		    goto loop2;
        		}
        		/* mismatchedSetEx()
        		 */
        		CONSTRUCTEX();
        		EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
        		EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;


        		goto ruleTEXTEx;
        	}
        	cnt2++;
            }
            loop2: ;	/* Jump to here if this rule does not match */
        }

    }

	LEXSTATE->type = _type;
    // This is where rules clean up and exit
    //
    goto ruleTEXTEx; /* Prevent compiler warnings */
    ruleTEXTEx: ;

}
Exemplo n.º 12
0
/** \brief Lexer rule generated by ANTLR3
 *
 * $ANTLR start WS
 *
 * Looks to match the characters the constitute the token WS
 * from the attached input stream.
 *
 *
 * \remark
 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
 */
static ANTLR3_INLINE
void mWS(pMudLexer ctx)
{
	ANTLR3_UINT32	_type;

    _type	    = WS;


    // c_src/Mud.g:127:3: ( ( ' ' | '\\t' )+ )
    // c_src/Mud.g:127:5: ( ' ' | '\\t' )+
    {
        // c_src/Mud.g:127:5: ( ' ' | '\\t' )+
        {
            int cnt1=0;

            for (;;)
            {
                int alt1=2;
        	switch ( LA(1) )
        	{
        	case '\t':
        	case ' ':
        		{
        			alt1=1;
        		}
        	    break;

        	}

        	switch (alt1)
        	{
        	    case 1:
        	        // c_src/Mud.g:
        	        {
        	            if ( LA(1) == '\t' || LA(1) == ' ' )
        	            {
        	                CONSUME();
        	            }
        	            else
        	            {
        	                CONSTRUCTEX();
        	                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
        	                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;

        	                LRECOVER();
        	                goto ruleWSEx;
        	            }


        	        }
        	        break;

        	    default:

        		if ( cnt1 >= 1 )
        		{
        		    goto loop1;
        		}
        		/* mismatchedSetEx()
        		 */
        		CONSTRUCTEX();
        		EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
        		EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;


        		goto ruleWSEx;
        	}
        	cnt1++;
            }
            loop1: ;	/* Jump to here if this rule does not match */
        }

    }

	LEXSTATE->type = _type;
    // This is where rules clean up and exit
    //
    goto ruleWSEx; /* Prevent compiler warnings */
    ruleWSEx: ;

}
Exemplo n.º 13
0
/** @ingroup alignmentGroup
    @brief Parse the PHYLIP file body
*/
static int
parse_phylip (pllAlignmentData * alignmentData, int input)
{
    int i,j;
    pllLexToken token;
    int * sequenceLength;
    int rc;

    sequenceLength = (int *) rax_calloc (alignmentData->sequenceCount + 1, sizeof (int));

    NEXT_TOKEN
    for (i = 0; ; ++i)
    {
        j = i % alignmentData->sequenceCount;
        if (i < alignmentData->sequenceCount)
        {
            if (token.tokenType == PLL_TOKEN_EOF)
            {
                rc = parsedOk (sequenceLength, alignmentData->sequenceCount, alignmentData->sequenceLength);
                rax_free (sequenceLength);
                return (rc);
            }

            if (token.tokenType == PLL_TOKEN_UNKNOWN)
            {
                rax_free (sequenceLength);
                return (0);
            }

            CONSUME(PLL_TOKEN_WHITESPACE | PLL_TOKEN_NEWLINE)


            if (token.tokenType != PLL_TOKEN_STRING && token.tokenType != PLL_TOKEN_NUMBER && token.tokenType != PLL_TOKEN_FLOAT)
            {
                rax_free (sequenceLength);
                return (0);
            }
            alignmentData->sequenceLabels[i + 1] = strndup (token.lexeme, token.len);
            NEXT_TOKEN
            CONSUME(PLL_TOKEN_WHITESPACE | PLL_TOKEN_NEWLINE)
        }

        while (1)
        {
            if (token.tokenType == PLL_TOKEN_EOF)
            {
                rc = parsedOk (sequenceLength, alignmentData->sequenceCount, alignmentData->sequenceLength);
                rax_free (sequenceLength);
                return (rc);
            }

            if (token.tokenType == PLL_TOKEN_UNKNOWN)
            {
                rax_free (sequenceLength);
                return (0);
            }

            if (token.tokenType == PLL_TOKEN_NEWLINE) break;

            if (token.tokenType != PLL_TOKEN_STRING)
            {
                rax_free (sequenceLength);
                return (0);
            }

            if (sequenceLength[j + 1] + token.len > alignmentData->sequenceLength)
            {
                fprintf (stderr, "Sequence %d is larger than specified\n", j + 1);
                rax_free (sequenceLength);
                return (0);
            }
            memmove (alignmentData->sequenceData[j + 1] + sequenceLength[j + 1], token.lexeme, token.len);
            sequenceLength[j + 1] += token.len;

            NEXT_TOKEN
            CONSUME (PLL_TOKEN_WHITESPACE)
        }
        CONSUME(PLL_TOKEN_WHITESPACE | PLL_TOKEN_NEWLINE);
    }
}