New rules implemented. The build works unmodified. Tests still running but most work.
Examples: you will need to look closely. ////////////////////////////////////////////////////// // test new pattern rules proc showx (x:opt[int]) { match x with | Some a => println$ a; | None => println$ "None"; endmatch; } proc showx2 (x:opt[int]) { match x with | Some ?a => println$ a; | #None => println$ "None"; endmatch; } showx (Some 1); showx (None[int]); showx2 (Some 2); showx2 (None[int]); proc showy (x:opt[opt[int]]) { match x with | Some (Some a) => println$ "Some (Some "+str a+"))"; | Some #None => println$ "Some None"; | None => println$ "None"; endmatch; } showy (Some (Some 22)); showy (Some None[int]); showy (None[opt[int]]); ////////////////////////////// This is implemented and supposed to work but doesn't parse: ////////////////////// open class My { union MyOpt[T] = | MyNone | MySome of T; } proc showz (x:MyOpt[MyOpt[int]]) { match x with | MySome (MySome a) => println$ "MySome (MySome "+str a+"))"; | MySome My::MyNone => println$ "MySome MyNone"; | MyNone => println$ "MyNone"; endmatch; } showz (MySome (MySome 22)); showz (MySome MyNone[int]); showz (MyNone[MyOpt[int]]); ////////////////////// this line gives an error: ~/felix>build/release/bin/flx --test=build/release tp /Users/johnskaller/felix/tp.flx: line 49, cols 14 to 13 48: | MySome (MySome a) => println$ "MySome (MySome "+str a+"))"; 49: | MySome My::MyNone => println$ "MySome MyNone"; * 50: | MyNone => println$ "MyNone"; Fatal error: exception Dyp.Syntax_errorThe idea here is simply that MyOpt::MyNone, being a really qualified name with :: in it, cannot be a pattern match variable, which has to be a simple identifier. The distinction is made in these grammar rules: sargument_pattern := sname =># "`(pat_as ,_sr (pat_any ,_sr) ,_1)"; sargument_pattern := sreally_qualified_name =># "`(pat_const_ctor ,_sr ,_1)"; and the first case works. So I'm not clear why the second case doesn't also. The expression grammar reads: //$ Qualified name. sreally_qualified_name := squalified_name "::" ssimple_name_parts =># "`(ast_lookup (,_1 ,(first _3) ,(second _3)))"; squalified_name := sreally_qualified_name =># '_1'; squalified_name := ssimple_name_parts =># "`(ast_name ,_sr ,(first _1) ,(second _1))"; ssimple_name_parts := sname =># "`(,_1 ())"; ssimple_name_parts := sname "[" sexpr "]" =># "`(,_1 ,(mkl _3))"; and I think this has to be right (or all hell would break loose). -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language