[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Added Yacc library to Bison
From: |
Paul Eggert |
Subject: |
Added Yacc library to Bison |
Date: |
Sat, 30 Nov 2002 01:14:14 -0800 (PST) |
POSIX requires that there be a Yacc library, linkable by "cc -ly". I
installed the following patch to Bison so that Bison can conform to
this POSIX requirement.
2002-11-30 Paul Eggert <address@hidden>
Add Yacc library, since POSIX requires it.
* doc/bison.texinfo (Yacc Library): New node. Regenerate top menu.
* lib/Makefile.am (lib_LIBRARIES, liby_a_SOURCES): New macros.
* lib/main.c, lib/yyerror.c: New files.
Index: doc/bison.texinfo
===================================================================
RCS file: /cvsroot/bison/bison/doc/bison.texinfo,v
retrieving revision 1.88
diff -p -u -r1.88 bison.texinfo
--- doc/bison.texinfo 30 Nov 2002 07:42:37 -0000 1.88
+++ doc/bison.texinfo 30 Nov 2002 09:07:52 -0000
@@ -119,7 +119,8 @@ Reference sections:
* Copying This Manual:: License for copying this manual.
* Index:: Cross-references to the text.
address@hidden --- The Detailed Node Listing ---
address@hidden
+ --- The Detailed Node Listing ---
The Concepts of Bison
@@ -130,6 +131,8 @@ The Concepts of Bison
a semantic value (the value of an integer,
the name of an identifier, etc.).
* Semantic Actions:: Each rule can have an action containing C code.
+* GLR Parsers:: Writing parsers for general context-free languages
+* Locations Overview:: Tracking Locations.
* Bison Parser:: What are Bison's input and output,
how is the output used?
* Stages:: Stages in writing and running Bison grammars.
@@ -143,8 +146,8 @@ Examples
Operator precedence is introduced.
* Simple Error Recovery:: Continuing after syntax errors.
* Location Tracking Calc:: Demonstrating the use of @@@var{n} and @@$.
-* Multi-function Calc:: Calculator with memory and trig functions.
- It uses multiple data-types for semantic values.
+* Multi-function Calc:: Calculator with memory and trig functions.
+ It uses multiple data-types for semantic values.
* Exercises:: Ideas for improving the multi-function calculator.
Reverse Polish Notation Calculator
@@ -182,15 +185,16 @@ Bison Grammar Files
* Rules:: How to write grammar rules.
* Recursion:: Writing recursive rules.
* Semantics:: Semantic values and actions.
+* Locations:: Locations and actions.
* Declarations:: All kinds of Bison declarations are described here.
* Multiple Parsers:: Putting more than one Bison parser in one program.
Outline of a Bison Grammar
-* Prologue:: Syntax and usage of the prologue (declarations section).
+* Prologue:: Syntax and usage of the prologue.
* Bison Declarations:: Syntax and usage of the Bison declarations section.
* Grammar Rules:: Syntax and usage of the grammar rules section.
-* Epilogue:: Syntax and usage of the epilogue (additional code
section).
+* Epilogue:: Syntax and usage of the epilogue.
Defining Language Semantics
@@ -202,6 +206,12 @@ Defining Language Semantics
This says when, why and how to use the exceptional
action in the middle of a rule.
+Tracking Locations
+
+* Location Type:: Specifying a data type for locations.
+* Actions and Locations:: Using locations in actions.
+* Location Default Action:: Defining a general way to compute locations.
+
Bison Declarations
* Token Decl:: Declaring terminal symbols.
@@ -229,7 +239,7 @@ The Lexical Analyzer Function @code{yyle
of the token it has read.
* Token Positions:: How @code{yylex} must return the text position
(line number, etc.) of the token, if the
- actions want that.
+ actions want that.
* Pure Calling:: How the calling convention differs
in a pure parser (@pxref{Pure Decl, ,A Pure
(Reentrant) Parser}).
@@ -259,7 +269,7 @@ Handling Context Dependencies
* Tie-in Recovery:: Lexical tie-ins have implications for how
error recovery rules must be written.
-Understanding or Debugging Your Parser
+Debugging Your Parser
* Understanding:: Understanding the structure of your parser.
* Tracing:: Tracing the execution of your parser.
@@ -269,6 +279,7 @@ Invoking Bison
* Bison Options:: All the options described in detail,
in alphabetical order by short options.
* Option Cross Key:: Alphabetical list of long options.
+* Yacc Library:: Yacc-compatible @code{yylex} and @code{main}.
Frequently Asked Questions
@@ -6075,6 +6086,7 @@ will produce @file{output.c++} and @file
* Bison Options:: All the options described in detail,
in alphabetical order by short options.
* Option Cross Key:: Alphabetical list of long options.
+* Yacc Library:: Yacc-compatible @code{yylex} and @code{main}.
@end menu
@node Bison Options
@@ -6265,6 +6277,32 @@ the corresponding short option.
--yacc -y
@end example
@end ifinfo
+
address@hidden Yacc Library
address@hidden Yacc Library
+
+The Yacc library contains default implementations of the
address@hidden and @code{main} functions. These default
+implementations are normally not useful, but @acronym{POSIX} requires
+them. To use the Yacc library, link your program with the
address@hidden option. Note that Bison's implementation of the Yacc
+library is distributed under the terms of the @acronym{GNU} General
+Public License (@pxref{Copying}).
+
+If you use the Yacc library's @code{yyerror} function, you should
+declare @code{yyerror} as follows:
+
address@hidden
+int yyerror (char const *);
address@hidden example
+
+Bison ignores the @code{int} value returned by this @code{yyerror}.
+If you use the Yacc library's @code{main} function, your
address@hidden function should have the following type signature:
+
address@hidden
+int yyparse (void);
address@hidden example
@c ================================================= Invoking Bison
Index: lib/Makefile.am
===================================================================
RCS file: /cvsroot/bison/bison/lib/Makefile.am,v
retrieving revision 1.34
diff -p -u -r1.34 Makefile.am
--- lib/Makefile.am 3 Nov 2002 08:39:43 -0000 1.34
+++ lib/Makefile.am 30 Nov 2002 09:07:52 -0000
@@ -17,12 +17,15 @@
AM_CFLAGS = $(WARNING_CFLAGS)
+lib_LIBRARIES = liby.a
noinst_LIBRARIES = libbison.a
# config.h is in build/., and system.h is in src/src/.
INCLUDES = -I$(top_builddir) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/lib
+
+liby_a_SOURCES = main.c yyerror.c
# Heck, we are still using an old version of Automake which does not
# understand inner AC_LIBOBJ (i.e., from Autoconf itself, not from
--- /dev/null 2002-11-30 01:07:34.000000000 -0800
+++ lib/main.c 2002-11-29 23:05:04.879290000 -0800
@@ -0,0 +1,38 @@
+/* Yacc library main function.
+
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+ This file is part of Bison, the GNU Compiler Compiler.
+
+ Bison is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Bison is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bison; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <config.h>
+
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif
+#if ! HAVE_SETLOCALE
+# define setlocale(Category, Locale)
+#endif
+
+int yyparse (void);
+
+int
+main (void)
+{
+ setlocale (LC_ALL, "");
+ return yyparse ();
+}
--- /dev/null 2002-11-30 01:07:34.000000000 -0800
+++ lib/yyerror.c 2002-11-29 23:05:47.677281000 -0800
@@ -0,0 +1,30 @@
+/* Yacc library error-printing function.
+
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+ This file is part of Bison, the GNU Compiler Compiler.
+
+ Bison is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Bison is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bison; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+
+int yyerror (char const *);
+
+int
+yyerror (char const *message)
+{
+ return fprintf (stderr, "%s\n", message);
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Added Yacc library to Bison,
Paul Eggert <=
- Prev by Date:
Bison manual updates for yylex, yyerror, inline, coding style, etc.
- Next by Date:
gram_error can be static, not extern
- Previous by thread:
Bison manual updates for yylex, yyerror, inline, coding style, etc.
- Next by thread:
gram_error can be static, not extern
- Index(es):