Parsing D Maybe Not Such a Good Idea <_<;
cy via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 14 22:51:53 PDT 2016
On Wednesday, 15 June 2016 at 04:59:59 UTC, Basile B. wrote:
> After lexing you can remove all the tokComment and everything
> becomes simple.
Well, let's see. Using this libdparser thing, now I have a
function declaration, with a name, parameters and a return type,
good so far. Now I want to modify the name, and output it along
with the parameters and the return type. So, let's just serialize
the return type then.
Oh, a Type has a list of type... constructors that are used
somehow. And a list of type suffixes. Let's see, each type suffix
can have a delegate, a star, and another Type recursively, plus
expressions for low and high, and a list of member function
attributes. Each member function attribute has an identifier (I
think? IdType is secretly imported from somewhere) and an
attribute.
Okay, so attributes have an argument list, as well as maybe a
template instance, and an identifier token. An argument list has
a list of items, each one an expression.
So there are 17 different types derived from Expression that
start with the letter A alone. Understandable, considering that D
allows arbitrary expressions in a type definition, and arbitrary
means a-n-y-t-h-i-n-g. So assuming I can magically represent an
expression, let's go back to finish up serializing the Type
object.
Oh... there's a Type2 object inside the Type object. It has
another one of those mysterious IdTypes, a symbol (for
something?), a typeof expression, an identifier, or something
called a template chain, a type constructor, and... a recursive
Type object inside it.
I think we have different definitions of the word "simple." D
syntax is hella complex.
(Either that or different definitions of the word "everything.")
More information about the Digitalmars-d
mailing list