New Macro Syntax Proposal

Dan murpsoft at hotmail.com
Wed Apr 25 22:55:01 PDT 2007


Unfortunate then that AA's aren't yet supported at compile time because they use pointers to hash the values from the strings, and pointers aren't established until runtime.

The syntax is also a bit rusty, but that's to be expected for a first proposal.  My AST Reflection example was probably even weaker.

~~

Davidl Wrote:
> and my idea is eventually get the compiler's associate array out not  
> built-in by using a
> macro Language INI file instead. In the ini file, the macro is the  
> language feature.
> 
> > Obviously the one I posted yesterday is not easy for IDE to highlight  
> > sub-language set
> > and also it lacks the power of parse different sub-language expressions.  
> > I think the
> > goal of macro should be powerful enough to introduce a new sub language.  
> > Then the macro
> > itself could be called mature.
> > Consider the following
> >
> > macro MyPowerfulMacro = CODEGEN //indicate the backend gen code output  
> > string
> > {
> > KeyWordList(CASE_INSENSITIVE)	// this is for IDE highlight
> > //the design here doesn't pollute keyword we have now, KeyWordList,  
> > Expression Backend all only take effect in macro expression
> > {
> >     object, TOKEN.object,
> >     end,    TOKEN.end,
> > }
> > Expression
> > {
> >     expdeclare ::= EXP.expdeclare(objid, objattr[])
> > 	TOKEN.object {( TOKEN.identifier:objid TOKEN.identifier:~objattr  
> > TOKEN.colon TOKEN.object)
> > 		| (EXP.expdeclare:objexp)  } TOKEN.end
> > }
> >
> > Backend EXP.expdeclare(objid, objattr[])
> > {
> > 	CODEGEN ~= class "~objid.strinof)~"{;
> > 	foreach(k;objattr)
> > 	{
> > 		CODEGEN ~= "class "~k.stringof~"{}"
> > 	}
> > 	CODEGEN ~= "}"
> > }
> >
> > }
> 




More information about the Digitalmars-d mailing list