aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2011-04-15 21:33:45 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2011-04-15 21:33:45 +0000
commit848049e223ef408a308cd85e7784b4ea4bc6e54a (patch)
tree176a1124f720ced26152fe4dbfd2f40552c6ae5e
parentb8b782f913f7130ea65600a7760efc8dedacfe49 (diff)
downloadsrc-848049e223ef408a308cd85e7784b4ea4bc6e54a.tar.gz
src-848049e223ef408a308cd85e7784b4ea4bc6e54a.zip
Redo r220658. More extensive patch was committed by Intel:
Notes
Notes: svn path=/vendor-sys/acpica/dist/; revision=220680
-rw-r--r--compiler/Makefile8
-rw-r--r--compiler/aslcompiler.y64
-rw-r--r--compiler/asldefine.h16
-rw-r--r--compiler/aslutils.c33
-rw-r--r--compiler/dtparser.y38
-rw-r--r--generate/unix/Makefile.config12
6 files changed, 93 insertions, 78 deletions
diff --git a/compiler/Makefile b/compiler/Makefile
index 2da41eed92db..4c54b22b84e7 100644
--- a/compiler/Makefile
+++ b/compiler/Makefile
@@ -166,11 +166,15 @@ OBJS = \
INTERMEDIATES = \
aslcompilerlex.c \
- aslcompilerparse.c
+ aslcompilerparse.c \
+ dtparserlex.c \
+ dtparserparse.c
MISC = \
aslcompiler.y.h \
- aslcompilerparse.output
+ aslcompilerparse.output \
+ dtparser.y.h \
+ dtparserparse.output
#
diff --git a/compiler/aslcompiler.y b/compiler/aslcompiler.y
index 31d2ba68e6d3..22d703947750 100644
--- a/compiler/aslcompiler.y
+++ b/compiler/aslcompiler.y
@@ -43,14 +43,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
-#define YYDEBUG 1
-#define YYERROR_VERBOSE 1
-
-/*
- * State stack - compiler will fault if it overflows. (Default was 200)
- */
-#define YYINITDEPTH 600
-
#include "aslcompiler.h"
#include <stdio.h>
#include <stdlib.h>
@@ -74,45 +66,40 @@
* ResourceMacroList, and FieldUnitList
*/
+void * AslLocalAllocate (unsigned int Size);
+
+/* Bison/yacc configuration */
-/*
- * Next statement is important - this makes everything public so that
- * we can access some of the parser tables from other modules
- */
#define static
#undef alloca
-#define alloca AslLocalAllocate
-#define YYERROR_VERBOSE 1
+#define alloca AslLocalAllocate
+#define yytname AslCompilername
-void *
-AslLocalAllocate (unsigned int Size);
+#define YYINITDEPTH 600 /* State stack depth */
+#define YYDEBUG 1 /* Enable debug output */
+#define YYERROR_VERBOSE 1 /* Verbose error messages */
/*
* The windows version of bison defines this incorrectly as "32768" (Not negative).
- * Using a custom (edited binary) version of bison that defines YYFLAG as YYFBAD
- * instead (#define YYFBAD 32768), so we can define it correctly here.
+ * We use a custom (edited binary) version of bison that defines YYFLAG as YYFBAD
+ * instead (#define YYFBAD 32768), so we can define it correctly here.
*
* The problem is that if YYFLAG is positive, the extended syntax error messages
* are disabled.
*/
-
#define YYFLAG -32768
-
%}
-
/*
* Declare the type of values in the grammar
*/
-
%union {
UINT64 i;
char *s;
ACPI_PARSE_OBJECT *n;
}
-
/*! [Begin] no source code translation */
/*
@@ -121,14 +108,12 @@ AslLocalAllocate (unsigned int Size);
*/
%expect 60
-
/*
* Token types: These are returned by the lexer
*
* NOTE: This list MUST match the AslKeywordMapping table found
* in aslmap.c EXACTLY! Double check any changes!
*/
-
%token <i> PARSEOP_ACCESSAS
%token <i> PARSEOP_ACCESSATTRIB_BLOCK
%token <i> PARSEOP_ACCESSATTRIB_BLOCK_CALL
@@ -3138,3 +3123,32 @@ AslDoError (void)
return (TrCreateLeafNode (PARSEOP_ERRORNODE));
}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: UtGetOpName
+ *
+ * PARAMETERS: ParseOpcode - Parser keyword ID
+ *
+ * RETURN: Pointer to the opcode name
+ *
+ * DESCRIPTION: Get the ascii name of the parse opcode
+ *
+ ******************************************************************************/
+
+char *
+UtGetOpName (
+ UINT32 ParseOpcode)
+{
+#ifdef ASL_YYTNAME_START
+ /*
+ * First entries (ASL_YYTNAME_START) in yytname are special reserved names.
+ * Ignore first 8 characters of the name
+ */
+ return ((char *) yytname
+ [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8);
+#else
+ return ("[Unknown parser generator]");
+#endif
+}
diff --git a/compiler/asldefine.h b/compiler/asldefine.h
index cfde1e48849f..04e3b6056b1f 100644
--- a/compiler/asldefine.h
+++ b/compiler/asldefine.h
@@ -66,12 +66,23 @@
#define ASL_STRING_CACHE_SIZE 32768
#define ASL_FIRST_PARSE_OPCODE PARSEOP_ACCESSAS
-#define ASL_YYTNAME_START 3
-
#define ASL_PARSE_OPCODE_BASE PARSEOP_ACCESSAS /* First Lex type */
/*
+ * Per-parser-generator configuration. These values are used to cheat and
+ * directly access the bison/yacc token name table (yyname or yytname).
+ * Note: These values are the index in yyname for the first lex token
+ * (PARSEOP_ACCCESSAS).
+ */
+#if defined (YYBISON)
+#define ASL_YYTNAME_START 3 /* Bison */
+#elif defined (YYBYACC)
+#define ASL_YYTNAME_START 257 /* Berkeley yacc */
+#endif
+
+
+/*
* Macros
*/
#define ASL_RESDESC_OFFSET(m) ACPI_OFFSET (AML_RESOURCE, m)
@@ -97,6 +108,7 @@
/* filename suffixes for output files */
+#define FILE_SUFFIX_PREPROCESSOR "i"
#define FILE_SUFFIX_AML_CODE "aml"
#define FILE_SUFFIX_LISTING "lst"
#define FILE_SUFFIX_HEX_DUMP "hex"
diff --git a/compiler/aslutils.c b/compiler/aslutils.c
index d6428197b893..79fad1d811d3 100644
--- a/compiler/aslutils.c
+++ b/compiler/aslutils.c
@@ -53,13 +53,6 @@
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslutils")
-#ifdef _USE_BERKELEY_YACC
-extern const char * const AslCompilername[];
-static const char * const *yytname = &AslCompilername[254];
-#else
-extern const char * const yytname[];
-#endif
-
char AslHexLookup[] =
{
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
@@ -444,32 +437,6 @@ UtSetParseOpName (
/*******************************************************************************
*
- * FUNCTION: UtGetOpName
- *
- * PARAMETERS: ParseOpcode - Parser keyword ID
- *
- * RETURN: Pointer to the opcode name
- *
- * DESCRIPTION: Get the ascii name of the parse opcode
- *
- ******************************************************************************/
-
-char *
-UtGetOpName (
- UINT32 ParseOpcode)
-{
-
- /*
- * First entries (ASL_YYTNAME_START) in yytname are special reserved names.
- * Ignore first 8 characters of the name
- */
- return ((char *) yytname
- [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8);
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: UtDisplaySummary
*
* PARAMETERS: FileID - ID of outpout file
diff --git a/compiler/dtparser.y b/compiler/dtparser.y
index 2a1030054996..44f9cc5129bd 100644
--- a/compiler/dtparser.y
+++ b/compiler/dtparser.y
@@ -42,22 +42,26 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
-#define YYDEBUG 1
-#define YYERROR_VERBOSE 1
-
#include "aslcompiler.h"
#include "dtcompiler.h"
-#define _COMPONENT ACPI_COMPILER
+#define _COMPONENT DT_COMPILER
ACPI_MODULE_NAME ("dtparser")
-UINT64 DtParserResult; /* Global for expression return value */
+int DtParserlex (void);
+int DtParserparse (void);
+void DtParsererror (char const *msg);
+extern char *DtParsertext;
+extern DT_FIELD *Gbl_CurrentField;
+
+UINT64 DtParserResult; /* Expression return value */
+
+/* Bison/yacc configuration */
-int DtParserlex (void);
-int DtParserparse (void);
-extern char* DtParsertext;
-extern void DtParsererror (char const * msg);
-#define YYFLAG -32768
+#define yytname DtParsername
+#define YYDEBUG 1 /* Enable debug output */
+#define YYERROR_VERBOSE 1 /* Verbose error messages */
+#define YYFLAG -32768
%}
@@ -67,6 +71,8 @@ extern void DtParsererror (char const * msg);
UINT32 op;
}
+/*! [Begin] no source code translation */
+
%type <value> Expression
%token <op> EXPOP_EOF
@@ -164,17 +170,14 @@ Expression
;
%%
+/*! [End] no source code translation !*/
+
/*
* Local support functions, including parser entry point
*/
-extern DT_FIELD *Gbl_CurrentField;
#define PR_FIRST_PARSE_OPCODE EXPOP_EOF
#define PR_YYTNAME_START 3
-#ifdef _USE_BERKELEY_YACC
-#define yytname DtParsername
-#endif
-
/******************************************************************************
*
@@ -213,13 +216,16 @@ char *
DtGetOpName (
UINT32 ParseOpcode)
{
-
+#ifdef ASL_YYTNAME_START
/*
* First entries (PR_YYTNAME_START) in yytname are special reserved names.
* Ignore first 6 characters of name (EXPOP_)
*/
return ((char *) yytname
[(ParseOpcode - PR_FIRST_PARSE_OPCODE) + PR_YYTNAME_START] + 6);
+#else
+ return ("[Unknown parser generator]");
+#endif
}
diff --git a/generate/unix/Makefile.config b/generate/unix/Makefile.config
index 3811e6142e6d..8a32bdfd40ba 100644
--- a/generate/unix/Makefile.config
+++ b/generate/unix/Makefile.config
@@ -77,6 +77,18 @@ CWARNINGFLAGS+= \
#
# Bison/Flex configuration
#
+# -v: verbose, produces a .output file
+# -d: produces the defines header file
+# -y: act like yacc
+#
+# -i: generate case insensitive scanner
+# -s: suppress default rule, abort on unknown input
+#
+# Berkeley yacc configuration
+#
+#YACC= byacc
+#YFLAGS+= -v -d
+#
YACC= bison
YFLAGS+= -v -d -y