Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers LCC > yacc trouble
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 953 of 1062
Post > Topic >>

yacc trouble

by Mohitz <coolmohitz@[EMAIL PROTECTED] > Jun 1, 2007 at 01:29 AM

Hi Guys,

I am facing a peculiar problem with my yacc script. Following is the
snippet of the yacc script that i am using.
I am using lex as the lexical analyzer.

Sample Input :

create template {
        with attributes :
              attr1 ;
              attr2 ;
              attr3 ;
}
tpl_name

Output that i get should be ideally

Attribute name is attr1
Attribute name is attr2
Attribute name is attr3

But what i get is

Attribute name is attr1 ;
Attribute name is attr2 ;
Attribute name is attr3 ;

Look at the semicolon appearing at the end. Does someone know why this
happens? Would be glad to furnish more information if needed.

Thanks in advance
Mohit

The Yacc Script Snippet

start                  : CREATE TEMPLATE '{' create_template_body '}'
IDENTIFIER
                        {
                              parsedTemplate =
appendTemplateName(strdup($6),$4);
                        }
                        ;
create_template_body    : define_attributes
                        {
                                $$ = createTemplate($1);
                        }
                        ;

define_attributes       : WITH ATTRIBUTES ':' attribute_list
                        {
                                $$ = $4;
                        }
                        ;

attribute_list          : attribute_list attribute
                        {
                                $$ = appendAttribute($1,$2);
                                // Append attribute to Attribute List
                        }
                        | attribute
                        {
                                $$ = createAttributeList($1);
                                // Create Attribute List from single
attribute
                        }
                        ;

attribute            : IDENTIFIER ';'
                        {
                                printf("Attribute Name is %s\n",
strdup($1));
                                $$ = createAttribute(strdup($1));
                        }
                        ;
 




 1 Posts in Topic:
yacc trouble
Mohitz <coolmohitz@[EM  2007-06-01 01:29:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 23 23:44:38 CDT 2008.