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/16 03:31:03 UTC
[lucy-commits] svn commit: r1183779 - in
/incubator/lucy/branches/clownfish_lemon/clownfish: src/CFCLexHeader.l
src/CFCParseHeader.y src/CFCVariable.c t/301-param_list.t t/600-parser.t
Author: marvin
Date: Sun Oct 16 01:31:02 2011
New Revision: 1183779
URL: http://svn.apache.org/viewvc?rev=1183779&view=rev
Log:
Add support for identifiers, param variables to Lemon-based parser.
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/src/CFCVariable.c
incubator/lucy/branches/clownfish_lemon/clownfish/t/301-param_list.t
incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.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=1183779&r1=1183778&r2=1183779&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCLexHeader.l (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCLexHeader.l Sun Oct 16 01:31:02 2011
@@ -80,6 +80,11 @@ va_list { PARSE(CFC_TOKENTYPE_VA_LIST
S_save_yytext();
PARSE(CFC_TOKENTYPE_INTEGER_LITERAL, NULL);
}
+[a-zA-Z_][a-zA-Z0-9_]* {
+ S_save_yytext();
+ PARSE(CFC_TOKENTYPE_IDENTIFIER, NULL);
+ }
+
[ \t\r\n] /* Skip whitespace. */
. {
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=1183779&r1=1183778&r2=1183779&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParseHeader.y (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParseHeader.y Sun Oct 16 01:31:02 2011
@@ -71,6 +71,7 @@ result ::= type(A).
type(A) ::= simple_type(B). { A = B; }
type(A) ::= composite_type(B). { A = B; }
+type(A) ::= param_variable(B). { A = B; } /* temporary */
composite_type(A) ::= simple_type(B) asterisk_postfix(C).
{
@@ -109,6 +110,7 @@ void_type(A) ::= void_type_specifier.
%type asterisk_postfix {char*}
%type array_postfix {char*}
%type array_postfix_elem {char*}
+%type declarator {char*}
%destructor float_type_specifier { }
%destructor integer_type_specifier { }
%destructor object_type_specifier { FREEMEM($$); }
@@ -117,6 +119,7 @@ void_type(A) ::= void_type_specifier.
%destructor asterisk_postfix { FREEMEM($$); }
%destructor array_postfix { FREEMEM($$); }
%destructor array_postfix_elem { FREEMEM($$); }
+%destructor declarator { FREEMEM($$); }
void_type_specifier ::= VOID.
va_list_specifier ::= VA_LIST.
@@ -228,3 +231,13 @@ integer_literal(A) ::= INTEGER_LITERAL.
A = strtol(CFCParser_current_state->text, NULL, 10);
}
+declarator(A) ::= IDENTIFIER.
+{
+ A = CFCUtil_strdup(CFCParser_current_state->text);
+}
+
+param_variable(A) ::= type(B) declarator(C).
+{
+ A = (CFCBase*)CFCVariable_new(NULL, NULL, NULL, NULL, C, (CFCType*)B);
+}
+
Modified: incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCVariable.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCVariable.c?rev=1183779&r1=1183778&r2=1183779&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCVariable.c (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCVariable.c Sun Oct 16 01:31:02 2011
@@ -57,8 +57,11 @@ CFCVariable_init(CFCVariable *self, stru
const char *exposure, const char *class_name,
const char *class_cnick, const char *micro_sym,
struct CFCType *type) {
- // Validate type.
+ // Validate params.
CFCUTIL_NULL_CHECK(type);
+ if (!parcel) {
+ parcel = CFCParcel_singleton(NULL, NULL);
+ }
// Default exposure to "local".
const char *real_exposure = exposure ? exposure : "local";
Modified: incubator/lucy/branches/clownfish_lemon/clownfish/t/301-param_list.t
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/t/301-param_list.t?rev=1183779&r1=1183778&r2=1183779&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/t/301-param_list.t (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/t/301-param_list.t Sun Oct 16 01:31:02 2011
@@ -26,7 +26,7 @@ my $parser = Clownfish::Parser->new;
$parser->parcel_definition('parcel Neato;')
or die "failed to process parcel_definition";
-isa_ok( $parser->param_variable($_),
+isa_ok( $parser->parse($_),
"Clownfish::Variable", "param_variable: $_" )
for ( 'uint32_t baz', 'CharBuf *stuff', 'float **ptr', );
Modified: incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.t
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.t?rev=1183779&r1=1183778&r2=1183779&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.t (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.t Sun Oct 16 01:31:02 2011
@@ -16,7 +16,7 @@
use strict;
use warnings;
-use Test::More tests => 103;
+use Test::More tests => 100;
BEGIN { use_ok('Clownfish::Parser') }
@@ -66,10 +66,6 @@ isa_ok( $parser->parse($_), "Clownfish::
is( $parser->declarator($_), $_, "declarator: $_" )
for ( 'foo', 'bar_bar_bar' );
-isa_ok( $parser->param_variable($_),
- "Clownfish::Variable", "param_variable: $_" )
- for ( 'uint32_t baz;', 'CharBuf *stuff;', 'float **ptr;', );
-
isa_ok( $parser->var_declaration_statement($_)->{declared},
"Clownfish::Variable", "var_declaration_statement: $_" )
for (