data Program = Prog [Declaration]
data Declaration = Decl Variable Expression
data Variable = Var String
data Expression = Apply Expression Expression | Abstract Variable
Expression | Variable

Taking the above program abstract syntax, it seems obvious to me that
parsers should output these elements.

For example if we have the following syntax for an abstraction:

'\', {space}, var, {space}, '.', {space}, expression

This clearly relates to the "Abstract Variable Expression" value
constructor.

This might be in combinators:

auto const lam_tok = tokenize(accept(is_char('\\')));
auto const var_tok = tokenize(accept(is_alpha) && many(accept(is_alnum)));
auto const dot_tok = tokenize(accept(is_char('.')));

auto const abs = all(return_abs, discard(lam_tok) && var_tok,
discard(dot_tok) && expr);

So to integrate this with the abstract syntax, we need to assert that:

typename abs::value_type

Is "Abstract Variable Expression" from the AST.

So I would consider the AST itself determines the grammar, and we can
attach a parser to each internal and leaf node of the tree.

Is this good enough?

Keean.
_______________________________________________
bitc-dev mailing list
bitc-dev@coyotos.org
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to