* Felix 1.0.20 released
@ 2004-12-12 1:31 skaller
0 siblings, 0 replies; only message in thread
From: skaller @ 2004-12-12 1:31 UTC (permalink / raw)
To: felix-language; +Cc: caml-list
Felix version 1.0.20 is now stablised and 1.0.21 has been
opened as the development version. Felix is an Algol like
language with a strong functional subsystem and ML like typing.
Available with BSD like FFAU licence from
http://felix.sf.net
This version integrates Scott McPeaks Elkhound GLR parser
http://www.cs.berkeley.edu/~smcpeak/elkhound/
directly in the language.
A complete (but trivial) working example is given below
to indicate the what the integration looks like.
----------------------------------------------
include "std";
// the input string
data := "1+2+3$";
// a type for tokens
union token_t =
| TOK_EOF
| TOK_PLUS
| TOK_INT of int
;
// a token stream generator
var i = 0;
fun get_token():token_t =
{
ch := data.[i to i+1];
++i;
tok :=
match ch with
| "$" => TOK_EOF
| "+" => TOK_PLUS
| "1" => TOK_INT 1
| "2" => TOK_INT 2
| "3" => TOK_INT 3
endmatch
;
return tok;
}
// a type for expression terms
union expr_t =
| Integer of int
;
// a grammar for expressions
nonterm expr : expr_t =
| xx:expr TOK_PLUS y:TOK_INT =>
match xx with
| Integer ?i => Integer (i+y)
endmatch
| y:TOK_INT => Integer y
;
// a parser for our example
var z : 1 + int =
parse (the get_token) with
| e: expr => match e with | Integer ?i => i endmatch
endmatch
;
// print the result
match z with
| case 1 => { print "Error"; }
| case 2 (?i) => { print i; }
endmatch;
endl;
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-12-12 1:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-12 1:31 Felix 1.0.20 released skaller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox