help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bison yyparse return array of values


From: Laura Morales
Subject: Bison yyparse return array of values
Date: Sun, 2 Apr 2017 11:20:09 +0200

I have this simple grammar which basically simply split symbols at white space

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

%output  "parser.c"
%defines "parser.h"

%union { char *str; }

%token <str> WORD

%start Input

%%

Input
    : WORD          { printf("word: %s\n", yylval.str); }
    | Input WORD    { printf("word: %s\n", yylval.str); }
    ;

%%
================

I'm trying to put this into a library, so the main() is in another file. This 
works, it's printing all the words. However what I want to do instead is return 
some data structure such as an array with all the WORDs (printf() is only there 
for testing). So... how can I achieve this?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]