From f7e963a1c5a83e8ac937d85d5c080d9eb1dedf5a Mon Sep 17 00:00:00 2001 From: David Hartmann Date: Wed, 29 Jun 2022 16:07:14 +0200 Subject: [PATCH 1/2] fix doc mentioning (old) tokens.h instead of tmp.tab.h --- doc/api/private/bison.BisonParser-class.html | 6 +++--- doc/api/public/bison.BisonParser-class.html | 6 +++--- doc/walkthrough.html | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/api/private/bison.BisonParser-class.html b/doc/api/private/bison.BisonParser-class.html index 2b90f6a..469fb72 100644 --- a/doc/api/private/bison.BisonParser-class.html +++ b/doc/api/private/bison.BisonParser-class.html @@ -204,7 +204,7 @@

Class BisonParser

bisonHFile = 'tmp.tab.h' str -bisonHFile1 = 'tokens.h' +bisonHFile1 = 'tmp.tab.h' classobj defaultNodeClass = bison.BisonNode @@ -584,10 +584,10 @@

bisonHFile1

str -
Value:
+
Value:
-'tokens.h'                                                             
+'tmp.tab.h'
diff --git a/doc/api/public/bison.BisonParser-class.html b/doc/api/public/bison.BisonParser-class.html index 671c91d..130bb9d 100644 --- a/doc/api/public/bison.BisonParser-class.html +++ b/doc/api/public/bison.BisonParser-class.html @@ -186,7 +186,7 @@

Class BisonParser

bisonHFile = 'tmp.tab.h' str -bisonHFile1 = 'tokens.h' +bisonHFile1 = 'tmp.tab.h' classobj defaultNodeClass = bison.BisonNode @@ -550,10 +550,10 @@

bisonHFile1

str -
Value:
+
Value:
-'tokens.h'                                                             
+'tmp.tab.h'
diff --git a/doc/walkthrough.html b/doc/walkthrough.html index 0555eb1..2201b2d 100644 --- a/doc/walkthrough.html +++ b/doc/walkthrough.html @@ -205,7 +205,7 @@

1.3. Preparing Your Tokeniser File

#include <string.h> #include "Python.h" #define YYSTYPE void * - #include "tokens.h" + #include "tmp.tab.h" extern void *py_parser; extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size); #define returntoken(tok) yylval = PyUnicode_FromString(strdup(yytext)); return (tok); @@ -231,11 +231,11 @@

1.3. Preparing Your Tokeniser File

just give them opaque pointers, and void * will suffice just fine.
-    #include "tokens.h"
+ #include "tmp.tab.h" When PyBison first instantiates any given parser class (and auto-generates, processes, compiles, links the grammar/scanner files into a dynamic lib), the bison program generates - a header file of token definitions, which gets renamed to tokens.h. Your scanner + a header file of token definitions, which gets renamed to tmp.tab.h. Your scanner script will need this file, so the token macros will be defined and resolved to the correct token numbers. @@ -690,7 +690,7 @@

2.8. Add Flex Script

#include <string.h> #include "Python.h" #define YYSTYPE void * - #include "tokens.h" + #include "tmp.tab.h" extern void *py_parser; extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size); #define returntoken(tok) yylval = PyUnicode_FromString(strdup(yytext)); return (tok); @@ -775,7 +775,7 @@

2.8. Add Flex Script

#include <string.h> #include "Python.h" #define YYSTYPE void * - #include "tokens.h" + #include "tmp.tab.h" extern void *py_parser; extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size); #define returntoken(tok) yylval = PyUnicode_FromString(strdup(yytext)); return (tok); From e9fdd35de82c778cfe737addfccc9ce34fe72e30 Mon Sep 17 00:00:00 2001 From: David Hartmann Date: Wed, 29 Jun 2022 16:07:35 +0200 Subject: [PATCH 2/2] fix comments mentioning tokens.h instead of tmp.tab.h --- src/bison/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bison/__init__.py b/src/bison/__init__.py index c443204..2433c35 100644 --- a/src/bison/__init__.py +++ b/src/bison/__init__.py @@ -99,9 +99,9 @@ class BisonParser(object): bisonHFile = 'tmp.tab.h' # C output file from bison gets renamed to this. - bisonCFile1 = bisonCFile # 'tmp.bison.c' + bisonCFile1 = bisonCFile # 'tmp.tab.c' # Bison-generated header file gets renamed to this. - bisonHFile1 = bisonHFile # 'tokens.h' + bisonHFile1 = bisonHFile # 'tmp.tab.h' # flex file names flexFile = 'tmp.l'