by fexl · 16y ago · 0 comments
# Parse a nested parenthesized expression.
\parse_nested =
(
\yes
\no
skip_char ch_lparen
(
parse_expr
(\expr skip_char ch_rparen (yes expr) no)
no
)
no
)
And it's simple to do either-or parsing like this: # Parse a factor: either an id or a nested expression.
\parse_factor =
(
\yes
\no
parse_id (\id yes (var id));
parse_nested yes;
no
)
Even such mundane tasks as skipping white space and comments have a
satisfying elegance about them: # Skip filler, including white space and comments.
\skip_filler =
(
\done
skip_space;
skip_comment
(skip_filler done)
done
) #include "node.h"
#include "type_S.h"
/*
Fusion function (Verschmelzungfunktion)
S x y z = ((x z) (y z))
*/
static void step(void)
{
int f1 = pop();
int f2 = pop();
int f3 = pop();
if (!f3) return;
set_pair(f3, P(R(f1),R(f3)), P(R(f2),R(f3)));
}
int type_S(void)
{
static int node = 0;
if (node == 0) node = new_combinator(step);
return node;
}All this stuff is really neat. Your C code interface looks quite nice and clean. I hope you release some source code soon.
And thanks for taking the time to write all this. Even though a lot of it is over my head, it's quite interesting. I'm really looking forward to playing around with it a bit and learning.
When Fexl runs, the first thing it does is read a Fexl function from standard input. The Fexl process then "becomes" that function, processing the tail of the input accordingly. Simple!
I started a proper blog here: http://fexl.com/blog , but we can still use ycombinator.com for discussion.
You can reach everything from http://fexl.com, including the Blog and Discussion group.