コード例 #1
0
ファイル: error_.cpp プロジェクト: signatal/codeography
/**
 * Error constructor.
 */
Error_::Error_()
: ParsableElement_(Types::ERROR, false)
, id()
, row(0)
, column(0)
{
    if (Error_::error_parse_rules1.empty())
    {
        Error_::error_parse_rules1.push_back("(");
        Error_::error_parse_rules1.push_back("error"); 
        Error_::error_parse_rules1.push_back(ParseRule(strine::Types::STRING));
        Error_::error_parse_rules1.push_back(")");
    }

    if (Error_::error_parse_rules2.empty())
    {
        Error_::error_parse_rules2.push_back("(");
        Error_::error_parse_rules2.push_back("error"); 
        Error_::error_parse_rules2.push_back(ParseRule(strine::Types::STRING));
        Error_::error_parse_rules2.push_back(ParseRule(strine::Types::NUMBER));
        Error_::error_parse_rules2.push_back(ParseRule(strine::Types::NUMBER));
        Error_::error_parse_rules2.push_back(")");
    }

}
コード例 #2
0
ファイル: set_.cpp プロジェクト: signatal/strine
/**
 * Set constructor.
 */
Set_::Set_()
    : ParsableElement_(Types::SET, false)
    , global(false)
    , id()
    , element()
{
    if (Set_::parse_rules.empty())
    {
        Set_::parse_rules.push_back("(");
        Set_::parse_rules.push_back("set");
        Set_::parse_rules.push_back(ParseRule(strine::Types::VARIABLE));
        Set_::parse_rules.push_back("->");
        Set_::parse_rules.push_back(ParseRule(ParseRule::ANY));
        Set_::parse_rules.push_back(")");
    }
}
コード例 #3
0
void MChannelRuleMgr::ParseRoot(const char* szTagName, MXmlElement* pElement)
{
	if (!_stricmp(szTagName, MTOK_CHANNELRULE)) 
	{
		ParseRule(pElement);
	}
}
コード例 #4
0
ファイル: if_.cpp プロジェクト: signatal/codeography
/**
 * If constructor.
 */
If_::If_()
: ParsableElement_(Types::IF, false)
, condition()
, true_result()
, false_result()
{
    if (If_::parse_rules.empty())
    {
        If_::parse_rules.push_back("(");
        If_::parse_rules.push_back("if"); 
        If_::parse_rules.push_back(ParseRule(ParseRule::ANY));
        If_::parse_rules.push_back(ParseRule(ParseRule::ANY));
        If_::parse_rules.push_back(ParseRule(ParseRule::ANY));
        If_::parse_rules.push_back(")");
    }
}
コード例 #5
0
ファイル: CSS.cpp プロジェクト: sigurdle/FirstProject2
void CSSStream::ParseRules()
{
	SkipSpacesComments();
	while (!eof())
	{
		ParseRule();
		SkipSpacesComments();
	}
}
コード例 #6
0
ファイル: quoted_.cpp プロジェクト: signatal/codeography
/**
 * Quoted constructor.
 */
Quoted_::Quoted_()
: ParsableElement_(Types::QUOTED, false)
, element()
{
    if (Quoted_::parse_rules.empty())
    {
        Quoted_::parse_rules.push_back("'");
        Quoted_::parse_rules.push_back(ParseRule(ParseRule::ANY));
    }
}
コード例 #7
0
ファイル: builtin_.cpp プロジェクト: signatal/codeography
void Builtin_::FillBuiltinParseRules()
{
    if (Builtin_::parse_rules.empty())
    {
        Builtin_::parse_rules.push_back("(");
        Builtin_::parse_rules.push_back("builtin");
        Builtin_::parse_rules.push_back(ParseRule(Types::STRING));
        Builtin_::parse_rules.push_back(")");
    }
}
コード例 #8
0
ファイル: evaluate_.cpp プロジェクト: signatal/codeography
/**
 * Evaluate constructor.
 */
Evaluate_::Evaluate_(Strine const& s)
: ParsableElement_(Types::EVALUATE, false)
, element()
, strine(s)
{
    if (Evaluate_::parse_rules.empty())
    {
        Evaluate_::parse_rules.push_back("(");
        Evaluate_::parse_rules.push_back("evaluate"); 
        Evaluate_::parse_rules.push_back(ParseRule(ParseRule::ANY));
        Evaluate_::parse_rules.push_back(")");
    }
}
コード例 #9
0
void RBSParseXML::ParseRules(xml::XMLElement*elem,RuleBasedSystem*rbs)
{
	core::stringc elemName;

	xml::xmlSubElementsMapIT eit=elem->getElementsBegin();
	xml::xmlSubElementsMapIT eEnd=elem->getElementsEnd();
	for(;eit!=eEnd;++eit)
	{
		if((*eit)->GetType()!=xml::ENT_Element)continue;
		xml::XMLElement* e=dynamic_cast<xml::XMLElement*>(*eit);
		core::string_to_char(e->getName(),elemName);
		elemName.make_lower();

		if(elemName=="rule"){
			ParseRule(e,rbs);
		}
	}
}
コード例 #10
0
int main (int argc, char const * argv [])

