You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/10/05 01:40:30 UTC

[lucy-commits] svn commit: r1179011 - in /incubator/lucy/branches/clownfish_lemon/clownfish: src/CFCLexHeader.l src/CFCParseHeader.y t/103-float_type.t

Author: marvin
Date: Tue Oct  4 23:40:30 2011
New Revision: 1179011

URL: http://svn.apache.org/viewvc?rev=1179011&view=rev
Log:
Add support for 32-bit and 64-bit floating point types.

Modified:
    incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCLexHeader.l
    incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParseHeader.y
    incubator/lucy/branches/clownfish_lemon/clownfish/t/103-float_type.t

Modified: incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCLexHeader.l
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCLexHeader.l?rev=1179011&r1=1179010&r2=1179011&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCLexHeader.l (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCLexHeader.l Tue Oct  4 23:40:30 2011
@@ -29,7 +29,8 @@ CFCParseHeader(void *header_parser, int 
 
 %%
 void       { PARSE(CFC_TOKENTYPE_VOID, NULL); }
-
 const      { PARSE(CFC_TOKENTYPE_CONST, NULL); }
+float      { PARSE(CFC_TOKENTYPE_FLOAT, NULL); }
+double     { PARSE(CFC_TOKENTYPE_DOUBLE, NULL); }
 %%
 

Modified: incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParseHeader.y
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParseHeader.y?rev=1179011&r1=1179010&r2=1179011&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParseHeader.y (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParseHeader.y Tue Oct  4 23:40:30 2011
@@ -31,17 +31,23 @@
   #define true 1
   #define false 0
 #endif
+
+static const char KW_FLOAT[]    = "float";
+static const char KW_DOUBLE[]   = "double";
 }
 
 %syntax_error {
     state->errors = true;
 }
 
-result ::= void_type(A).
+result ::= simple_type(A).
 {
     state->result = A;
 }
 
+simple_type(A) ::= void_type(B).    { A = B; }
+simple_type(A) ::= float_type(B).   { A = B; }
+
 void_type(A) ::= CONST void_type_specifier.
 {
     A = (CFCBase*)CFCType_new_void(true);
@@ -52,6 +58,15 @@ void_type(A) ::= void_type_specifier.
     A = (CFCBase*)CFCType_new_void(false);
 }
 
+%type float_type_specifier          {const char*}
+%destructor float_type_specifier        { }
+
 void_type_specifier ::= VOID.
+float_type_specifier(A) ::= FLOAT.   { A = KW_FLOAT; }
+float_type_specifier(A) ::= DOUBLE.  { A = KW_DOUBLE; }
 
+float_type(A) ::= float_type_specifier(B).
+{
+    A = (CFCBase*)CFCType_new_float(0, B);
+}
 

Modified: incubator/lucy/branches/clownfish_lemon/clownfish/t/103-float_type.t
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/t/103-float_type.t?rev=1179011&r1=1179010&r2=1179011&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/t/103-float_type.t (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/t/103-float_type.t Tue Oct  4 23:40:30 2011
@@ -33,7 +33,7 @@ my $parser = Clownfish::Parser->new;
 for my $specifier (qw( float double)) {
     is( $parser->c_float_specifier($specifier),
         $specifier, "c_float_specifier: $specifier" );
-    my $type = $parser->float_type($specifier);
+    my $type = $parser->parse($specifier);
     isa_ok( $type, "Clownfish::Type" );
     ok( $type && $type->is_floating, "parsed specifier is_floating()" );
     $type = $parser->float_type("const $specifier");
@@ -41,7 +41,11 @@ for my $specifier (qw( float double)) {
     ok( $type && $type->is_floating, "parsed const specifier is_floating()" );
     ok( $type && $type->const,       "parsed const specifier is_floating()" );
     my $bogus = $specifier . "y";
-    ok( !$parser->c_float_specifier($bogus),
-        "c_float_specifier guards against partial word matches" );
+
+    TODO: {
+        local $TODO = "No word boundary support in lex";
+        ok( !$parser->parse($bogus),
+            "c_float_specifier guards against partial word matches" );
+    }
 }