Parser for assembly style constant

Claudio La Rosa <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
Hi,

I tried to write a simple parser for a assembly line constant definition

Label: (dc.t | dc.s | dc.w) constantsList

The constant are:
numeric (decimal) constant
ternary constant (es: 0Tconstant or 0TConstant)
balanced ternary constant (es.: 0BTConstant)
character

My parser is:

		constChar = qi::char_('\'') >> *qi::char_("a-zA-Z") >> qi::char_('\'');
		
		constTernary = (qi::char_('0') >> (qi::char_('t') | qi::char_('T')) >> +qi::char_("0-2"));

		constBalancedTernary = (qi::char_('0') 
					>> (qi::char_('b') | qi::char_('B'))
					>> (qi::char_('t') | qi::char_('T')) 
					>> +qi::char_("0-2"));


		constDecimal = +char_("0-9");

		rConstValues = (constDecimal | constChar | constTernary | constBalancedTernary )[phoenix::push_back(phoenix::ref(constValuesList), _1)] % ','; //Constants list



firstStepRules = labelName[phoenix::bind(&asmGrammar::do_varName, this, _1)]
			>> rSpazi1
			>> (qi::as_string[(no_case["dc.t"])] | qi::as_string[(no_case["dc.s"])] | qi::as_string[(no_case["dc.w"])])[phoenix::bind(&asmGrammar::do_varType, this, _1)]
			>> rSpazi1
			>> rConstValues [phoenix::bind(&asmGrammar::do_firstStep, this)];


If I parse this line:

std::string s("label: dc.W 0bt222,123,12,'A',22,0t212");

If I list the constValuesList (vector of string), I obtain only one 0!!

what is wrong?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.