{
	extern struct channel channel;
	static char const * optv [] =
	{
		"ei:qrst:T:vV:",
		"action operand condition [...] control volatility [device] [...]\n\n          where a condition is: field operator value",
		"Qualcomm Atheros Stream MakeRules Utility",
		"e\tredirect stderr to stdout",

#if defined (WINPCAP) || defined (LIBPCAP)

		"i n\thost interface is (n) [" LITERAL (CHANNEL_ETHNUMBER) "]",

#else

		"i s\thost interface is (s) [" LITERAL (CHANNEL_ETHDEVICE) "]",

#endif

		"q\tquiet mode",
		"r\tread rules from device",
		"s\tdisplay symbol tables",
		"t n\tread timeout is (n) milliseconds [" LITERAL (CHANNEL_TIMEOUT) "]",
		"T x\tinserted vlan tag is x [" LITERAL (PLCRULE_VLAN_TAG) "]",
		"v\tverbose mode",
		"V n\tcspec version is n [" LITERAL (PLCRULE_CSPEC_VERSION) "]",
		(char const *) (0)
	};

#include "../plc/plc.c"

	struct cspec cspec;
	struct MMERule rule;
	signed c;
	memset (& rule, 0, sizeof (rule));
	memset (& cspec, 0, sizeof (cspec));
	cspec.VLAN_TAG = PLCRULE_VLAN_TAG;
	cspec.CSPEC_VERSION = PLCRULE_CSPEC_VERSION;
	if (getenv (PLCDEVICE))
	{

#if defined (WINPCAP) || defined (LIBPCAP)

		channel.ifindex = atoi (getenv (PLCDEVICE));

#else

		channel.ifname = strdup (getenv (PLCDEVICE));

#endif

	}
	optind = 1;
	while (~ (c = getoptv (argc, argv, optv)))
	{
		switch (c)
		{
		case 'e':
			dup2 (STDOUT_FILENO, STDERR_FILENO);
			break;
		case 'i':

#if defined (WINPCAP) || defined (LIBPCAP)

			channel.ifindex = atoi (optarg);

#else

			channel.ifname = optarg;

#endif

			break;
		case 'q':
			_setbits (channel.flags, CHANNEL_SILENCE);
			_setbits (plc.flags, PLC_SILENCE);
			break;
		case 'r':
			_setbits (plc.flags, PLC_ANALYSE);
			break;
		case 's':
			printf ("\n");
			printf (" Controls are ");
			codelist (controls, SIZEOF (controls), COMMA, QUOTE, stdout);
			printf (".\n");
			printf (" Volatilities are ");
			codelist (volatilities, SIZEOF (volatilities), COMMA, QUOTE, stdout);
			printf (".\n");
			printf (" Actions are ");
			codelist (actions, SIZEOF (actions), COMMA, QUOTE, stdout);
			printf (".\n");
			printf (" Operands are ");
			codelist (operands, SIZEOF (operands), COMMA, QUOTE, stdout);
			printf (".\n");
			printf (" Fields are ");
			codelist (fields, SIZEOF (fields), COMMA, QUOTE, stdout);
			printf (".\n");
			printf (" Operators are ");
			codelist (operators, SIZEOF (operators), COMMA, QUOTE, stdout);
			printf (".\n");
			printf (" States are ");
			codelist (states, SIZEOF (states), COMMA, QUOTE, stdout);
			printf (".\n");
			printf ("\n");
			return (0);
		case 't':
			channel.timeout = (signed) (uintspec (optarg, 0, UINT_MAX));
			break;
		case 'T':
			cspec.VLAN_TAG = (uint32_t) (basespec (optarg, 16, sizeof (cspec.VLAN_TAG)));
			cspec.VLAN_TAG = htonl (cspec.VLAN_TAG);
			break;
		case 'v':
			_setbits (channel.flags, CHANNEL_VERBOSE);
			_setbits (plc.flags, PLC_VERBOSE);
			break;
		case 'V':
			cspec.CSPEC_VERSION = (uint16_t) (basespec (optarg, 10, sizeof (cspec.CSPEC_VERSION)));
			cspec.CSPEC_VERSION = HTOLE16 (cspec.CSPEC_VERSION);
			break;
		default: 
			break;
		}
	}
	argc -= optind;
	argv += optind;
	if (_allclr (plc.flags, PLC_ANALYSE))
	{
		if (ParseRule (& argc, & argv, & rule, & cspec) == -1)
		{
			error (1, 0, "invalid rule");
		}
	}
	openchannel (& channel);
	if (! (plc.message = malloc (sizeof (* plc.message))))
	{
		error (1, errno, PLC_NOMEMORY);
	}
	if (! argc)
	{
		if (_anyset (plc.flags, PLC_ANALYSE))
		{
			ReadRules (& plc);
		}
		else 
		{
			MakeRule (& plc, & rule);
		}
	}
	while ((argc) && (* argv))
	{
		if (! hexencode (channel.peer, sizeof (channel.peer), synonym (* argv, devices, SIZEOF (devices))))
		{
			error (1, errno, PLC_BAD_MAC, * argv);
		}
		if (_anyset (plc.flags, PLC_ANALYSE))
		{
			ReadRules (& plc);
		}
		else 
		{
			MakeRule (& plc, & rule);
		}
		argc--;
		argv++;
	}
	free (plc.message);
	closechannel (& channel);
	exit (0);
}
コード例 #11
0
ファイル: CSS.cpp プロジェクト: sigurdle/FirstProject2
void StyleSheet::Parse(Stream& stream)
{
	try
	{
		CSSStream stream(stream);
		stream.getnextc();

		stream.SkipSpaces();

		while (!stream.eof())
		{
			CSSRule* rule;
			ParseRule(stream, this, NULL, this, &rule);
			if (rule)
			{
				m_cssRules->m_rules.Add(rule);

				// Call handlers After it is inserted
				for (int i = 0; i < m_handlers.size(); i++)
				{
					ASSERT(0);
					//m_handlers[i]->handleCSSEvent(LCSSObject_Rule, LCSSEvent_Insert, this, rule);
				}

			//	rule.Detach();
			}

			stream.SkipSpaces();
		}
	}
	CATCH (Exception* e)
	{
		//TRACE("ERROR Parsing Stylesheet: %S\n", p);
		TRACE("ERROR Parsing Stylesheet\n");
		//MessageBox(NULL, _bstr_t(p), "CSS", MB_OK);

		// TODO, the errorhandler should already have been called
#if 0
		WCHAR msg[512];
		swprintf(msg, L"CSS: %s", p);

		if (m_ownerNode)
		{
			CComPtr<ILDOMDocument> ownerDocument;
			m_ownerNode->get_ownerDocument(&ownerDocument);
			if (ownerDocument)
			{
				long offset;
				m_ownerNode->getTextOffset(5, &offset);

				offset += stream->m_ipos;

				CComPtr<ILDOMError> error;
				CreateDOMError(LSEVERITY_ERROR, offset, msg, &error);

				ILDOMErrorHandler* errorHandler;
				ownerDocument->get_errorHandler(&errorHandler);

				if (errorHandler)
				{
					bool bContinue;
					errorHandler->handleError(error, &bContinue);
					if (!bContinue)
					{
					}
				}
			}
		}
#endif
	}
コード例 #12
0
int main(void)
{
  char rule[20];
  char bin[20];
  int error = 1; //set to 0 if an unrecoverable error occurs
  
  global.state=0;
  global.table_entry = 0;
  global.rule.v_end=0x0;
    
  printf("Name of rule file: ");  
  scanf("%s", rule);
    
  if(NULL==(global.rulefile=fopen(rule,"r")))
  {
    printf("Error 1: Couldn't open Rule file\n");
    return -1;
  }
  
  printf("Name of output file for Level 1 table: ");
  scanf("%s", bin);

  if(NULL==(global.outfile=fopen(bin,"wb")))
  {
    fclose(global.outfile);
    printf("Error 2: Couldn't open Output file\n");
    return -1;
  }
  
  printf("Name of page table entry output file: ");
  scanf("%s", bin);

  if(NULL==(global.entry_outfile=fopen(bin,"wb")))
  {
    fclose(global.entry_outfile);
    printf("Error 2: Couldn't open Output file\n");
    return -1;
  }
  
  printf("Do you have a Level 2 table? (y/n) ");
  scanf("%s", bin);
  
  /* Level 2 table was defined */
  if(bin[0] == 'y')
  {
    printf("Name of output file for Level 2 table: ");
    scanf("%s", bin);

    if(NULL==(global.l2_outfile=fopen(bin,"wb")))
    {
      fclose(global.l2_outfile);
      printf("Error 2: Couldn't open Output file\n");
      return -1;
    }
    
    printf("Base address of Level 2 table: ");
    scanf("%s", bin);
    global.base_address_l2 = atox(bin);
  }
  /* Level 2 table was not defined */
  else
  {
    /* setting Level 2 table base to invalid value to check whether Level 2 was specified when it should not have been */
    global.base_address_l2 = 0xFFFFFFFF;
  }
  
  while( ParseRule(&error) )
  {
    if(WriteTableEntries(&error)==-1)
    {
      fclose( global.outfile );
      fclose( global.rulefile );
      fclose( global.entry_outfile );
      fclose( global.l2_outfile );
      exit(-1);
    }
    
    //check for terminal error
    if(!error)
    {
      fclose( global.outfile );
      fclose( global.rulefile );
      fclose( global.entry_outfile );
      fclose( global.l2_outfile );
      printf("Error 3: MMU table could not be generated\n");
      return 0 ;
    }
    
    global.rule.def = 0; //clear default flag
  }

  printf("MMU table generation complete\n");
        
  fclose( global.outfile );
  fclose( global.rulefile );
  fclose( global.entry_outfile );
  fclose( global.l2_outfile );
  return 0 ;
}