New Macro Syntax Proposal
Davidl
Davidl at 126.com
Wed Apr 25 20:38:57 PDT 2007
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