Skip to content

Some grammar actions can be removed #6

@mingodad

Description

@mingodad

Looking through the grammar at https://github.com/LilyOSullivan/SymbolicExecutionForCWithParser/blob/main/LexYacc/Parser_source/GRAMMAR.Y I noticed that there are several actions that can be removed and achieve the same result with less work/allocations:

{
        $$ = (char*) malloc(strlen($1) + 1);
	strcpy($$, $1);
        free($1);
}

Rule actions like the above can be removed, because the default rule is $$ = $1, so no need to copy and delete $1.

	{
		struct_flag = NO;
		
		// Visual C extension
		$$ = (char*) malloc(strlen($2) + 1);
		strcpy($$, $2);
		free($1);
		free($2);
	}

Rule actions like the above can be reduced to :

	{
		struct_flag = NO;
		
		// Visual C extension
		$$ = $2;
		free($1);
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions