Skip to content

Add support Start-Symbol: %start #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ydah
Copy link
Member

@ydah ydah commented Mar 1, 2025

Fixes: #568

@yui-knk
Copy link
Collaborator

yui-knk commented Apr 29, 2025

I tried the grammar file below with Bison 3.8.2.

%{
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
%}

%code provides {
static int yylex(YYSTYPE *val, YYLTYPE *loc);
static int yyerror(YYLTYPE *loc, const char *str);
}

%union {
    int val;
}
%token LF
%token <val> NUM
%type <val> expr
%left '+' '-'
%left '*' '/'

%locations

%start program_1 program_2 program_3 '/'

%%

program_1 : expr '+' expr;
program_2 : expr '-' expr;
program_3 : expr '*' expr;


expr : NUM
     | '(' expr ')'  { $$ = $2; }
     ;

%%

Output file says YY_PARSE_ terminals are required on state 0. Could you check how multiple start symbols are used?

State 0

    0 $accept: • YY_PARSE_program_1 program_1 $end
    1        | • YY_PARSE_program_2 program_2 $end
    2        | • YY_PARSE_program_3 program_3 $end
    3        | • YY_PARSE_(NULL) '/' $end

    YY_PARSE_(NULL)     shift, and go to state 1
    YY_PARSE_program_1  shift, and go to state 2
    YY_PARSE_program_2  shift, and go to state 3
    YY_PARSE_program_3  shift, and go to state 4

@yui-knk
Copy link
Collaborator

yui-knk commented Apr 29, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Start-Symbol: %start
2 participants