[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/9] style: avoid %{...%} in our parser
From: |
Akim Demaille |
Subject: |
[PATCH 4/9] style: avoid %{...%} in our parser |
Date: |
Thu, 18 Apr 2013 17:28:03 +0200 |
* src/parse-gram.y (%{...%}): Split in %code and %code requires.
* src/location.h: Add missing includes for self containedness.
---
src/location.h | 4 ++++
src/parse-gram.y | 41 ++++++++++++++++++++++-------------------
2 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/src/location.h b/src/location.h
index 8f1c5ae..9c6e53c 100644
--- a/src/location.h
+++ b/src/location.h
@@ -20,6 +20,10 @@
#ifndef LOCATION_H_
# define LOCATION_H_
+# include <stdbool.h>
+# include <stdio.h>
+# include <string.h> /* strcmp */
+
# include "uniqstr.h"
/* A boundary between two characters. */
diff --git a/src/parse-gram.y b/src/parse-gram.y
index 62cee18..8b57ce8 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -1,4 +1,4 @@
-%{/* Bison Grammar Parser -*- C -*-
+/* Bison Grammar Parser -*- C -*-
Copyright (C) 2002-2013 Free Software Foundation, Inc.
@@ -17,27 +17,30 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <config.h>
-#include "system.h"
-
-#include "c-ctype.h"
-#include "complain.h"
-#include "conflicts.h"
-#include "files.h"
-#include "getargs.h"
-#include "gram.h"
-#include "named-ref.h"
-#include "quotearg.h"
-#include "reader.h"
-#include "symlist.h"
-#include "symtab.h"
-#include "scan-gram.h"
-#include "scan-code.h"
-#include "xmemdup0.h"
-%}
+%code requires
+{
+ #include "symlist.h"
+ #include "symtab.h"
+}
%code
{
+ #include <config.h>
+ #include "system.h"
+
+ #include "c-ctype.h"
+ #include "complain.h"
+ #include "conflicts.h"
+ #include "files.h"
+ #include "getargs.h"
+ #include "gram.h"
+ #include "named-ref.h"
+ #include "quotearg.h"
+ #include "reader.h"
+ #include "scan-gram.h"
+ #include "scan-code.h"
+ #include "xmemdup0.h"
+
static int current_prec = 0;
static location current_lhs_location;
static named_ref *current_lhs_named_ref;
--
1.8.2.1
- [PATCH 0/9] {master} check more (all?) variables requiring code value, Akim Demaille, 2013/04/18
- [PATCH 3/9] style: use %code for local function declarations in our parser, Akim Demaille, 2013/04/18
- [PATCH 7/9] parser: do not convert $ and @ in code values of %define variables, Akim Demaille, 2013/04/18
- [PATCH 4/9] style: avoid %{...%} in our parser,
Akim Demaille <=
- [PATCH 1/9] muscle: check the kind of api.prefix, api.location.type, Akim Demaille, 2013/04/18
- [PATCH 6/9] parser: no longer use the "braceless" non-terminal, Akim Demaille, 2013/04/18
- [PATCH 2/9] regen, Akim Demaille, 2013/04/18
- [PATCH 9/9] muscle: check more cases of %define variables with code values, Akim Demaille, 2013/04/18
- [PATCH 8/9] regen, Akim Demaille, 2013/04/18
- [PATCH 5/9] regen, Akim Demaille, 2013/04/18
- Re: [PATCH 0/9] {master} check more (all?) variables requiring code value, Akim Demaille, 2013/04/22