Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2008-01-22 19:16:30 +0000
committerMike Kucera2008-01-22 19:16:30 +0000
commit17f8a38f4e9b5ea45d46995f0f399eb193fb9ac1 (patch)
tree3127f63022f7ac6049d3ab4b6e8afadff7d8c1ed /lrparser
parent6c58a960298f56e66a553c61b6bbac8ae4bcf829 (diff)
downloadorg.eclipse.cdt-17f8a38f4e9b5ea45d46995f0f399eb193fb9ac1.tar.gz
org.eclipse.cdt-17f8a38f4e9b5ea45d46995f0f399eb193fb9ac1.tar.xz
org.eclipse.cdt-17f8a38f4e9b5ea45d46995f0f399eb193fb9ac1.zip
initial commit of new C99 and C++ parsers (work in progress)
Diffstat (limited to 'lrparser')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/.classpath7
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/.project28
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/META-INF/MANIFEST.MF16
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/about.html24
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/build.properties16
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/plugin.properties15
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ActionTestSuite.java29
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ResolverActionTests.java129
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/SymbolTableTests.java152
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/Activator.java60
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CommentTests.java66
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompleteParser2Tests.java74
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompletionBasicTest.java88
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompletionParseTest.java424
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationInclusionTests.java62
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationMacroTests.java65
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationTests.java59
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMPreprocessorInformationTest.java35
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DigraphTrigraphTests.java175
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99GCCTests.java38
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99KnRTests.java70
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99SelectionParseTest.java165
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99SpecTests.java211
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99TaskParserTest.java33
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99Tests.java164
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99UtilOldTests.java44
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99UtilTests.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/ParseHelper.java135
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/ParserTestSuite.java55
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/.classpath7
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/.project34
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF17
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/about.html24
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/about.ini24
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/about.mappings9
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/about.properties25
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/build.properties21
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/eclipse32.gifbin0 -> 1706 bytes
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/plugin.properties18
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/plugin.xml28
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/BaseExtensibleLanguage.java178
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java107
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParser.java41
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParserActionTokenProvider.java58
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/ITokenCollector.java26
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/LPGTokenAdapter.java121
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java94
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java1042
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/FunctionalMap.java292
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/IASTNodeFactory.java168
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ITokenMap.java33
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ScopedStack.java207
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/TokenMap.java71
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99ASTNodeFactory.java425
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99BuildASTParserAction.java974
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99ResolveParserAction.java1560
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99SymbolTable.java111
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99TypedefTrackerParserAction.java354
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/CNamespace.java29
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/DeclSpec.java168
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/DeclaratorFrame.java142
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/IC99ASTNodeFactory.java70
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ImperativeSymbolTable.java208
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/TypedefSymbolTable.java73
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTNodeFactory.java498
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java1370
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/ICPPASTNodeFactory.java122
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/C99Language.java97
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/DOMToC99TokenMap.java329
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/DOMToISOCPPTokenMap.java173
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/ISOCPPLanguage.java97
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/AbstractTrialUndoActionProvider.java202
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/ITrialUndoActionProvider.java43
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/ParserState.java141
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/Rule.java54
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/TrialUndoParser.java652
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/TrialUndoParserTemplate.g303
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/ASTPrinter.java472
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/BindingCheckVisitor.java50
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/CollectionUtils.java126
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/DebugUtil.java76
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99OldParser.g1056
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.g1218
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.java2429
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ParserAction.java20
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parserprs.java1378
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parsersym.java212
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ResolverParser.g1835
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99ArrayType.java122
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99BasicType.java132
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99CompositeTypeScope.java38
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java105
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumerator.java66
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Field.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java152
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99FunctionScope.java41
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99FunctionType.java60
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Label.java61
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Parameter.java34
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99PointerType.java98
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99ProblemBinding.java31
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99QualifierType.java102
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java103
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Structure.java146
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Typedef.java100
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Variable.java111
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/IC99Binding.java19
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/IC99Scope.java31
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/ITypeable.java17
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.g1660
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.java2573
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParserAction.java19
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParserprs.java2882
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParsersym.java272
116 files changed, 31235 insertions, 0 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/.classpath b/lrparser/org.eclipse.cdt.core.lrparser.tests/.classpath
new file mode 100644
index 00000000000..751c8f2e504
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/.project b/lrparser/org.eclipse.cdt.core.lrparser.tests/.project
new file mode 100644
index 00000000000..4b301f0a33d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.core.parser.c99.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/.settings/org.eclipse.jdt.ui.prefs b/lrparser/org.eclipse.cdt.core.lrparser.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..95087c66c9e
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Fri Oct 05 11:17:36 EDT 2007
+eclipse.preferences.version=1
+internal.default.compliance=default
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/META-INF/MANIFEST.MF b/lrparser/org.eclipse.cdt.core.lrparser.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..7081dd0820a
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-SymbolicName: org.eclipse.cdt.core.lrparser.tests
+Bundle-Version: 4.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.core.lrparser.tests.c99.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.junit,
+ org.eclipse.cdt.core.tests,
+ org.eclipse.cdt.core,
+ org.eclipse.core.resources,
+ org.eclipse.cdt.core.lrparser;bundle-version="4.0.1"
+Eclipse-LazyStart: true
+Export-Package: org.eclipse.cdt.core.lrparser.tests.c99
+Bundle-Vendor: %Bundle-Vendor.0
+Bundle-Localization: plugin
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/about.html b/lrparser/org.eclipse.cdt.core.lrparser.tests/about.html
new file mode 100644
index 00000000000..9b669c2fd0c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
+
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>February 8, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/build.properties b/lrparser/org.eclipse.cdt.core.lrparser.tests/build.properties
new file mode 100644
index 00000000000..185a840ec69
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/build.properties
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2007 IBM Corporation and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.properties
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/plugin.properties b/lrparser/org.eclipse.cdt.core.lrparser.tests/plugin.properties
new file mode 100644
index 00000000000..b09765a2e51
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/plugin.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2007 IBM Corporation and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+# properties file for org.eclipse.cdt.core.parser.c99.tests
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.0 = C99 Parser Tests Plug-in
+
+upcSourceName=UPC Source File \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ActionTestSuite.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ActionTestSuite.java
new file mode 100644
index 00000000000..6262e2735da
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ActionTestSuite.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import org.eclipse.cdt.core.dom.lrparser.action.c99.SymbolTableTests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class ActionTestSuite extends TestSuite {
+
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(SymbolTableTests.class);
+ suite.addTestSuite(ResolverActionTests.class);
+
+ return suite;
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ResolverActionTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ResolverActionTests.java
new file mode 100644
index 00000000000..a2524edf6c3
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ResolverActionTests.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_identifier;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_int;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import lpg.lpgjavaruntime.IToken;
+import lpg.lpgjavaruntime.Token;
+
+import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Variable;
+
+public class ResolverActionTests extends TestCase {
+
+ /**
+ * We are testing the parser actions in isolation without running
+ * an actual parser, therefore we need to mock out the parser object.
+ */
+ private static class MockParser implements IParserActionTokenProvider {
+
+ public List<IToken> ruleTokens;
+
+ public MockParser(Object ... tokenTypes) {
+ this.ruleTokens = tokens(tokenTypes);
+ }
+ public List<IToken> getCommentTokens() {
+ return null;
+ }
+ public IToken getEOFToken() {
+ return null;
+ }
+ public IToken getLeftIToken() {
+ return ruleTokens.get(0);
+ }
+ public IToken getRightIToken() {
+ return ruleTokens.get(ruleTokens.size()-1);
+ }
+ public List<IToken> getRuleTokens() {
+ return ruleTokens;
+ }
+ public void setRuleTokens(Object ... tokenTypes) {
+ this.ruleTokens = tokens(tokenTypes);
+ }
+ static List<IToken> tokens(Object[] tokenTypes) {
+ List<IToken> tokens = new ArrayList<IToken>();
+ if(tokenTypes == null)
+ return tokens;
+
+ for(final Object o : tokenTypes) {
+ IToken token;
+ if(o instanceof Integer)
+ token = new Token(0, 0, ((Integer)o).intValue());
+ else if(o instanceof String)
+ token = new Token(0, 0, TK_identifier) {
+ @Override public String toString() {
+ return o.toString();
+ }
+ };
+ else
+ throw new AssertionFailedError();
+
+ tokens.add(token);
+ }
+ return tokens;
+ }
+ }
+
+
+ /**
+ * Parsing: int x;, then undo, then parse again
+ */
+ @SuppressWarnings("deprecation")
+ public void testResolverActions1() {
+ MockParser mockParser = new MockParser();
+ C99ResolveParserAction action = new C99ResolveParserAction(mockParser);
+
+ mockParser.setRuleTokens(TK_int);
+ action.openDeclarationScope();
+ action.consumeDeclSpecToken();
+ mockParser.setRuleTokens("x");
+ action.consumeDirectDeclaratorIdentifier();
+ action.consumeDeclaratorComplete();
+ action.closeDeclarationScope();
+
+ C99SymbolTable symbolTable;
+ symbolTable = action.getSymbolTable();
+ assertEquals(1, symbolTable.size());
+ C99Variable binding = (C99Variable) symbolTable.lookup(CNamespace.IDENTIFIER, "x");
+ assertEquals("x", binding.getName());
+
+ // cool, now undo!
+ assertEquals(5, action.undoStackSize());
+ action.undo(5);
+ assertEquals(0, action.undoStackSize());
+ assertEquals(0, action.getDeclarationStack().size());
+ symbolTable = action.getSymbolTable();
+ assertTrue(symbolTable.isEmpty());
+
+ // rerun
+ mockParser.setRuleTokens(TK_int);
+ action.openDeclarationScope();
+ action.consumeDeclSpecToken();
+ mockParser.setRuleTokens("x");
+ action.consumeDirectDeclaratorIdentifier();
+ action.consumeDeclaratorComplete();
+ action.closeDeclarationScope();
+
+ symbolTable = action.getSymbolTable();
+ assertEquals(1, symbolTable.size());
+ binding = (C99Variable) symbolTable.lookup(CNamespace.IDENTIFIER, "x");
+ assertEquals("x", binding.getName());
+ }
+}
+
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/SymbolTableTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/SymbolTableTests.java
new file mode 100644
index 00000000000..1dee48b6215
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/dom/lrparser/action/c99/SymbolTableTests.java
@@ -0,0 +1,152 @@
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import junit.framework.TestCase;
+
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.lrparser.action.FunctionalMap;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Label;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Structure;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Variable;
+
+@SuppressWarnings("deprecation")
+public class SymbolTableTests extends TestCase {
+ // TODO write tests for imperative symbol table
+
+ private final String[] KEYS = { "pantera", "soulfly", "inflames", "megadeth", "archenemy", "carcass" };
+
+ public void testPersistence() {
+ FunctionalMap<String,Integer> st0 = FunctionalMap.emptyMap();
+ assertTrue(st0.isEmpty());
+
+ FunctionalMap<String,Integer> st1 = st0.insert(KEYS[0], 1);
+
+ // empty symbol table does not change
+ assertTrue(st0.isEmpty());
+ assertNull(st0.lookup(KEYS[1]));
+
+ // a new symbol table was created
+ assertFalse(st1.isEmpty());
+ assertEquals(new Integer(1), st1.lookup(KEYS[0]));
+
+ FunctionalMap<String,Integer> st2 = st1.insert(KEYS[1], 2);
+ FunctionalMap<String,Integer> st3 = st2.insert(KEYS[2], 3);
+ FunctionalMap<String,Integer> st4 = st3.insert(KEYS[3], 4);
+ FunctionalMap<String,Integer> st5 = st4.insert(KEYS[4], 5);
+
+ assertMap(st0, KEYS, new Integer[] {null, null, null, null, null, null} );
+ assertMap(st1, KEYS, new Integer[] {1, null, null, null, null, null} );
+ assertMap(st2, KEYS, new Integer[] {1, 2, null, null, null, null} );
+ assertMap(st3, KEYS, new Integer[] {1, 2, 3, null, null, null} );
+ assertMap(st4, KEYS, new Integer[] {1, 2, 3, 4, null, null} );
+ assertMap(st5, KEYS, new Integer[] {1, 2, 3, 4, 5, null} );
+ }
+
+
+
+ public void testOverride() {
+ FunctionalMap<String,Integer> map1 = FunctionalMap.emptyMap();
+ for(int i = 0; i < KEYS.length; i++) {
+ map1 = map1.insert(KEYS[i], i);
+ }
+
+ assertMap(map1, KEYS, new Integer[] {0, 1, 2, 3, 4, 5});
+
+ FunctionalMap<String,Integer> map2 = map1.insert(KEYS[5], 999);
+ FunctionalMap<String,Integer> map3 = map2.insert(KEYS[5], null);
+
+ assertEquals(new Integer(5), map1.lookup(KEYS[5]));
+ assertEquals(new Integer(999), map2.lookup(KEYS[5]));
+ assertNull(map3.lookup(KEYS[5]));
+ }
+
+
+ private static void assertMap(FunctionalMap map, Comparable[] keys, Object[] vals) {
+ assert keys.length == vals.length;
+
+ for(int i = 0; i < keys.length; i++) {
+ assertEquals( "the key '" + keys[i] + "' did not match", vals[i], map.lookup((keys[i])));
+ if(vals[i] != null) {
+ assertTrue("key '" + keys[i] + "' not in map", map.containsKey(keys[i]));
+ }
+ }
+ }
+
+
+ public void testFunctionalSymbolTable1() {
+ C99SymbolTable st = C99SymbolTable.EMPTY_TABLE;
+
+ for(String key : KEYS) {
+ st = st.insert(CNamespace.IDENTIFIER, key, new C99Variable(key));
+ }
+ for(String key : KEYS) {
+ st = st.insert(CNamespace.GOTO_LABEL, key, new C99Label(key));
+ }
+ for(String key : KEYS) {
+ st = st.insert(CNamespace.STRUCT_TAG, key, new C99Structure(key));
+ }
+
+ assertFunctionalSymbolTableContainsAllThePairs(st);
+ }
+
+ public void testFunctionalSymbolTable2() {
+ C99SymbolTable st = C99SymbolTable.EMPTY_TABLE;
+
+ // same test as above but this time we insert the keys in a different order
+ for(String key : KEYS) {
+ st = st.insert(CNamespace.IDENTIFIER, key, new C99Variable(key));
+ st = st.insert(CNamespace.GOTO_LABEL, key, new C99Label(key));
+ st = st.insert(CNamespace.STRUCT_TAG, key, new C99Structure(key));
+ }
+
+ assertFunctionalSymbolTableContainsAllThePairs(st);
+ }
+
+ private void assertFunctionalSymbolTableContainsAllThePairs(C99SymbolTable st) {
+ assertEquals(KEYS.length * 3, st.size());
+ for(String key : KEYS) {
+ IBinding b = st.lookup(CNamespace.IDENTIFIER, key);
+ assertNotNull(b);
+ C99Variable x = (C99Variable)b;
+ assertEquals(key, x.getName());
+ }
+ for(String key : KEYS) {
+ IBinding b = st.lookup(CNamespace.GOTO_LABEL, key);
+ assertNotNull(b);
+ C99Label x = (C99Label)b;
+ assertEquals(key, x.getName());
+ }
+ for(String key : KEYS) {
+ IBinding b = st.lookup(CNamespace.STRUCT_TAG, key);
+ assertNotNull(b);
+ C99Structure x = (C99Structure)b;
+ assertEquals(key, x.getName());
+ }
+ }
+
+
+ public void testProperFail() {
+ FunctionalMap<Integer,Integer> map = FunctionalMap.emptyMap();
+ try {
+ map.insert(null, 99);
+ fail();
+ } catch (NullPointerException _) {}
+
+ try {
+ map.containsKey(null);
+ fail();
+ } catch (NullPointerException _) {}
+
+ try {
+ map.lookup(null);
+ fail();
+ } catch (NullPointerException _) {}
+
+ C99SymbolTable table = C99SymbolTable.EMPTY_TABLE;
+ try {
+ table.insert(null, null, new C99Variable("blah")); //$NON-NLS-1$
+ fail();
+ } catch (NullPointerException _) {}
+
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/Activator.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/Activator.java
new file mode 100644
index 00000000000..c4b48fd8096
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/Activator.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.cdt.core.parser.c99.tests";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CommentTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CommentTests.java
new file mode 100644
index 00000000000..79dfdf8ffd6
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CommentTests.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.CommentTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99CommentTests extends CommentTests {
+
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems )
+ throws ParserException {
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+
+
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang,
+ boolean useGNUExtensions, boolean expectNoProblems,
+ boolean parseComments) throws ParserException {
+
+
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems, parseComments);
+
+ return ParseHelper.commentParse(code, getLanguage());
+ }
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+ public void testBug191266() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append("#define MACRO 1000000000000 \n");
+ sb.append("int x = MACRO; \n");
+ sb.append("//comment\n");
+ String code = sb.toString();
+
+ IASTTranslationUnit tu = parse(code, ParserLanguage.C, false, false, true);
+
+ IASTComment[] comments = tu.getComments();
+ assertEquals(1, comments.length);
+
+ IASTFileLocation location = comments[0].getFileLocation();
+ assertEquals(code.indexOf("//"), location.getNodeOffset());
+ assertEquals("//comment".length(), location.getNodeLength());
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompleteParser2Tests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompleteParser2Tests.java
new file mode 100644
index 00000000000..f1c622010b5
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompleteParser2Tests.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.CompleteParser2Tests;
+
+public class C99CompleteParser2Tests extends CompleteParser2Tests {
+
+ protected IASTTranslationUnit parse(String code, boolean expectedToPass,
+ ParserLanguage lang, boolean gcc) throws Exception {
+
+ if(lang != ParserLanguage.C)
+ return super.parse(code, expectedToPass, lang, gcc);
+
+ return ParseHelper.parse(code, getLanguage(), expectedToPass);
+ }
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+ // Tests that are failing at this point
+
+ public void testBug39676_tough() { // is this C99?
+ try {
+ super.testBug39676_tough();
+ } catch(AssertionFailedError _) {
+ return;
+ } catch(Exception _) {
+ return;
+ }
+
+ fail();
+ }
+
+// public void testPredefinedSymbol_bug70928_infinite_loop_test1() throws Exception { // gcc extension
+// try {
+// super.testPredefinedSymbol_bug70928_infinite_loop_test1();
+// fail();
+// } catch(AssertionError _) { }
+// }
+//
+// public void testPredefinedSymbol_bug70928_infinite_loop_test2() throws Exception { // gcc extension
+// try {
+// super.testPredefinedSymbol_bug70928_infinite_loop_test2();
+// fail();
+// } catch(AssertionError _) { }
+// }
+//
+//
+// public void testBug102376() throws Exception { // gcc extension
+// try {
+// super.testBug102376();
+// fail();
+// } catch(AssertionError _) { }
+// }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompletionBasicTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompletionBasicTest.java
new file mode 100644
index 00000000000..5d9ab1467b3
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompletionBasicTest.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.prefix.BasicCompletionTest;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99CompletionBasicTest extends BasicCompletionTest {
+
+ public C99CompletionBasicTest() { }
+
+
+ protected IASTCompletionNode getCompletionNode(String code,
+ ParserLanguage lang, boolean useGNUExtensions)
+ throws ParserException {
+
+ if(ParserLanguage.C == lang) {
+ return ParseHelper.getCompletionNode(code, getLanguage());
+ }
+ else {
+ // TODO: parsing of C++
+ return super.getCompletionNode(code, lang, useGNUExtensions);
+ }
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+ // The C99 parser currently doesn't support ambiguity nodes.
+ // Therefore calling IASTCompletionNode.getNames() will
+ // never return more than one name.
+
+
+ @Override
+ public void testFunction() throws Exception {
+ StringBuffer code = new StringBuffer();
+ code.append("void func(int x) { }");//$NON-NLS-1$
+ code.append("void func2() { fu");//$NON-NLS-1$
+
+ // C
+ IASTCompletionNode node = getGCCCompletionNode(code.toString());
+ IASTName[] names = node.getNames();
+
+ // There is only one name, for now
+ assertEquals(1, names.length);
+ // The expression points to our functions
+ IBinding[] bindings = sortBindings(names[0].getCompletionContext().findBindings(names[0], true));
+ // There should be two since they both start with fu
+ assertEquals(2, bindings.length);
+ assertEquals("func", ((IFunction)bindings[0]).getName());//$NON-NLS-1$
+ assertEquals("func2", ((IFunction)bindings[1]).getName());//$NON-NLS-1$
+
+ }
+
+ @Override
+ public void testTypedef() throws Exception {
+ StringBuffer code = new StringBuffer();
+ code.append("typedef int blah;");//$NON-NLS-1$
+ code.append("bl");//$NON-NLS-1$
+
+ // C
+ IASTCompletionNode node = getGCCCompletionNode(code.toString());
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+ IBinding[] bindings = names[0].getCompletionContext().findBindings(names[0], true);
+ assertEquals(1, bindings.length);
+ assertEquals("blah", ((ITypedef)bindings[0]).getName());//$NON-NLS-1$
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompletionParseTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompletionParseTest.java
new file mode 100644
index 00000000000..ecb9846b3f6
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99CompletionParseTest.java
@@ -0,0 +1,424 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import java.util.Arrays;
+import java.util.Comparator;
+
+import junit.framework.TestCase;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+
+
+/**
+ * Reuse the completion parse tests from the old parser for now.
+ *
+ * This test suite is specific to C99.
+ */
+public class C99CompletionParseTest extends TestCase {
+
+ public C99CompletionParseTest() { }
+ public C99CompletionParseTest(String name) { super(name); }
+
+
+ protected IASTCompletionNode parse(String code, int offset) throws Exception {
+ return ParseHelper.getCompletionNode(code, getLanguage(), offset);
+ }
+
+
+ private static class BindingsComparator implements Comparator {
+ public int compare(Object o1, Object o2) {
+ IBinding b1 = (IBinding)o1;
+ IBinding b2 = (IBinding)o2;
+ return b1.getName().compareTo(b2.getName());
+ }
+ }
+
+ private static BindingsComparator bindingsComparator = new BindingsComparator();
+
+ protected IBinding[] sortBindings(IBinding[] bindings) {
+ Arrays.sort(bindings, bindingsComparator);
+ return bindings;
+ }
+
+ protected IBinding[] getBindings(IASTName[] names) {
+ return sortBindings(names[0].getCompletionContext().findBindings(names[0], true));
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+ // First steal tests from CompletionParseTest
+
+
+ public void testCompletionStructField() throws Exception
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "int aVar; " ); //$NON-NLS-1$
+ sb.append( "struct D{ " ); //$NON-NLS-1$
+ sb.append( " int aField1; " ); //$NON-NLS-1$
+ sb.append( " int aField2; " ); //$NON-NLS-1$
+ sb.append( "}; " ); //$NON-NLS-1$
+ sb.append( "void foo(){" ); //$NON-NLS-1$
+ sb.append( " struct D d; " ); //$NON-NLS-1$
+ sb.append( " d.a " ); //$NON-NLS-1$
+ sb.append( "}\n" ); //$NON-NLS-1$
+
+ String code = sb.toString();
+ int index = code.indexOf( "d.a" ); //$NON-NLS-1$
+
+ IASTCompletionNode node = parse( code, index + 3 );
+ assertNotNull( node );
+
+ String prefix = node.getPrefix();
+ assertNotNull( prefix );
+ assertEquals( prefix, "a" ); //$NON-NLS-1$
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(2, bindings.length);
+ assertEquals("aField1", ((IField)bindings[0]).getName());
+ assertEquals("aField2", ((IField)bindings[1]).getName());
+ }
+
+ public void testCompletionStructFieldPointer() throws Exception
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("struct Cube { "); //$NON-NLS-1$
+ sb.append(" int nLen; "); //$NON-NLS-1$
+ sb.append(" int nWidth; "); //$NON-NLS-1$
+ sb.append(" int nHeight; "); //$NON-NLS-1$
+ sb.append("}; "); //$NON-NLS-1$
+ sb.append("int volume( struct Cube * pCube ) { "); //$NON-NLS-1$
+ sb.append(" pCube->SP "); //$NON-NLS-1$
+
+ String code = sb.toString();
+ IASTCompletionNode node = parse( code, code.indexOf("SP")); //$NON-NLS-1$
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(3, bindings.length);
+ assertEquals("nHeight", ((IField)bindings[0]).getName());
+ assertEquals("nLen", ((IField)bindings[1]).getName());
+ assertEquals("nWidth", ((IField)bindings[2]).getName());
+ }
+
+
+ public void testCompletionParametersAsLocalVariables() throws Exception{
+ StringBuffer sb = new StringBuffer();
+ sb.append( "int foo( int aParameter ){" ); //$NON-NLS-1$
+ sb.append( " int aLocal;" ); //$NON-NLS-1$
+ sb.append( " if( aLocal != 0 ){" ); //$NON-NLS-1$
+ sb.append( " int aBlockLocal;" ); //$NON-NLS-1$
+ sb.append( " a \n" ); //$NON-NLS-1$
+
+ String code = sb.toString();
+ int index = code.indexOf( " a " ); //$NON-NLS-1$
+
+ IASTCompletionNode node = parse( code, index + 2 );
+ assertNotNull( node );
+
+ assertEquals("a", node.getPrefix()); //$NON-NLS-1$
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(3, bindings.length);
+ assertEquals("aBlockLocal", ((IVariable)bindings[0]).getName());
+ assertEquals("aLocal", ((IVariable)bindings[1]).getName());
+ assertEquals("aParameter", ((IVariable)bindings[2]).getName());
+ }
+
+
+ public void testCompletionTypedef() throws Exception{
+ StringBuffer sb = new StringBuffer();
+ sb.append( "typedef int Int; "); //$NON-NLS-1$
+ sb.append( "InSP" ); //$NON-NLS-1$
+
+ String code = sb.toString();
+ int index = code.indexOf( "SP" ); //$NON-NLS-1$
+
+ IASTCompletionNode node = parse( code, index );
+ assertNotNull(node);
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ assertEquals("In", node.getPrefix());
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("Int", ((ITypedef)bindings[0]).getName());
+ }
+
+ public void testCompletion() throws Exception
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("#define GL_T 0x2001\n"); //$NON-NLS-1$
+ sb.append("#define GL_TRUE 0x1\n"); //$NON-NLS-1$
+ sb.append("typedef unsigned char GLboolean;\n"); //$NON-NLS-1$
+ sb.append("static GLboolean should_rotate = GL_T"); //$NON-NLS-1$
+
+ String code = sb.toString();
+
+ int index = code.indexOf("= GL_T"); //$NON-NLS-1$
+
+ IASTCompletionNode node = parse( code, index + 6);
+ assertNotNull(node);
+
+ assertEquals("GL_T", node.getPrefix()); //$NON-NLS-1$
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+ }
+
+ public void testCompletionInTypeDef() throws Exception{
+ StringBuffer sb = new StringBuffer();
+ sb.append( "struct A { int name; }; \n" ); //$NON-NLS-1$
+ sb.append( "typedef struct A * PA; \n" ); //$NON-NLS-1$
+ sb.append( "int main() { \n" ); //$NON-NLS-1$
+ sb.append( " PA a; \n" ); //$NON-NLS-1$
+ sb.append( " a->SP \n" ); //$NON-NLS-1$
+ sb.append( "} \n" ); //$NON-NLS-1$
+
+ String code = sb.toString();
+ int index = code.indexOf("SP"); //$NON-NLS-1$
+
+ IASTCompletionNode node = parse( code, index );
+ assertNotNull( node );
+
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("name", ((IField)bindings[0]).getName());
+ }
+
+
+ public void _testCompletionFunctionCall() throws Exception
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "struct A { \n" ); //$NON-NLS-1$
+ sb.append( " int f2; \n" ); //$NON-NLS-1$
+ sb.append( " int f4; \n" ); //$NON-NLS-1$
+ sb.append( "}; \n" ); //$NON-NLS-1$
+ sb.append( "const A * foo(){} \n" ); //$NON-NLS-1$
+ sb.append( "void main( ) \n" ); //$NON-NLS-1$
+ sb.append( "{ \n" ); //$NON-NLS-1$
+ sb.append( " foo()->SP \n" ); //$NON-NLS-1$
+
+ String code = sb.toString();
+ int index = code.indexOf( "SP" ); //$NON-NLS-1$
+
+ IASTCompletionNode node = parse( code, index );
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(2, bindings.length);
+ assertEquals("f2", ((IField)bindings[0]).getName());
+ assertEquals("f4", ((IField)bindings[1]).getName());
+ }
+
+
+ public void _testCompletionSizeof() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "int f() {\n" ); //$NON-NLS-1$
+ sb.append( "short blah;\n" ); //$NON-NLS-1$
+ sb.append( "int x = sizeof(bl" ); //$NON-NLS-1$
+
+ String code = sb.toString();
+ int index = code.indexOf( "of(bl" ); //$NON-NLS-1$
+
+ IASTCompletionNode node = parse( code, index + 5);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("blah", ((IVariable)bindings[0]).getName());
+ }
+
+
+ public void testCompletionForLoop() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "int f() {\n" ); //$NON-NLS-1$
+ sb.append( " int biSizeImage = 5;\n" ); //$NON-NLS-1$
+ sb.append( "for (int i = 0; i < bi " ); //$NON-NLS-1$
+ String code = sb.toString();
+
+ int index = code.indexOf("< bi");
+
+ IASTCompletionNode node = parse( code, index + 4);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("biSizeImage", ((IVariable)bindings[0]).getName());
+ }
+
+
+
+ public void testCompletionStructPointer() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append(" struct Temp { char * total; };" );
+ sb.append(" int f(struct Temp * t) {" );
+ sb.append(" t->t[5] = t->" );
+ String code = sb.toString();
+
+ int index = code.indexOf("= t->");
+
+ IASTCompletionNode node = parse( code, index + 5);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(1, bindings.length);
+ assertEquals("total", ((IVariable)bindings[0]).getName());
+ }
+
+
+ public void testCompletionEnum() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "typedef int DWORD;\n" ); //$NON-NLS-1$
+ sb.append( "typedef char BYTE;\n"); //$NON-NLS-1$
+ sb.append( "#define MAKEFOURCC(ch0, ch1, ch2, ch3) \\\n"); //$NON-NLS-1$
+ sb.append( "((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \\\n"); //$NON-NLS-1$
+ sb.append( "((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))\n"); //$NON-NLS-1$
+ sb.append( "enum e {\n"); //$NON-NLS-1$
+ sb.append( "blah1 = 5,\n"); //$NON-NLS-1$
+ sb.append( "blah2 = MAKEFOURCC('a', 'b', 'c', 'd'),\n"); //$NON-NLS-1$
+ sb.append( "blah3\n"); //$NON-NLS-1$
+ sb.append( "};\n"); //$NON-NLS-1$
+ sb.append( "e mye = bl\n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ int index = code.indexOf("= bl");
+
+ IASTCompletionNode node = parse( code, index + 4);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(3, bindings.length);
+ assertEquals("blah1", ((IEnumerator)bindings[0]).getName());
+ assertEquals("blah2", ((IEnumerator)bindings[1]).getName());
+ assertEquals("blah3", ((IEnumerator)bindings[2]).getName());
+ }
+
+
+ public void testCompletionStructArray() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "struct packet { int a; int b; };\n" ); //$NON-NLS-1$
+ sb.append( "struct packet buffer[5];\n" ); //$NON-NLS-1$
+ sb.append( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
+ sb.append( " buffer[2]." ); //$NON-NLS-1$
+ String code = sb.toString();
+
+ int index = code.indexOf("[2].");
+
+ IASTCompletionNode node = parse( code, index + 4);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ IBinding[] bindings = getBindings(names);
+
+ assertEquals(2, bindings.length);
+ assertEquals("a", ((IField)bindings[0]).getName());
+ assertEquals("b", ((IField)bindings[1]).getName());
+ }
+
+
+ public void testCompletionPreprocessorDirective() throws Exception {
+ IASTCompletionNode node = parse("#", 1);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+
+ assertEquals("#", node.getPrefix());
+ }
+
+ public void testCompletionPreprocessorMacro() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "#define AMACRO 99 \n");
+ sb.append( "int main() { \n");
+ sb.append( " int AVAR; \n");
+ sb.append( " int x = A \n");
+ String code = sb.toString();
+
+ int index = code.indexOf("= A");
+
+ IASTCompletionNode node = parse( code, index + 3);
+ assertNotNull( node );
+
+ IASTName[] names = node.getNames();
+ assertEquals(1, names.length);
+ assertEquals("A", node.getPrefix());
+ }
+
+
+ public void testCompletionInsidePreprocessorDirective() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "#define MAC1 99 \n");
+ sb.append( "#define MAC2 99 \n");
+ sb.append( "#ifdef MA");
+ String code = sb.toString();
+
+ int index = code.length();
+
+ IASTCompletionNode node = parse( code, index );
+ assertNotNull( node );
+
+ assertEquals("MA", node.getPrefix());
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationInclusionTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationInclusionTests.java
new file mode 100644
index 00000000000..19798739bee
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationInclusionTests.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import java.util.Collections;
+
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.ParserUtil;
+import org.eclipse.cdt.core.parser.tests.ast2.DOMLocationInclusionTests;
+import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
+import org.eclipse.core.resources.IFile;
+
+public class C99DOMLocationInclusionTests extends DOMLocationInclusionTests {
+
+ public C99DOMLocationInclusionTests() {
+ }
+
+ public C99DOMLocationInclusionTests(String name, Class className) {
+ super(name, className);
+ }
+
+ public C99DOMLocationInclusionTests(String name) {
+ super(name);
+ }
+
+ protected IASTTranslationUnit parse(IFile code, IScannerInfo s)
+ throws Exception {
+
+ CodeReader codeReader = new CodeReader(code.getLocation().toOSString());
+ BaseExtensibleLanguage lang = getLanguage();
+ IASTTranslationUnit tu = lang.getASTTranslationUnit(codeReader, s, SavedCodeReaderFactory.getInstance(), null, BaseExtensibleLanguage.OPTION_ADD_COMMENTS, ParserUtil.getParserLogService());
+
+ return tu;
+ }
+
+ protected IASTTranslationUnit parse(IFile code) throws Exception {
+
+ return parse(code, new ExtendedScannerInfo());
+ }
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationMacroTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationMacroTests.java
new file mode 100644
index 00000000000..5fdd7cfc71c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationMacroTests.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTMacroExpansion;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.DOMLocationMacroTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99DOMLocationMacroTests extends DOMLocationMacroTests {
+
+
+ public C99DOMLocationMacroTests() {
+ super();
+ }
+
+
+ public C99DOMLocationMacroTests(String name) {
+ super(name);
+ }
+
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ if(lang == ParserLanguage.C) {
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+ else
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+ /**
+ * Tests GCC specific stuff, not applicable at this point
+ */
+ public void testStdioBug() throws ParserException {
+ try {
+ super.testStdioBug();
+ fail();
+ }
+ catch(Throwable e) { }
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationTests.java
new file mode 100644
index 00000000000..fe81bddc2fb
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMLocationTests.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.DOMLocationTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99DOMLocationTests extends DOMLocationTests {
+
+ public C99DOMLocationTests() { }
+ public C99DOMLocationTests(String name) { super(name); }
+
+ @Override
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems )
+ throws ParserException {
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+ // this one fails because the C99 parser does error recovery differently
+ public void test162180_1() throws Exception {
+ try {
+ super.test162180_1();
+ fail();
+ }
+ catch(AssertionFailedError e) {}
+
+ }
+
+ public void test162180_3() throws Exception {
+ try {
+ super.test162180_3();
+ fail();
+ }
+ catch(AssertionFailedError e) {}
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMPreprocessorInformationTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMPreprocessorInformationTest.java
new file mode 100644
index 00000000000..46e49449448
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DOMPreprocessorInformationTest.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.DOMPreprocessorInformationTest;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99DOMPreprocessorInformationTest extends DOMPreprocessorInformationTest {
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ //if(lang != ParserLanguage.C)
+ // return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DigraphTrigraphTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DigraphTrigraphTests.java
new file mode 100644
index 00000000000..9065c0ab3d6
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99DigraphTrigraphTests.java
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import junit.framework.TestCase;
+
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+
+public class C99DigraphTrigraphTests extends TestCase {
+
+
+ public C99DigraphTrigraphTests() { }
+ public C99DigraphTrigraphTests(String name) { super(name); }
+
+
+ protected IASTTranslationUnit parse(String code) {
+ return ParseHelper.parse(code, getLanguage(), true);
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+ public void testTrigraphSequences() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("??=define SIZE ??/ \n"); // trigraph used as backslash to ignore newline
+ sb.append("99 \n");
+ sb.append("int main(void)??< \n");
+ sb.append(" int arr??(SIZE??); \n");
+ sb.append(" arr??(4??) = '0' - (??-0 ??' 1 ??! 2); \n");
+ sb.append(" printf(\"%c??/n\", arr??(4??)); \n");
+ sb.append("??> \n");
+ String code = sb.toString();
+
+ IASTTranslationUnit tu = parse(code);
+ assertNotNull(tu);
+
+ IASTPreprocessorStatement[] defines = tu.getAllPreprocessorStatements();
+ assertEquals(1, defines.length);
+ IASTPreprocessorMacroDefinition macro = (IASTPreprocessorMacroDefinition)defines[0];
+ assertEquals("SIZE", macro.getName().toString());
+ //assertEquals("99", macro.getExpansion());
+
+ IASTFunctionDefinition main = (IASTFunctionDefinition)tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) main.getBody();
+ IASTStatement[] statements = body.getStatements();
+ assertEquals(3, statements.length);
+
+ // int arr??(SIZE??);
+ IASTSimpleDeclaration arr = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[0]).getDeclaration();
+ IASTArrayDeclarator arr_decl = (IASTArrayDeclarator)arr.getDeclarators()[0];
+ IASTArrayModifier modifier = arr_decl.getArrayModifiers()[0];
+ IASTLiteralExpression lit = (IASTLiteralExpression)modifier.getConstantExpression();
+ assertEquals(IASTLiteralExpression.lk_integer_constant, lit.getKind());
+
+ // arr??(4??) = '0' - (??-0 ??' 1 ??! 2);
+ IASTBinaryExpression expr = (IASTBinaryExpression)((IASTExpressionStatement)statements[1]).getExpression();
+ assertEquals(IASTBinaryExpression.op_assign, expr.getOperator());
+ IASTArraySubscriptExpression arr_op = (IASTArraySubscriptExpression)expr.getOperand1();
+ assertEquals("4", ((IASTLiteralExpression)arr_op.getSubscriptExpression()).toString());
+ IASTBinaryExpression cond = (IASTBinaryExpression)((IASTUnaryExpression)((IASTBinaryExpression)expr.getOperand2()).getOperand2()).getOperand();
+ assertEquals(IASTBinaryExpression.op_binaryOr, cond.getOperator());
+ IASTBinaryExpression cond2 = (IASTBinaryExpression)cond.getOperand1();
+ assertEquals(IASTBinaryExpression.op_binaryXor, cond2.getOperator());
+ IASTUnaryExpression not = (IASTUnaryExpression)cond2.getOperand1();
+ assertEquals(IASTUnaryExpression.op_tilde, not.getOperator());
+
+ // printf(\"%c??/n\", arr??(4??));
+ IASTFunctionCallExpression expr2 = (IASTFunctionCallExpression)((IASTExpressionStatement)statements[2]).getExpression();
+ IASTExpressionList params = (IASTExpressionList) expr2.getParameterExpression();
+ IASTArraySubscriptExpression arr_op2 = (IASTArraySubscriptExpression)params.getExpressions()[1];
+ assertEquals("4", ((IASTLiteralExpression)arr_op2.getSubscriptExpression()).toString());
+ }
+
+
+ public void testTrigraphEscapeSequences() {
+ // a ??/ trigraph should act just like a backslash in a string literal
+ StringBuffer sb = new StringBuffer();
+ sb.append("int main(void)??< \n");
+ sb.append(" char str[] = \"??/\"??/n\"; \n");
+ sb.append(" char c = '??/u0000'; \n");
+ sb.append("??> \n");
+ String code = sb.toString();
+ parse(code); // will throw an exception if there are parse errors
+ }
+
+
+ public void testDigraphSequences() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("%:define join(a, b) a %:%: b \n");
+ sb.append("int main() <% \n");
+ sb.append(" int arr<:5:>; \n");
+ sb.append("%> \n");
+ String code = sb.toString();
+
+ IASTTranslationUnit tu = parse(code); // will throw an exception if there are parse errors
+
+ IASTFunctionDefinition main = (IASTFunctionDefinition)tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) main.getBody();
+ IASTStatement[] statements = body.getStatements();
+ assertEquals(1, statements.length);
+
+ IASTSimpleDeclaration arr = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[0]).getDeclaration();
+ IASTArrayDeclarator arr_decl = (IASTArrayDeclarator)arr.getDeclarators()[0];
+ IASTArrayModifier modifier = arr_decl.getArrayModifiers()[0];
+ IASTLiteralExpression lit = (IASTLiteralExpression)modifier.getConstantExpression();
+ assertEquals("5", lit.toString());
+
+ }
+
+
+ public void testTrigraphAndDigraphSequecesInPreprocessorDirectives() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("%:define join1(a, b) a %:%: b \n");
+ sb.append("%:define str1(a) %: a \n");
+ sb.append("??=define join2(a, b) a ??=??= b \n");
+ sb.append("??=define str2(a) ??= a \n");
+ sb.append("int main() <% \n");
+ sb.append(" int join1(x, y) = str1(its all good); \n");
+ sb.append(" int join2(a, b) = str2(its still good); \n");
+ sb.append("%> \n");
+ String code = sb.toString();
+
+ IASTTranslationUnit tu = parse(code); // will throw an exception if there are parse errors
+
+ IASTFunctionDefinition main = (IASTFunctionDefinition)tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) main.getBody();
+ IASTStatement[] statements = body.getStatements();
+ assertEquals(2, statements.length);
+
+ IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[0]).getDeclaration();
+ IASTDeclarator declarator1 = decl1.getDeclarators()[0];
+ assertEquals("xy", declarator1.getName().toString());
+ IASTLiteralExpression expr1 = (IASTLiteralExpression)((IASTInitializerExpression)declarator1.getInitializer()).getExpression();
+ assertEquals(IASTLiteralExpression.lk_string_literal, expr1.getKind());
+ assertEquals("\"its all good\"", expr1.toString());
+
+ IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration)((IASTDeclarationStatement)statements[1]).getDeclaration();
+ IASTDeclarator declarator2 = decl2.getDeclarators()[0];
+ assertEquals("ab", declarator2.getName().toString());
+ IASTLiteralExpression expr2 = (IASTLiteralExpression)((IASTInitializerExpression)declarator2.getInitializer()).getExpression();
+ assertEquals(IASTLiteralExpression.lk_string_literal, expr2.getKind());
+ assertEquals("its still good", expr2.toString());
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99GCCTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99GCCTests.java
new file mode 100644
index 00000000000..e8870b00943
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99GCCTests.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.GCCTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99GCCTests extends GCCTests {
+
+ public C99GCCTests() {}
+ public C99GCCTests(String name) { super(name); }
+
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99KnRTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99KnRTests.java
new file mode 100644
index 00000000000..aabf43559b6
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99KnRTests.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2KnRTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+/**
+ * @author Mike Kucera
+ */
+public class C99KnRTests extends AST2KnRTests {
+
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ if(lang == ParserLanguage.C) {
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+ else
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+ }
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+ // TODO: Failing tests, will get around to fixing these bugs
+
+ public void testKRCProblem3() throws Exception {
+ try {
+ super.testKRCProblem3();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+ public void testKRCProblem4() throws Exception {
+ try {
+ super.testKRCProblem4();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+ public void testKRCProblem5() throws Exception {
+ try {
+ super.testKRCProblem5();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+ public void testKRCProblem2() throws Exception {
+ try {
+ super.testKRCProblem2();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99SelectionParseTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99SelectionParseTest.java
new file mode 100644
index 00000000000..54702ac3f87
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99SelectionParseTest.java
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import java.util.Collections;
+
+import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.ScannerInfo;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2SelectionParseTest;
+import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+
+public class C99SelectionParseTest extends AST2SelectionParseTest {
+
+ public C99SelectionParseTest() {}
+ public C99SelectionParseTest(String name) { super(name); }
+
+ protected IASTNode parse(String code, ParserLanguage lang, int offset, int length) throws ParserException {
+ if(lang == ParserLanguage.C)
+ return parse(code, lang, false, false, offset, length);
+ else
+ return super.parse(code, lang, offset, length);
+ }
+
+ protected IASTNode parse(IFile file, ParserLanguage lang, int offset, int length) throws ParserException {
+ if(lang == ParserLanguage.C) {
+ IASTTranslationUnit tu = parse(file, lang, false, false);
+ return tu.selectNodeForLocation(tu.getFilePath(), offset, length);
+ }
+ else
+ return super.parse(file, lang, offset, length);
+ }
+
+ protected IASTNode parse(String code, ParserLanguage lang, int offset, int length, boolean expectedToPass) throws ParserException {
+ if(lang == ParserLanguage.C)
+ return parse(code, lang, false, expectedToPass, offset, length);
+ else
+ return super.parse(code, lang, offset, length, expectedToPass);
+ }
+
+ protected IASTNode parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, int offset, int length) throws ParserException {
+ if(lang == ParserLanguage.C) {
+ IASTTranslationUnit tu = ParseHelper.parse(code, getLanguage(), useGNUExtensions, expectNoProblems, 0);
+ return tu.selectNodeForLocation(tu.getFilePath(), offset, length);
+ }
+ else
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems, offset, length);
+ }
+
+ protected IASTTranslationUnit parse( IFile file, ParserLanguage lang, IScannerInfo scanInfo, boolean useGNUExtensions, boolean expectNoProblems )
+ throws ParserException {
+
+ if(lang != ParserLanguage.C)
+ return super.parse(file, lang, useGNUExtensions, expectNoProblems);
+
+ String fileName = file.getLocation().toOSString();
+ ICodeReaderFactory fileCreator = SavedCodeReaderFactory.getInstance();
+ CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(fileName);
+ return ParseHelper.parse(reader, getLanguage(), scanInfo, fileCreator, expectNoProblems, true, 0);
+ }
+
+ protected IASTTranslationUnit parse( IFile file, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems )
+ throws ParserException {
+ return parse(file, lang, new ScannerInfo(), useGNUExtensions, expectNoProblems);
+ }
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+// public void testBug193185_IncludeNext() throws Exception
+// {
+// String baseFile = "int zero; \n#include \"foo.h\""; //$NON-NLS-1$
+// String i1Next = "int one; \n#include_next <foo.h>"; //$NON-NLS-1$
+// String i2Next = "int two; \n#include_next \"foo.h\""; //$NON-NLS-1$
+// String i3Next = "int three; \n"; //$NON-NLS-1$
+//
+//
+// IFile base = importFile( "base.c", baseFile ); //$NON-NLS-1$
+// importFile( "foo.h", i1Next ); //$NON-NLS-1$
+// IFolder twof = importFolder("two"); //$NON-NLS-1$
+// IFolder threef = importFolder("three"); //$NON-NLS-1$
+// importFile( "two/foo.h", i2Next ); //$NON-NLS-1$
+// importFile( "three/foo.h", i3Next ); //$NON-NLS-1$
+//
+// String[] path = new String[] {
+// twof.getRawLocation().toOSString(),
+// threef.getRawLocation().toOSString()
+// };
+//
+// IScannerInfo scannerInfo = new ExtendedScannerInfo( Collections.EMPTY_MAP, path, new String[0], path );
+//
+// IASTTranslationUnit tu = parse(base, ParserLanguage.C, scannerInfo, false, true);
+//
+// IASTDeclaration[] decls = tu.getDeclarations();
+// assertEquals(4, decls.length);
+//
+// IASTSimpleDeclaration declaration = (IASTSimpleDeclaration)decls[0];
+// assertEquals("zero", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
+//
+// declaration = (IASTSimpleDeclaration)decls[1];
+// assertEquals("one", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
+//
+// declaration = (IASTSimpleDeclaration)decls[2];
+// assertEquals("two", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
+//
+// declaration = (IASTSimpleDeclaration)decls[3];
+// assertEquals("three", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
+// }
+//
+//
+// public void testBug193366() throws Exception
+// {
+// String baseFile =
+// "#define FOOH <foo.h> \n" + //$NON-NLS-1$
+// "#define bar blahblahblah \n" + //$NON-NLS-1$
+// "#include FOOH \n" + //$NON-NLS-1$
+// "#include <bar.h> \n"; //$NON-NLS-1$
+//
+// String fooFile = "int x; \n"; //$NON-NLS-1$
+// String barFile = "int y; \n"; //$NON-NLS-1$
+//
+//
+// IFile base = importFile( "base.c", baseFile ); //$NON-NLS-1$
+// IFolder include = importFolder("inc"); //$NON-NLS-1$
+// importFile( "inc/foo.h", fooFile ); //$NON-NLS-1$
+// importFile( "inc/bar.h", barFile ); //$NON-NLS-1$
+//
+// String[] path = new String[] { include.getRawLocation().toOSString() };
+// IScannerInfo scannerInfo = new ExtendedScannerInfo( Collections.EMPTY_MAP, path, new String[0], path );
+//
+// IASTTranslationUnit tu = parse(base, ParserLanguage.C, scannerInfo, false, true);
+//
+// IASTDeclaration[] decls = tu.getDeclarations();
+// assertEquals(2, decls.length);
+//
+// IASTSimpleDeclaration declaration = (IASTSimpleDeclaration)decls[0];
+// assertEquals("x", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
+//
+// declaration = (IASTSimpleDeclaration)decls[1];
+// assertEquals("y", declaration.getDeclarators()[0].getName().toString()); //$NON-NLS-1$
+// }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99SpecTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99SpecTests.java
new file mode 100644
index 00000000000..47cf41b902b
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99SpecTests.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2CSpecTest;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99SpecTests extends AST2CSpecTest {
+
+ public C99SpecTests() { }
+ public C99SpecTests(String name) { super(name); }
+
+
+ /**
+ * Only parses it as C actually
+ * @throws ParserException
+ */
+ protected void parseCandCPP( String code, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
+ parse(code, ParserLanguage.C, checkBindings, expectedProblemBindings);
+ parse(code, ParserLanguage.CPP, checkBindings, expectedProblemBindings);
+ }
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
+ if(lang == ParserLanguage.C)
+ return ParseHelper.parse(code, getLanguage(), true, checkBindings, expectedProblemBindings );
+ else
+ return super.parse(code, lang, checkBindings, expectedProblemBindings);
+ }
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+ //Assignment statements cannot exists outside of a function body
+ @Override
+ public void test5_1_2_3s15() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("//#include <stdio.h>\n"); //$NON-NLS-1$
+ buffer.append("int foo() { \n"); //$NON-NLS-1$
+ buffer.append("int sum;\n"); //$NON-NLS-1$
+ buffer.append("char *p;\n"); //$NON-NLS-1$
+ buffer.append("sum = sum * 10 - '0' + (*p++ = getchar());\n"); //$NON-NLS-1$
+ buffer.append("sum = (((sum * 10) - '0') + ((*(p++)) = (getchar())));\n"); //$NON-NLS-1$
+ buffer.append("} \n"); //$NON-NLS-1$
+ parseCandCPP(buffer.toString(), false, 0);
+ }
+
+
+ // offsetof does not work if <stddef.h> is not included!
+ @Override
+ public void test6_7_2_1s17() throws Exception {
+ try {
+ super.test6_7_2_1s17();
+ } catch(AssertionFailedError _) {
+ return;
+ }
+
+ fail();
+ }
+
+
+ // Tests from AST2CSpecFailingTests
+
+ /**
+ * TODO: This one fails, it can't resolve one of the bindings (const t) I think
+ *
+ [--Start Example(C 6.7.7-6):
+ typedef signed int t;
+ typedef int plain;
+ struct tag {
+ unsigned t:4;
+ const t:5;
+ plain r:5;
+ };
+ t f(t (t));
+ long t;
+ --End Example]
+ */
+ public void test6_7_7s6() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("typedef signed int t;\n"); //$NON-NLS-1$
+ buffer.append("typedef int plain;\n"); //$NON-NLS-1$
+ buffer.append("struct tag {\n"); //$NON-NLS-1$
+ buffer.append("unsigned t:4;\n"); //$NON-NLS-1$
+ buffer.append("const t:5;\n"); //$NON-NLS-1$
+ buffer.append("plain r:5;\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("t f(t (t));\n"); //$NON-NLS-1$
+ buffer.append("long t;\n"); //$NON-NLS-1$
+
+ try {
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
+ } catch(AssertionFailedError _) {
+ // there should be an error
+ }
+ }
+
+
+
+ /**
+ [--Start Example(C 6.10.3.5-5):
+ #define x 3
+ #define f(a) f(x * (a))
+ #undef x
+ #define x 2
+ #define g f
+ #define z z[0]
+ #define h g(~
+ #define m(a) a(w)
+ #define w 0,1
+ #define t(a) a
+ #define p() int
+ #define q(x) x
+ #define r(x,y) x ## y
+ #define str(x) # x
+ int foo() {
+ p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
+ char c[2][6] = { str(hello), str() };
+ }
+ --End Example]
+ */
+ @Override
+ public void test6_10_3_5s5() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("#define x 3\n"); //$NON-NLS-1$
+ buffer.append("#define f(a) f(x * (a))\n"); //$NON-NLS-1$
+ buffer.append("#undef x\n"); //$NON-NLS-1$
+ buffer.append("#define x 2\n"); //$NON-NLS-1$
+ buffer.append("#define g f\n"); //$NON-NLS-1$
+ buffer.append("#define z z[0]\n"); //$NON-NLS-1$
+ buffer.append("#define h g(~\n"); //$NON-NLS-1$
+ buffer.append("#define m(a) a(w)\n"); //$NON-NLS-1$
+ buffer.append("#define w 0,1\n"); //$NON-NLS-1$
+ buffer.append("#define t(a) a\n"); //$NON-NLS-1$
+ buffer.append("#define p() int\n"); //$NON-NLS-1$
+ buffer.append("#define q(x) x\n"); //$NON-NLS-1$
+ buffer.append("#define r(x,y) x ## y\n"); //$NON-NLS-1$
+ buffer.append("#define str(x) # x\n"); //$NON-NLS-1$
+ buffer.append("int foo() {\n"); //$NON-NLS-1$
+ buffer.append("p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };\n"); //$NON-NLS-1$
+ buffer.append("char c[2][6] = { str(hello), str() };\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
+ //parseCandCPP(buffer.toString(), true, 0);
+ // TODO: this only works on the C99 parser for now
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
+ }
+
+
+ /**
+ [--Start Example(C 6.10.3.5-7):
+ #define t(x,y,z) x ## y ## z
+ int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
+ t(10,,), t(,11,), t(,,12), t(,,) };
+ --End Example]
+ */
+ @Override
+ public void test6_10_3_5s7() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("#define t(x,y,z) x ## y ## z\n"); //$NON-NLS-1$
+ buffer.append("int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),\n"); //$NON-NLS-1$
+ buffer.append("t(10,,), t(,11,), t(,,12), t(,,) };\n"); //$NON-NLS-1$
+
+ // TODO: this only works on the C99 parser for now
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
+ }
+
+ /**
+ * This test seems to be incorrect in AST2SpecTests
+ */
+ @Override
+ public void test4s6() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("#ifdef __STDC_IEC_559__ /* FE_UPWARD defined */\n"); //$NON-NLS-1$
+ buffer.append("fesetround(FE_UPWARD);\n"); //$NON-NLS-1$
+ buffer.append("#endif\n"); //$NON-NLS-1$
+ parseCandCPP(buffer.toString(), false, 0);
+ }
+
+
+ @Override
+ public void test6_7_8s24() throws Exception { // complex isn't declared as a typedef
+ try {
+ super.test6_7_8s24();
+ fail();
+ } catch(AssertionFailedError _) { }
+ }
+
+
+ @Override
+ public void test6_7_8s34() throws Exception { // div_t isn't declared as a typedef
+ try {
+ super.test6_7_8s34();
+ fail();
+ } catch(AssertionFailedError _) { }
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99TaskParserTest.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99TaskParserTest.java
new file mode 100644
index 00000000000..9de4d8122b6
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99TaskParserTest.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.TaskParserTest;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99TaskParserTest extends TaskParserTest {
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99Tests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99Tests.java
new file mode 100644
index 00000000000..399ba88e1ab
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99Tests.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2Tests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+
+/**
+ *
+ * @author Mike Kucera
+ *
+ */
+public class C99Tests extends AST2Tests {
+
+ public static TestSuite suite() {
+ return suite(C99Tests.class);
+ }
+
+ public C99Tests(String name) {
+ super(name);
+ }
+
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+ public void testMultipleHashHash() throws Exception {
+ String code = "#define TWICE(a) int a##tera; int a##ther; \n TWICE(pan)";
+ parseAndCheckBindings(code, ParserLanguage.C);
+ }
+
+
+ public void testBug191279() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append(" /**/ \n");
+ sb.append("# define YO 99 /**/ \n");
+ sb.append("# undef YO /**/ ");
+ sb.append(" /* $ */ ");
+ String code = sb.toString();
+ parseAndCheckBindings(code, ParserLanguage.C);
+ }
+
+
+ public void testBug191324() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ sb.append("int x$y = 99; \n");
+ sb.append("int $q = 100; \n"); // can use $ as first character in identifier
+ sb.append("#ifndef SS$_INVFILFOROP \n");
+ sb.append("int z; \n");
+ sb.append("#endif \n");
+ String code = sb.toString();
+ parseAndCheckBindings(code, ParserLanguage.C);
+ }
+
+ public void testBug192009_implicitInt() throws Exception {
+ String code = "main() { int x; }";
+ IASTTranslationUnit tu = parse(code, ParserLanguage.C, false, true);
+
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(1, declarations.length);
+
+ IASTFunctionDefinition main = (IASTFunctionDefinition) declarations[0];
+ ICASTSimpleDeclSpecifier declSpec = (ICASTSimpleDeclSpecifier) main.getDeclSpecifier();
+ assertEquals(0, declSpec.getType());
+
+
+ assertEquals("main", main.getDeclarator().getName().toString());
+ }
+
+
+
+ public void testBug93980() { // some wierd gcc extension I think
+ try {
+ super.testBug93980();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+
+ public void testBug95866() { // gcc extension
+ try {
+ super.testBug95866();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+
+ public void testBug80171() throws Exception { // implicit int not supported
+ try {
+ super.testBug80171();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+
+ public void testBug196468_emptyArrayInitializer() { // empty array initializer is a gcc extension
+ try {
+ super.testBug196468_emptyArrayInitializer();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+
+ public void testBug75340() { // not legal c99
+ try {
+ super.testBug75340();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+
+ public void test92791() { // I think the test is wrong, the second code snippet contains a redeclaration
+ try {
+ super.test92791();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+
+
+ public void testBug192165() { // gcc extension: typeof
+ try {
+ super.testBug192165();
+ fail();
+ } catch(Throwable _) { }
+ }
+
+
+
+ public void testBug191450_attributesInBetweenPointers() { // gcc extension: attributes
+ try {
+ super.testBug191450_attributesInBetweenPointers();
+ fail();
+ } catch(Throwable _) { }
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99UtilOldTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99UtilOldTests.java
new file mode 100644
index 00000000000..576b884d165
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99UtilOldTests.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2UtilOldTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99UtilOldTests extends AST2UtilOldTests {
+
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+
+
+ public void testCastExpression() throws Exception { // A not typedefed
+ try {
+ super.testCastExpression();
+ fail();
+ } catch(AssertionFailedError _) {}
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99UtilTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99UtilTests.java
new file mode 100644
index 00000000000..f63eb9f9277
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/C99UtilTests.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.c99.C99Language;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.tests.ast2.AST2UtilTests;
+import org.eclipse.cdt.internal.core.parser.ParserException;
+
+public class C99UtilTests extends AST2UtilTests {
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang ) throws ParserException {
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang);
+
+ return parse(code, lang, false, true );
+ }
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions ) throws ParserException {
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang, useGNUExtensions);
+
+ return parse( code, lang, useGNUExtensions, true );
+ }
+
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
+ if(lang != ParserLanguage.C)
+ return super.parse(code, lang, useGNUExtensions, expectNoProblems);
+
+ return ParseHelper.parse(code, getLanguage(), expectNoProblems);
+ }
+
+
+ protected BaseExtensibleLanguage getLanguage() {
+ return C99Language.getDefault();
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/ParseHelper.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/ParseHelper.java
new file mode 100644
index 00000000000..2c4d2e89e33
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/ParseHelper.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.model.AbstractLanguage;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.ParserUtil;
+import org.eclipse.cdt.core.parser.ScannerInfo;
+import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Utility methods for parsing test code using the C99 LPG parser.
+ *
+ * @author Mike Kucera
+ */
+public class ParseHelper {
+
+ static int testsRun = 0;
+
+ private static class C99NameResolver extends ASTVisitor {
+ {
+ shouldVisitNames = true;
+ }
+ public int numProblemBindings=0;
+ public int numNullBindings=0;
+
+ public int visit( IASTName name ){
+ IBinding binding = name.resolveBinding();
+ if (binding instanceof IProblemBinding)
+ numProblemBindings++;
+ if (binding == null)
+ numNullBindings++;
+ return PROCESS_CONTINUE;
+ }
+ }
+
+
+
+ public static IASTTranslationUnit parse(char[] code, BaseExtensibleLanguage lang, boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings) {
+ CodeReader codeReader = new CodeReader(code);
+ return parse(codeReader, lang, new ScannerInfo(), null, expectNoProblems, checkBindings, expectedProblemBindings);
+ }
+
+ public static IASTTranslationUnit parse(String code, BaseExtensibleLanguage lang, boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings) {
+ return parse(code.toCharArray(), lang, expectNoProblems, checkBindings, expectedProblemBindings);
+ }
+
+
+ public static IASTTranslationUnit parse(String code, BaseExtensibleLanguage lang, boolean expectNoProblems) {
+ return parse(code, lang, expectNoProblems, false, 0);
+ }
+
+
+
+ public static IASTTranslationUnit parse(CodeReader codeReader, BaseExtensibleLanguage language, IScannerInfo scanInfo,
+ ICodeReaderFactory fileCreator, boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings) {
+ testsRun++;
+
+ IASTTranslationUnit tu;
+ try {
+ tu = language.getASTTranslationUnit(codeReader, scanInfo, fileCreator, null, ParserUtil.getParserLogService());
+ } catch (CoreException e) {
+ throw new AssertionFailedError(e.toString());
+ }
+
+ // should parse correctly first before we look at the bindings
+ if(expectNoProblems )
+ {
+ if (CVisitor.getProblems(tu).length != 0) {
+ throw new AssertionFailedError(" CVisitor has AST Problems " ); //$NON-NLS-1$
+ }
+
+ // TODO: actually collect preprocessor problems
+ if (tu.getPreprocessorProblems().length != 0) {
+ throw new AssertionFailedError(" C TranslationUnit has Preprocessor Problems " ); //$NON-NLS-1$
+ }
+ }
+
+ // resolve all bindings
+ if (checkBindings) {
+
+ C99NameResolver res = new C99NameResolver();
+ tu.accept( res );
+ if (res.numProblemBindings != expectedProblemBindings )
+ throw new AssertionFailedError("Expected " + expectedProblemBindings + " problem(s), encountered " + res.numProblemBindings ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+
+ return tu;
+ }
+
+
+ public static IASTTranslationUnit commentParse(String code, BaseExtensibleLanguage language) {
+ CodeReader codeReader = new CodeReader(code.toCharArray());
+ IASTTranslationUnit tu;
+ try {
+ tu = language.getASTTranslationUnit(codeReader, new ScannerInfo(), null, null, AbstractLanguage.OPTION_ADD_COMMENTS, ParserUtil.getParserLogService());
+ } catch (CoreException e) {
+ throw new AssertionFailedError(e.toString());
+ }
+ return tu;
+ }
+
+ public static IASTCompletionNode getCompletionNode(String code, BaseExtensibleLanguage lang) {
+ return getCompletionNode(code, lang, code.length());
+ }
+
+
+ public static IASTCompletionNode getCompletionNode(String code, BaseExtensibleLanguage language, int offset) {
+ CodeReader reader = new CodeReader(code.toCharArray());
+ return language.getCompletionNode(reader, new ScannerInfo(), null, null, ParserUtil.getParserLogService(), offset);
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/ParserTestSuite.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/ParserTestSuite.java
new file mode 100644
index 00000000000..3927c09a930
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/c99/ParserTestSuite.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.lrparser.tests.c99;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class ParserTestSuite extends TestSuite {
+
+ // TODO: the following test are not being reused
+ //
+ // DOMGCCSelectionParseExtensionsTest
+ // DOMSelectionParseTest
+ // GCCCompleteParseExtensionsTest
+ // QuickParser2Tests
+ //
+ // and perhaps others
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(C99Tests.class); // has some tests that do fail
+
+ suite.addTestSuite(C99SpecTests.class); // a couple of failures
+ suite.addTestSuite(C99KnRTests.class); // mostly fail due to ambiguities
+
+ // The majority of the content assist test are in the ui tests plugin
+ suite.addTestSuite(C99CompletionBasicTest.class);
+ // this one still has a lot of failing tests though
+ suite.addTestSuite(C99SelectionParseTest.class);
+
+ suite.addTestSuite(C99DOMLocationInclusionTests.class);
+ suite.addTestSuite(C99DOMLocationTests.class);
+ suite.addTestSuite(C99DOMLocationMacroTests.class);
+ suite.addTestSuite(C99DOMPreprocessorInformationTest.class);
+ suite.addTestSuite(C99CommentTests.class);
+ suite.addTestSuite(C99DigraphTrigraphTests.class);
+ suite.addTestSuite(C99GCCTests.class);
+ suite.addTestSuite(C99UtilOldTests.class);
+ suite.addTestSuite(C99UtilTests.class);
+ suite.addTestSuite(C99CompleteParser2Tests.class);
+ suite.addTestSuite(C99TaskParserTest.class);
+
+
+ return suite;
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/.classpath b/lrparser/org.eclipse.cdt.core.lrparser/.classpath
new file mode 100644
index 00000000000..751c8f2e504
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/.project b/lrparser/org.eclipse.cdt.core.lrparser/.project
new file mode 100644
index 00000000000..b101bd0e58f
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.core.parser.c99</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sourceforge.metrics.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sourceforge.metrics.nature</nature>
+ </natures>
+</projectDescription>
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/.settings/org.eclipse.jdt.core.prefs b/lrparser/org.eclipse.cdt.core.lrparser/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..96d4911cd62
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Mon Jul 30 15:15:28 EDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF b/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..8d4148969a6
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.1
+Bundle-SymbolicName: org.eclipse.cdt.core.lrparser;singleton:=true
+Bundle-Version: 4.0.1.qualifier
+Bundle-ClassPath: .
+Require-Bundle: org.eclipse.cdt.core,
+ net.sourceforge.lpg.lpgjavaruntime;bundle-version="1.1.0";visibility:=reexport,
+ org.eclipse.core.runtime
+Export-Package: org.eclipse.cdt.core.dom.lrparser,
+ org.eclipse.cdt.core.dom.lrparser.action,
+ org.eclipse.cdt.core.dom.lrparser.action.c99,
+ org.eclipse.cdt.core.dom.lrparser.c99,
+ org.eclipse.cdt.internal.core.dom.lrparser.c99;x-internal:=true,
+ org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings
+Bundle-Localization: plugin
+Bundle-Vendor: %Bundle-Vendor.0
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/about.html b/lrparser/org.eclipse.cdt.core.lrparser/about.html
new file mode 100644
index 00000000000..d7c511887d6
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
+
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 22, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/about.ini b/lrparser/org.eclipse.cdt.core.lrparser/about.ini
new file mode 100644
index 00000000000..b3cd8d70ba9
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/about.ini
@@ -0,0 +1,24 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+
+# Property "aboutText" contains blurb for "About" dialog (translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=eclipse32.gif
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which the
+# welcome page is to be opened.
+# optional
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/about.mappings b/lrparser/org.eclipse.cdt.core.lrparser/about.mappings
new file mode 100644
index 00000000000..0824105e69d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/about.mappings
@@ -0,0 +1,9 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
+# The following should contain the build version.
+# e.g. "0=20020612"
+# This value will be added automaticaly via the build scripts
+0=@build@ \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/about.properties b/lrparser/org.eclipse.cdt.core.lrparser/about.properties
new file mode 100644
index 00000000000..262b4010c35
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/about.properties
@@ -0,0 +1,25 @@
+###############################################################################
+# Copyright (c) 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+# about.properties
+# contains externalized strings for about.ini
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# fill-ins are supplied by about.mappings
+# This file should be translated.
+# NOTE TO TRANSLATOR: Please do not translate the featureVersion variable.
+
+
+blurb=CDT C99 Parser Support\n\
+\n\
+Version: {featureVersion}\n\
+Build id: {0}\n\
+\n\
+(c) Copyright Eclipse contributors and others, 2007. All rights reserved.\n\
+Visit http://www.eclipse.org/cdt
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/build.properties b/lrparser/org.eclipse.cdt.core.lrparser/build.properties
new file mode 100644
index 00000000000..71b26d6c8f3
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/build.properties
@@ -0,0 +1,21 @@
+###############################################################################
+# Copyright (c) 2007 IBM Corporation and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.properties,\
+ plugin.xml,\
+ eclipse32.gif,\
+ about.ini,\
+ about.mappings,\
+ about.properties
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/eclipse32.gif b/lrparser/org.eclipse.cdt.core.lrparser/eclipse32.gif
new file mode 100644
index 00000000000..e6ad7ccd75b
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/eclipse32.gif
Binary files differ
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/plugin.properties b/lrparser/org.eclipse.cdt.core.lrparser/plugin.properties
new file mode 100644
index 00000000000..165e3722a96
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/plugin.properties
@@ -0,0 +1,18 @@
+###############################################################################
+# Copyright (c) 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+Bundle-Name.0 = LR Parser Plug-in
+Bundle-Vendor.0 = Eclipse.org
+Bundle-Name.1 = LR Parser Plug-in
+
+# built-in languages
+language.name.c99= C99
+language.name.isocpp= ISO C++ \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/plugin.xml b/lrparser/org.eclipse.cdt.core.lrparser/plugin.xml
new file mode 100644
index 00000000000..abca5716d74
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/plugin.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension point="org.eclipse.cdt.core.language">
+ <language
+ class="org.eclipse.cdt.core.dom.lrparser.c99.C99Language"
+ id="c99"
+ name="%language.name.c99">
+ </language>
+ <language
+ class="org.eclipse.cdt.core.dom.lrparser.cpp.ISOCPPLanguage"
+ id="isocpp"
+ name="%language.name.isocpp">
+ </language>
+
+ <pdomLinkageFactory
+ class="org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory"
+ id="c99"/>
+
+ <pdomLinkageFactory
+ class="org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory"
+ id="isocpp"/>
+ </extension>
+
+
+
+</plugin>
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/BaseExtensibleLanguage.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/BaseExtensibleLanguage.java
new file mode 100644
index 00000000000..c35084bc969
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/BaseExtensibleLanguage.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser;
+
+import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
+import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
+import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.AbstractLanguage;
+import org.eclipse.cdt.core.model.ICLanguageKeywords;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IParserLogService;
+import org.eclipse.cdt.core.parser.IScanner;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTTranslationUnit;
+import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
+import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
+import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
+import org.eclipse.core.runtime.CoreException;
+
+
+/**
+ * Implementation of the ILanguage extension point,
+ * provides the ability to add LPG based languages to CDT.
+ *
+ * @author Mike Kucera
+ */
+@SuppressWarnings("restriction")
+public abstract class BaseExtensibleLanguage extends AbstractLanguage implements ILanguage, ICLanguageKeywords {
+
+
+ /**
+ * Retrieve the parser (runs after the preprocessor runs).
+ *
+ * Can be overridden in subclasses to provide a different parser
+ * for a language extension.
+ */
+ protected abstract IParser getParser();
+
+
+ /**
+ * A token map is used to map tokens from the DOM preprocessor
+ * to the tokens defined by an LPG parser.
+ */
+ protected abstract ITokenMap getTokenMap();
+
+
+ /**
+ * Normally all the AST nodes are created by the parser, but we
+ * need the root node ahead of time.
+ *
+ * The preprocessor is responsible for creating preprocessor AST nodes,
+ * so the preprocessor needs access to the translation unit so that it can
+ * set the parent pointers on the AST nodes it creates.
+ *
+ * @return an IASTTranslationUnit object thats empty and will be filled in by the parser
+ */
+ protected abstract IASTTranslationUnit createASTTranslationUnit();
+
+
+ /**
+ * Returns the ParserLanguage value that is to be used when creating
+ * an instance of CPreprocessor.
+ *
+ */
+ protected abstract ParserLanguage getParserLanguageForPreprocessor();
+
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPDOMLinkageFactory.class)
+ return new PDOMCLinkageFactory();
+
+ return super.getAdapter(adapter);
+ }
+
+
+
+
+ @SuppressWarnings("nls")
+ @Override
+ public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
+ ICodeReaderFactory fileCreator, IIndex index, int options, IParserLogService log) throws CoreException {
+
+ ILanguage gccLanguage = GCCLanguage.getDefault();
+ IASTTranslationUnit gtu = gccLanguage.getASTTranslationUnit(reader, scanInfo, fileCreator, index, log);
+
+ System.out.println();
+ System.out.println("********************************************************");
+ System.out.println("GCC AST:");
+ DebugUtil.printAST(gtu);
+ System.out.println();
+
+
+
+ //IParseResult parseResult = parse(reader, scanInfo, fileCreator, index, null, null);
+ //IASTTranslationUnit tu = parseResult.getTranslationUnit();
+
+ // TODO temporary
+ IScannerExtensionConfiguration config = new GCCScannerExtensionConfiguration();
+
+ ParserLanguage pl = getParserLanguageForPreprocessor();
+ IScanner preprocessor = new CPreprocessor(reader, scanInfo, pl, log, config, fileCreator);
+ preprocessor.setScanComments((options & OPTION_ADD_COMMENTS) != 0);
+ preprocessor.setComputeImageLocations((options & AbstractLanguage.OPTION_NO_IMAGE_LOCATIONS) == 0);
+
+ IParser parser = getParser();
+ IASTTranslationUnit tu = createTranslationUnit(index, preprocessor);
+
+ CPreprocessorAdapter.runCPreprocessor(preprocessor, parser, getTokenMap(), tu);
+
+ parser.parse(tu); // the parser will fill in the rest of the AST
+
+
+ System.out.println("Base Extensible Language AST:");
+ //DebugUtil.printAST(tu);
+ return tu;
+ }
+
+
+ public IASTTranslationUnit getASTTranslationUnit(CodeReader reader,
+ IScannerInfo scanInfo, ICodeReaderFactory fileCreator,
+ IIndex index, IParserLogService log) throws CoreException {
+
+ return getASTTranslationUnit(reader, scanInfo, fileCreator, index, 0, log);
+ }
+
+
+ public IASTCompletionNode getCompletionNode(CodeReader reader,
+ IScannerInfo scanInfo, ICodeReaderFactory fileCreator,
+ IIndex index, IParserLogService log, int offset) {
+
+ // TODO temporary
+ IScannerExtensionConfiguration config = new GCCScannerExtensionConfiguration();
+
+ ParserLanguage pl = getParserLanguageForPreprocessor();
+ IScanner preprocessor = new CPreprocessor(reader, scanInfo, pl, log, config, fileCreator);
+ preprocessor.setContentAssistMode(offset);
+
+ IParser parser = getParser();
+ IASTTranslationUnit tu = createTranslationUnit(index, preprocessor);
+
+ CPreprocessorAdapter.runCPreprocessor(preprocessor, parser, getTokenMap(), tu);
+
+ // the parser will fill in the rest of the AST
+ IASTCompletionNode completionNode = parser.parse(tu);
+ return completionNode;
+ }
+
+
+ /**
+ * Gets the translation unit object and sets the index and the location resolver.
+ */
+ private IASTTranslationUnit createTranslationUnit(IIndex index, IScanner preprocessor) {
+ IASTTranslationUnit tu = createASTTranslationUnit();
+ tu.setIndex(index);
+ if(tu instanceof CASTTranslationUnit) {
+ ((CASTTranslationUnit)tu).setLocationResolver(preprocessor.getLocationResolver());
+ }
+ return tu;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java
new file mode 100644
index 00000000000..987d7957dfb
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser;
+
+import lpg.lpgjavaruntime.IToken;
+import lpg.lpgjavaruntime.Token;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
+import org.eclipse.cdt.core.parser.EndOfFileException;
+import org.eclipse.cdt.core.parser.IScanner;
+
+/**
+ * Adapts the CPreprocessor from the CDT core for use with LPG based parsers.
+ *
+ * @author Mike Kucera
+ *
+ */
+class CPreprocessorAdapter {
+
+ /**
+ * During content assist the preprocessor may return a completion token
+ * which represents the identifier on which the user invoked content assist.
+ * The the preprocessor normally returns arbitrarily many end-of-completion
+ * (EOC) tokens.
+ *
+ * A bottom-up parser cannot know ahead of time how many EOC tokens are
+ * needed in order for the parse to complete successfully. So we pick
+ * a number that seems arbitrarily large enough.
+ */
+ private static final int NUM_EOC_TOKENS = 50;
+
+ private static final int DUMMY_TOKEN_KIND = 0;
+
+
+ private static final int tCOMPLETION = org.eclipse.cdt.core.parser.IToken.tCOMPLETION;
+ private static final int tEND_OF_INPUT = org.eclipse.cdt.core.parser.IToken.tEND_OF_INPUT;
+ private static final int tEOC = org.eclipse.cdt.core.parser.IToken.tEOC;
+
+
+
+ /**
+ * Collect the tokens generated by the preprocessor.
+ *
+ * TODO: should preprocessor.nextTokenRaw() be called instead?
+ */
+ @SuppressWarnings("restriction")
+ public static void runCPreprocessor(IScanner preprocessor, ITokenCollector tokenCollector, ITokenMap tokenMap, IASTTranslationUnit tu) {
+ // LPG requires that the token stream start with a dummy token
+ tokenCollector.addToken(createDummyToken());
+
+ preprocessor.getLocationResolver().setRootNode(tu);
+
+ try {
+ while(true) {
+ org.eclipse.cdt.core.parser.IToken domToken = preprocessor.nextToken(); // throws EndOfFileException
+ int type = domToken.getType();
+
+ IToken token = new LPGTokenAdapter(domToken, tokenMap.mapKind(type));
+ tokenCollector.addToken(token);
+
+ if(type == tCOMPLETION) {
+ // the token after the completion token must be an EOC token
+ org.eclipse.cdt.core.parser.IToken domEocToken = preprocessor.nextToken();
+ assert domEocToken.getType() == tEOC;
+
+ IToken eocToken = createEOCToken(domEocToken, tokenMap);
+
+ for(int i = 0; i < NUM_EOC_TOKENS; i++)
+ tokenCollector.addToken(eocToken); // reuse the same reference, no need to create several objects
+
+ break;
+ }
+ }
+ } catch (EndOfFileException e) {
+ // just break out of the loop
+ }
+
+ // LPG requires that the token stream end with an EOF token
+ tokenCollector.addToken(createEOFToken(tokenMap));
+ }
+
+
+
+
+ private static IToken createEOCToken(org.eclipse.cdt.core.parser.IToken domEocToken, ITokenMap tokenMap) {
+ return new LPGTokenAdapter(domEocToken, tokenMap.mapKind(domEocToken.getType()));
+ }
+
+ private static IToken createDummyToken() {
+ return new Token(null, 0, 0, DUMMY_TOKEN_KIND);
+ }
+
+ private static IToken createEOFToken(ITokenMap tokenMap) {
+ return new Token(null, 0, 0, tokenMap.mapKind(tEND_OF_INPUT));
+ }
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParser.java
new file mode 100644
index 00000000000..9510cc46a6a
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParser.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+
+/**
+ * Represents a parser that can be used by BaseExtensibleLanguage.
+ *
+ * @author Mike Kucera
+ */
+public interface IParser extends ITokenCollector {
+
+ /**
+ * Performs the actual parse.
+ *
+ * The given translation unit is assumed to not have any children, during the parse
+ * it will have its declaration fields filled in, resulting in a complete AST.
+ *
+ * If there were any errors during the parse these will be represented in the
+ * AST as problem nodes.
+ *
+ * If the parser encounters a completion token then a completion node
+ * is returned, null is returned otherwise.
+ *
+ * @param tu An IASTTranslationUnit instance that will have its declarators filled in.
+ * @return a completion node if a completion token is encountered during the parser, null otherwise.
+ */
+ public IASTCompletionNode parse(IASTTranslationUnit tu);
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParserActionTokenProvider.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParserActionTokenProvider.java
new file mode 100644
index 00000000000..a58b77306ab
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParserActionTokenProvider.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser;
+
+import java.util.List;
+
+import lpg.lpgjavaruntime.IToken;
+
+/**
+ * Provides an interface to the token stream that
+ * can be used by the parser semantic actions.
+ *
+ * Allows the semantic actions to directly inspect the token
+ * stream. Used to calculate AST node offsets and for
+ * other purposes.
+ *
+ * TODO There are still issues with getLeftIToken() and
+ * getRightIToken(), they should return null when used with
+ * an empty rule but currently they don't.
+ *
+ * @author Mike Kucera
+ */
+public interface IParserActionTokenProvider {
+
+ /**
+ * Returns the tokens that were parsed to recognized
+ * the currently executing rule.
+ *
+ * @returns a read-only list of tokens, will not be null but may be empty
+ */
+ public List<IToken> getRuleTokens();
+
+ /**
+ * Usually equivalent to getRuleTokens().get(0); but more efficient.
+ *
+ * However, when called during an empty rule it will return the token to the
+ * left of the location of the empty rule.
+ */
+ public IToken getLeftIToken();
+
+ /**
+ * Usually equivalent to getRuleTokens().get(getRuleTokens().size()-1); but more efficient.
+ *
+ * However, when called during an empty rule it will return the token to the
+ * right of the location of the empty rule.
+ */
+ public IToken getRightIToken();
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/ITokenCollector.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/ITokenCollector.java
new file mode 100644
index 00000000000..a35fc09b468
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/ITokenCollector.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser;
+
+import lpg.lpgjavaruntime.IToken;
+
+/**
+ * An LPG parser object is initialized with the list of tokens
+ * before parsing is invoked.
+ *
+ * This interface allows tokens to be "injected" into the parser
+ * before the parser is run.
+ *
+ * @author Mike Kucera
+ */
+public interface ITokenCollector {
+ public void addToken(IToken token);
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/LPGTokenAdapter.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/LPGTokenAdapter.java
new file mode 100644
index 00000000000..ad68293a0f5
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/LPGTokenAdapter.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser;
+
+
+import lpg.lpgjavaruntime.PrsStream;
+
+/**
+ * The CPreprocessor from the CDT core returns tokens that
+ * are of the type org.eclipse.cdt.core.parser.IToken,
+ * however LPG wants the tokens to be of the type lpg.lpgjavaruntime.IToken.
+ *
+ * So these adapter objects are used to wrap the tokens returned
+ * by CPreprocessor so that they can be used with LPG.
+ *
+ * @author Mike Kucera
+ */
+class LPGTokenAdapter implements lpg.lpgjavaruntime.IToken {
+
+ /** The token object that is being wrapped */
+ private final org.eclipse.cdt.core.parser.IToken token;
+
+
+ private int tokenIndex;
+ private int adjunctIndex;
+
+ private int kind;
+
+ public LPGTokenAdapter(org.eclipse.cdt.core.parser.IToken token, int parserKind) {
+ this.token = token;
+ this.kind = parserKind;
+ }
+
+ public int getAdjunctIndex() {
+ return adjunctIndex;
+ }
+
+ public int getColumn() {
+ return 0;
+ }
+
+ public int getEndColumn() {
+ return 0;
+ }
+
+ public int getEndLine() {
+ return 0;
+ }
+
+ public int getEndOffset() {
+ return token.getEndOffset();
+ }
+
+ public lpg.lpgjavaruntime.IToken[] getFollowingAdjuncts() {
+ return null;
+ }
+
+ public int getKind() {
+ return kind;
+ }
+
+ public int getLine() {
+ return 0;
+ }
+
+ public lpg.lpgjavaruntime.IToken[] getPrecedingAdjuncts() {
+ return null;
+ }
+
+ public PrsStream getPrsStream() {
+ return null;
+ }
+
+ public int getStartOffset() {
+ return token.getOffset();
+ }
+
+ public int getTokenIndex() {
+ return tokenIndex;
+ }
+
+ @Deprecated
+ public String getValue(char[] arg0) {
+ return toString();
+ }
+
+ public void setAdjunctIndex(int adjunctIndex) {
+ this.adjunctIndex = adjunctIndex;
+ }
+
+ public void setEndOffset(int arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setKind(int kind) {
+ this.kind = kind;
+ }
+
+ public void setStartOffset(int arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setTokenIndex(int tokenIndex) {
+ this.tokenIndex = tokenIndex;
+ }
+
+ @Override
+ public String toString() {
+ return token.toString();
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java
new file mode 100644
index 00000000000..50c6430a7ea
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action;
+
+import java.util.LinkedList;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+/**
+ * An AST node that represents the location of content assist
+ * in the source file.
+ *
+ * This node may contain the prefix text of an identifier up to the point. If
+ * there is no prefix, the completion occurred at the point where a new token
+ * would have begun.
+ *
+ * Contains a list of name nodes, each name represents an identifier
+ * at the point where content assist was invoked. There is usually
+ * a single name node, however if an ambiguity is detected then that section
+ * of the source may be interpreted in more than one way (for example, as an expression then as a declaration).
+ * This results in an ambiguity node in the tree and one name node for each of the ways it can be interpreted.
+ *
+ * The full AST may be accessed via getTranslationUnit() or by following
+ * the parent pointers of the name nodes.
+ *
+ * @author Mike Kucera
+ */
+public class ASTCompletionNode implements IASTCompletionNode {
+
+ private final LinkedList<IASTName> names = new LinkedList<IASTName>();
+
+ private final String prefix;
+ private final IASTTranslationUnit tu;
+
+
+ /**
+ * Creates a completion node.
+ * @throws NullPointerException if tu is null
+ * @throws IllegalArgumentException if prefix is the empty string, it should be null instead
+ */
+ public ASTCompletionNode(String prefix, IASTTranslationUnit tu) {
+ if("".equals(prefix)) //$NON-NLS-1$
+ throw new IllegalArgumentException("prefix cannot be the empty string"); //$NON-NLS-1$
+ if(tu == null)
+ throw new NullPointerException("tu is null"); //$NON-NLS-1$
+
+ this.prefix = prefix;
+ this.tu = tu;
+ }
+
+
+ public void addName(IASTName name) {
+ names.add(name);
+ }
+
+
+ /**
+ * Returns the length of the prefix.
+ */
+ public int getLength() {
+ return prefix == null ? 0 : prefix.length();
+ }
+
+
+ public IASTName[] getNames() {
+ return names.toArray(new IASTName[0]);
+ }
+
+
+ /**
+ * If the point of completion was at the end of a potential identifier, this
+ * string contains the text of that identifier.
+ *
+ * @returns a string of length >= 1 or null
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public IASTTranslationUnit getTranslationUnit() {
+ return tu;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
new file mode 100644
index 00000000000..841ec45e80f
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
@@ -0,0 +1,1042 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action;
+
+import java.util.Collections;
+import java.util.List;
+
+import lpg.lpgjavaruntime.IToken;
+
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
+import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTForStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
+import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTProblemHolder;
+import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTNode;
+
+
+/**
+ * Parser semantic actions that are common to both C and C++.
+ *
+ * @author Mike Kucera
+ */
+@SuppressWarnings("restriction")
+public abstract class BuildASTParserAction {
+
+
+ /**
+ * Used with very simple optional rules that just say
+ * that some particular token or keyword is optional.
+ * The presence of the PLACE_HOLDER on the stack means that the keyword
+ * was parsed, the presence of null means the keyword wasn't parsed.
+ *
+ * @see BuildASTParserAction#consumePlaceHolder()
+ * @see BuildASTParserAction#consumeEmpty()
+ */
+ protected static final Object PLACE_HOLDER = Boolean.TRUE;
+
+
+ // turn debug tracing on and off
+ // TODO move this into an AspectJ project
+ protected static final boolean TRACE_ACTIONS = true;
+ protected static final boolean TRACE_AST_STACK = true;
+
+
+ /** Stack that holds the intermediate nodes as the AST is being built */
+ protected final ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ /** Provides an interface to the token stream */
+ protected final IParserActionTokenProvider parser;
+
+ /** The completion node, only generated during a completion parse */
+ protected ASTCompletionNode completionNode;
+
+ /** The root node is created outside the parser because it is also needed by the preprocessor */
+ protected final IASTTranslationUnit tu;
+
+ /** Abstract factory for creating AST node objects */
+ private final IASTNodeFactory nodeFactory;
+
+
+
+ /**
+ * Completion tokens are represented by different kinds by different parsers.
+ */
+ protected abstract boolean isCompletionToken(IToken token);
+
+
+ /**
+ * Create a new parser action.
+ * @param tu Root node of the AST, its list of declarations should be empty.
+ * @throws NullPointerException if any of the parameters are null
+ */
+ public BuildASTParserAction(IASTNodeFactory nodeFactory, IParserActionTokenProvider parser, IASTTranslationUnit tu) {
+ if(nodeFactory == null)
+ throw new NullPointerException("nodeFactory is null"); //$NON-NLS-1$
+ if(parser == null)
+ throw new NullPointerException("parser is null"); //$NON-NLS-1$
+ if(tu == null)
+ throw new NullPointerException("tu is null"); //$NON-NLS-1$
+
+ this.nodeFactory = nodeFactory;
+ this.parser = parser;
+ this.tu = tu;
+ }
+
+
+ /**
+ * Creates a completion node if one does not yet exist and adds the
+ * given name to it.
+ */
+ protected void addNameToCompletionNode(IASTName name, String prefix) {
+ if(completionNode == null) {
+ prefix = (prefix == null || prefix.length() == 0) ? null : prefix;
+ completionNode = nodeFactory.newCompletionNode(prefix, tu);
+ }
+
+ completionNode.addName(name);
+ }
+
+
+ /**
+ * Returns the completion node if this is a completion parse, null otherwise.
+ */
+ public IASTCompletionNode getASTCompletionNode() {
+ return completionNode;
+ }
+
+
+
+
+ protected static int offset(IToken token) {
+ return token.getStartOffset();
+ }
+
+ protected static int offset(IASTNode node) {
+ return ((ASTNode)node).getOffset();
+ }
+
+ protected static int length(IToken token) {
+ return endOffset(token) - offset(token);
+ }
+
+ protected static int length(IASTNode node) {
+ return ((ASTNode)node).getLength();
+ }
+
+ protected static int endOffset(IASTNode node) {
+ return offset(node) + length(node);
+ }
+
+ protected static int endOffset(IToken token) {
+ return token.getEndOffset();
+ }
+
+
+ protected void setOffsetAndLength(IASTNode node) {
+ int ruleOffset = parser.getLeftIToken().getStartOffset();
+ int ruleLength = parser.getRightIToken().getEndOffset() - ruleOffset;
+ ((ASTNode)node).setOffsetAndLength(ruleOffset, ruleLength);
+ }
+
+ protected static void setOffsetAndLength(IASTNode node, IToken token) {
+ ((ASTNode)node).setOffsetAndLength(offset(token), length(token));
+ }
+
+ protected static void setOffsetAndLength(IASTNode node, int offset, int length) {
+ ((ASTNode)node).setOffsetAndLength(offset, length);
+ }
+
+
+
+ /**
+ * Creates a IASTName node from an identifier token.
+ * If the token is a completion token then it is added to the completion node.
+ */
+ protected IASTName createName(IToken token) {
+ IASTName name = nodeFactory.newName(token.toString().toCharArray()); // TODO, token.toCharArray();
+ setOffsetAndLength(name, token);
+
+ if(isCompletionToken(token))
+ addNameToCompletionNode(name, token.toString());
+
+ return name;
+ }
+
+
+
+
+ /*************************************************************************************************************
+ * Start of actions.
+ ************************************************************************************************************/
+
+
+
+ /**
+ * Method that is called by the special <openscope> production
+ * in order to create a new scope in the AST stack.
+ */
+ public void openASTScope() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ astStack.openScope();
+ }
+
+
+
+ /**
+ * Place null on the stack.
+ * Usually called for optional element to indicate the element
+ * was not parsed.
+ */
+ public void consumeEmpty() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+ astStack.push(null);
+ }
+
+
+ /**
+ * Place a marker on the stack.
+ * Usually used for very simple optional elements to indicate
+ * the element was parsed. Usually the existence of an AST node
+ * on the stack is used instead of the marker, but for simple
+ * cases like an optional keyword this action is useful.
+ */
+ public void consumePlaceHolder() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+ astStack.push(PLACE_HOLDER);
+ }
+
+
+
+ /**
+ * Gets the current token and places it on the stack for later consumption.
+ */
+ public void consumeDeclSpecToken() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ astStack.push(parser.getRightIToken());
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+
+ public void consumeTranslationUnit() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ // can't close the outermost scope
+ // the outermost scope may be empty if there are no tokens in the file
+ for(Object o : astStack.topScope()) {
+ tu.addDeclaration((IASTDeclaration)o);
+ }
+
+ // this is the same way that the DOM parser computes the length
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ if (declarations.length != 0) {
+ CASTNode d = (CASTNode) declarations[declarations.length-1];
+ setOffsetAndLength(tu, 0, d.getOffset() + d.getLength());
+ }
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * Consumes a single identifier token.
+ */
+ public void consumeIdentifierName() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IToken token = parser.getRightIToken();
+ IASTName name = createName(token);
+ astStack.push(name);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * @param kind One of the kind flags from IASTLiteralExpression or ICPPASTLiteralExpression
+ * @see IASTLiteralExpression
+ * @see ICPPASTLiteralExpression
+ */
+ public void consumeExpressionLiteral(int kind) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IToken token = parser.getRightIToken();
+ String rep = token.toString();
+
+ // Strip the quotes from string literals, this is just to be consistent
+ // with the dom parser (i.e. to make a test pass)
+// if(kind == IASTLiteralExpression.lk_string_literal &&
+// rep.startsWith("\"") && rep.endsWith("\"")) {
+// rep = rep.substring(1, rep.length()-1);
+// }
+
+ IASTLiteralExpression expr = nodeFactory.newLiteralExpression(kind, rep);
+ setOffsetAndLength(expr, token);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ public void consumeExpressionBracketed() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression operand = (IASTExpression) astStack.pop();
+ IASTUnaryExpression expr = nodeFactory.newUnaryExpression(IASTUnaryExpression.op_bracketedPrimary, operand);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ public void consumeExpressionID() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = createName(parser.getRightIToken());
+ IASTIdExpression expr = nodeFactory.newIdExpression(name);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ public void consumeExpressionName() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = (IASTName) astStack.pop();
+ IASTIdExpression expr = nodeFactory.newIdExpression(name);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * expression ::= <openscope-ast> expression_list_actual
+ */
+ public void consumeExpressionList() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> expressions = astStack.closeScope();
+ if(expressions.size() == 1) {
+ astStack.push(expressions.get(0));
+ }
+ else {
+ IASTExpressionList exprList = nodeFactory.newExpressionList();
+ for(Object o : expressions) {
+ exprList.addExpression((IASTExpression)o);
+ }
+ astStack.push(exprList);
+ }
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * postfix_expression ::= postfix_expression '[' expression ']'
+ */
+ public void consumeExpressionArraySubscript() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression subscript = (IASTExpression) astStack.pop();
+ IASTExpression arrayExpr = (IASTExpression) astStack.pop();
+ IASTArraySubscriptExpression expr = nodeFactory.newArraySubscriptExpression(arrayExpr, subscript);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * postfix_expression ::= postfix_expression '(' expression_list_opt ')'
+ */
+ public void consumeExpressionFunctionCall() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression argList = (IASTExpression) astStack.pop(); // may be null
+ IASTExpression idExpr = (IASTExpression) astStack.pop();
+
+ IASTFunctionCallExpression expr = nodeFactory.newFunctionCallExpression(idExpr, argList);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * @param operator constant for {@link ICPPASTCastExpression}
+ */
+ public void consumeExpressionCast(int operator) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression operand = (IASTExpression) astStack.pop();
+ IASTTypeId typeId = (IASTTypeId) astStack.pop();
+ IASTCastExpression expr = nodeFactory.newCastExpression(operator, typeId, operand);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * Lots of rules, no need to list them.
+ * @param operator From IASTUnaryExpression
+ */
+ public void consumeExpressionUnaryOperator(int operator) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression operand = (IASTExpression) astStack.pop();
+ IASTUnaryExpression expr = nodeFactory.newUnaryExpression(operator, operand);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * unary_operation ::= 'sizeof' '(' type_name ')'
+ * @see consumeExpressionUnaryOperator For the other use of sizeof
+ */
+ public void consumeExpressionTypeId(int operator) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTTypeId typeId = (IASTTypeId) astStack.pop();
+ IASTTypeIdExpression expr = nodeFactory.newTypeIdExpression(operator, typeId);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * Lots of rules, no need to list them all.
+ * @param op Field from IASTBinaryExpression
+ */
+ public void consumeExpressionBinaryOperator(int op) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr2 = (IASTExpression) astStack.pop();
+ IASTExpression expr1 = (IASTExpression) astStack.pop();
+ IASTBinaryExpression binExpr = nodeFactory.newBinaryExpression(op, expr1, expr2);
+ setOffsetAndLength(binExpr);
+ astStack.push(binExpr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * conditional_expression ::= logical_OR_expression '?' expression ':' conditional_expression
+ */
+ public void consumeExpressionConditional() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr3 = (IASTExpression) astStack.pop();
+ IASTExpression expr2 = (IASTExpression) astStack.pop();
+ IASTExpression expr1 = (IASTExpression) astStack.pop();
+ IASTConditionalExpression condExpr = nodeFactory.newConditionalExpession(expr1, expr2, expr3);
+ setOffsetAndLength(condExpr);
+ astStack.push(condExpr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * labeled_statement ::= label_identifier ':' statement
+ * label_identifier ::= identifier
+ */
+ public void consumeStatementLabeled(/*IBinding binding*/) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStatement body = (IASTStatement) astStack.pop();
+ IASTName label = createName(parser.getLeftIToken());
+ //label.setBinding(binding);
+ IASTLabelStatement stat = nodeFactory.newLabelStatement(label, body);
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * labeled_statement ::= case constant_expression ':'
+ */
+ public void consumeStatementCase() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr = (IASTExpression) astStack.pop();
+ IASTCaseStatement caseStatement = nodeFactory.newCaseStatement(expr);
+ setOffsetAndLength(caseStatement);
+ astStack.push(caseStatement);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * labeled_statement ::= default ':'
+ */
+ public void consumeStatementDefault() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDefaultStatement stat = nodeFactory.newDefaultStatement();
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * expression_statement ::= ';'
+ */
+ public void consumeStatementNull() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTNullStatement stat = nodeFactory.newNullStatement();
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * expression_statement ::= expression ';'
+ */
+ public void consumeStatementExpression() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr = (IASTExpression) astStack.pop();
+ IASTExpressionStatement stat = nodeFactory.newExpressionStatement(expr);
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * compound_statement ::= <openscope> '{' block_item_list '}'
+ *
+ * block_item_list ::= block_item | block_item_list block_item
+ */
+ public void consumeStatementCompoundStatement(boolean hasStatementsInBody) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTCompoundStatement block = nodeFactory.newCompoundStatement();
+
+ if(hasStatementsInBody) {
+ for(Object o : astStack.closeScope()) {
+ block.addStatement((IASTStatement)o);
+ }
+ }
+
+ setOffsetAndLength(block);
+ astStack.push(block);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * iteration_statement_matched
+ * ::= 'do' statement 'while' '(' expression ')' ';'
+ */
+ public void consumeStatementDoLoop() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression condition = (IASTExpression) astStack.pop();
+ IASTStatement body = (IASTStatement) astStack.pop();
+ IASTDoStatement stat = nodeFactory.newDoStatement(body, condition);
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * jump_statement ::= goto goto_identifier ';'
+ */
+ public void consumeStatementGoto(/*IBinding binding*/) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = createName(parser.getRuleTokens().get(1));
+ //name.setBinding(binding);
+ IASTGotoStatement gotoStat = nodeFactory.newGotoStatement(name);
+ setOffsetAndLength(gotoStat);
+ astStack.push(gotoStat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * jump_statement ::= continue ';'
+ */
+ public void consumeStatementContinue() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTContinueStatement stat = nodeFactory.newContinueStatement();
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * jump_statement ::= break ';'
+ */
+ public void consumeStatementBreak() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTBreakStatement stat = nodeFactory.newBreakStatement();
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * jump_statement ::= return ';'
+ * jump_statement ::= return expression ';'
+ */
+ public void consumeStatementReturn(boolean hasExpr) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr = hasExpr ? (IASTExpression) astStack.pop() : null;
+ IASTReturnStatement returnStat = nodeFactory.newReturnStatement(expr);
+ setOffsetAndLength(returnStat);
+ astStack.push(returnStat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * iteration_statement_matched
+ * ::= 'for' '(' expression_opt ';' expression_opt ';' expression_opt ')' statement
+ */
+ public void consumeStatementForLoop() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStatement body = (IASTStatement) astStack.pop();
+ // these two expressions may be null, see consumeExpressionOptional()
+ IASTExpression expr3 = (IASTExpression) astStack.pop();
+ IASTExpression expr2 = (IASTExpression) astStack.pop();
+
+ IASTNode node = (IASTNode) astStack.pop(); // may be an expression or a declaration
+
+ IASTStatement initializer;
+ if(node instanceof IASTExpression)
+ initializer = nodeFactory.newExpressionStatement((IASTExpression)node);
+ else if(node instanceof IASTDeclaration)
+ initializer = nodeFactory.newDeclarationStatement((IASTDeclaration)node);
+ else // its null
+ initializer = nodeFactory.newNullStatement();
+
+ IASTForStatement forStat = nodeFactory.newForStatement(initializer, expr2, expr3, body);
+ setOffsetAndLength(forStat);
+ astStack.push(forStat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * type_name ::= specifier_qualifier_list
+ * | specifier_qualifier_list abstract_declarator
+ */
+ public void consumeTypeId(boolean hasDeclarator) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclarator declarator;
+ if(hasDeclarator)
+ declarator = (IASTDeclarator) astStack.pop();
+ else
+ declarator = nodeFactory.newDeclarator(nodeFactory.newName());
+
+ IASTDeclSpecifier declSpecifier = (IASTDeclSpecifier) astStack.pop();
+ IASTTypeId typeId = nodeFactory.newTypeId(declSpecifier, declarator);
+ setOffsetAndLength(typeId);
+ astStack.push(typeId);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * TODO: do I really want to share declaration rules between the two parsers.
+ * Even if there is potential for reuse it still may be cleaner to leave the
+ * common stuff to just simple expressions and statements.
+ *
+ * declaration ::= declaration_specifiers <openscope> init_declarator_list ';'
+ * declaration ::= declaration_specifiers ';'
+ */
+ public void consumeDeclarationSimple(boolean hasDeclaratorList) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> declarators = (hasDeclaratorList) ? astStack.closeScope() : Collections.emptyList();
+ ICASTDeclSpecifier declSpecifier = (ICASTDeclSpecifier) astStack.pop(); // may be null
+
+ IASTSimpleDeclaration declaration = nodeFactory.newSimpleDeclaration(declSpecifier);
+
+ for(Object declarator : declarators)
+ declaration.addDeclarator((IASTDeclarator)declarator);
+
+ setOffsetAndLength(declaration);
+ astStack.push(declaration);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * direct_declarator ::= '(' declarator ')'
+ */
+ public void consumeDirectDeclaratorBracketed() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclarator nested = (IASTDeclarator) astStack.pop();
+ IASTDeclarator declarator = nodeFactory.newDeclarator(nodeFactory.newName());
+ declarator.setNestedDeclarator(nested);
+ setOffsetAndLength(declarator);
+ astStack.push(declarator);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * direct_declarator ::= declarator_id_name
+ */
+ public void consumeDirectDeclaratorIdentifier() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = (IASTName) astStack.pop();
+ IASTDeclarator declarator = nodeFactory.newDeclarator(name);
+ setOffsetAndLength(declarator);
+ astStack.push(declarator);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * array_modifier
+ * ::= '[' ']'
+ * | '[' assignment_expression ']'
+ */
+ public void consumeDirectDeclaratorArrayModifier(boolean hasAssignmentExpr) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr = hasAssignmentExpr ? (IASTExpression)astStack.pop() : null;
+ IASTArrayModifier arrayModifier = nodeFactory.newArrayModifier(expr);
+ setOffsetAndLength(arrayModifier);
+ astStack.push(arrayModifier);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * When the identifier part of a declarator is parsed it will put a plain IASTDeclarator on the stack.
+ * When the array modifier part is parsed we will need to throw away the plain
+ * declarator and replace it with an array declarator. If its a multidimensional array then
+ * the additional array modifiers will need to be added to the array declarator.
+ * Special care is taken for nested declarators.
+ */
+ protected void consumeDeclaratorArray(IASTArrayModifier arrayModifier) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclarator node = (IASTDeclarator) astStack.pop();
+
+ // Its a nested declarator so create an new ArrayDeclarator
+ if(node.getNestedDeclarator() != null) { //node.getPropertyInParent() == IASTDeclarator.NESTED_DECLARATOR) {
+ IASTArrayDeclarator declarator = nodeFactory.newArrayDeclarator(nodeFactory.newName());
+ IASTDeclarator nested = node;
+ declarator.setNestedDeclarator(nested);
+
+ int offset = offset(nested);
+ int length = endOffset(arrayModifier) - offset;
+ setOffsetAndLength(declarator, offset, length);
+
+ declarator.addArrayModifier(arrayModifier);
+ astStack.push(declarator);
+ }
+ // There is already an array declarator so just add the modifier to it
+ else if(node instanceof IASTArrayDeclarator) {
+ IASTArrayDeclarator decl = (IASTArrayDeclarator) node;
+ ((ASTNode)decl).setLength(endOffset(arrayModifier) - offset(decl));
+
+ decl.addArrayModifier(arrayModifier);
+ astStack.push(decl);
+ }
+ // The declarator is an identifier so create a new array declarator
+ else {
+ IASTName name = node.getName();
+ IASTArrayDeclarator decl = nodeFactory.newArrayDeclarator(name);
+
+ int offset = offset(name);
+ int length = endOffset(arrayModifier) - offset;
+ setOffsetAndLength(decl, offset, length);
+
+ decl.addArrayModifier(arrayModifier);
+ astStack.push(decl);
+ }
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * Pops a simple declarator from the stack, converts it into
+ * a FunctionDeclator, then pushes it.
+ * TODO: is this the best way of doing this?
+ */
+ protected void consumeDirectDeclaratorFunctionDeclarator(IASTFunctionDeclarator declarator, int endOffset) {
+ IASTDeclarator decl = (IASTDeclarator) astStack.pop();
+
+ if(decl.getNestedDeclarator() != null) {
+ decl = decl.getNestedDeclarator(); // need to remove one level of nesting for function pointers
+ declarator.setNestedDeclarator(decl);
+ declarator.setName(nodeFactory.newName());
+ int offset = offset(decl);
+ setOffsetAndLength(declarator, offset, endOffset - offset);
+ astStack.push(declarator);
+ }
+ else {
+ IASTName name = decl.getName();
+ if(name == null) {
+ name = nodeFactory.newName();
+ }
+ declarator.setName(name);
+
+ IASTPointerOperator[] pointers = decl.getPointerOperators();
+ for(int i = 0; i < pointers.length; i++) {
+ declarator.addPointerOperator(pointers[i]);
+ }
+
+ int offset = offset(name); // TODO
+ setOffsetAndLength(declarator, offset, endOffset - offset);
+ astStack.push(declarator);
+ }
+
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+ /**
+ * direct_declarator ::= direct_declarator array_modifier
+ * consume the direct_declarator part and add the array modifier
+ */
+ public void consumeDirectDeclaratorArrayDeclarator() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTArrayModifier arrayModifier = (IASTArrayModifier) astStack.pop();
+ consumeDeclaratorArray(arrayModifier);
+ }
+
+
+ /**
+ * enum_specifier ::= 'enum' '{' <openscope> enumerator_list_opt '}'
+ * | 'enum' enum_identifier '{' <openscope> enumerator_list_opt '}'
+ */
+ public void consumeTypeSpecifierEnumeration(boolean hasIdent) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = (hasIdent) ? createName(parser.getRuleTokens().get(1)) : nodeFactory.newName();
+
+ IASTEnumerationSpecifier enumSpec = nodeFactory.newEnumerationSpecifier(name);
+
+ for(Object o : astStack.closeScope())
+ enumSpec.addEnumerator((IASTEnumerator)o);
+
+ setOffsetAndLength(enumSpec);
+ astStack.push(enumSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * enumerator ::= enum_identifier
+ * | enum_identifier '=' constant_expression
+ */
+ public void consumeEnumerator(boolean hasInitializer) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = createName(parser.getLeftIToken());
+
+ IASTExpression value = null;
+ if(hasInitializer)
+ value = (IASTExpression) astStack.pop();
+
+ IASTEnumerator enumerator = nodeFactory.newEnumerator(name, value);
+ setOffsetAndLength(enumerator);
+ astStack.push(enumerator);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * initializer ::= assignment_expression
+ */
+ public void consumeInitializer() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression assignmentExpr = (IASTExpression) astStack.pop();
+ IASTInitializerExpression expr = nodeFactory.newInitializerExpression(assignmentExpr);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * initializer ::= '{' <openscope> initializer_list '}'
+ * | '{' <openscope> initializer_list ',' '}'
+ */
+ public void consumeInitializerList() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTInitializerList list = nodeFactory.newInitializerList();
+
+ for(Object o : astStack.closeScope())
+ list.addInitializer((IASTInitializer)o);
+
+ setOffsetAndLength(list);
+ astStack.push(list);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+
+ /**
+ * statement ::= ERROR_TOKEN
+ */
+ public void consumeStatementProblem() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ consumeProblem(nodeFactory.newProblemStatement());
+ }
+
+ /**
+ * assignment_expression ::= ERROR_TOKEN
+ * constant_expression ::= ERROR_TOKEN
+ */
+ public void consumeExpressionProblem() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ consumeProblem(nodeFactory.newProblemExpression());
+ }
+
+ /**
+ * external_declaration ::= ERROR_TOKEN
+ */
+ public void consumeDeclarationProblem() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ consumeProblem(nodeFactory.newProblemDeclaration());
+ }
+
+
+ private void consumeProblem(IASTProblemHolder problemHolder) {
+ IASTProblem problem = nodeFactory.newProblem(IASTProblem.SYNTAX_ERROR, new char[0], false, true);
+ problemHolder.setProblem(problem);
+ setOffsetAndLength(problem);
+ setOffsetAndLength((ASTNode)problemHolder);
+ astStack.push(problemHolder);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+} \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/FunctionalMap.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/FunctionalMap.java
new file mode 100644
index 00000000000..3b518c9d64c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/FunctionalMap.java
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action;
+
+
+/**
+ * An immutable map, like you would find in a functional programming language.
+ *
+ * Inserting a new pair into the map leaves the original map untouched,
+ * instead a new map that contains the pair is returned. Therefore
+ * an assignment is needed to "modify" the map (just like with Strings).
+ *
+ * <code>
+ * myMap = myMap.insert(key,value);
+ * </code>
+ *
+ * There is no remove() method because it is not needed. In order to
+ * "delete" a pair from the map simply save a reference to an old version
+ * of the map and restore the map from that old reference. This makes
+ * "undo" operations trivial to implement.
+ *
+ * <code>
+ * FunctionalMap oldMap = myMap; // save a reference
+ * myMap = myMap.insert(key,value); // insert the pair into the map
+ * myMap = oldMap; // delete the pair from the map
+ * </code>
+ *
+ * This map is implemented as a red-black tree data structure,
+ * and is based on the implementation found at:
+ * http://www.eecs.usma.edu/webs/people/okasaki/jfp99.ps
+ *
+ * @author Mike Kucera
+ */
+public class FunctionalMap<K extends Comparable<K>, V> {
+
+ // better than an enum because enum variables can be null
+ private static final boolean RED = true, BLACK = false;
+
+
+ private static class Node<K, V> {
+ final K key;
+ final V val;
+ Node<K,V> left;
+ Node<K,V> right;
+ boolean color;
+
+ public Node(K key, V val, boolean color, Node<K,V> left, Node<K,V> right) {
+ this.key = key;
+ this.val = val;
+ this.left = left;
+ this.right = right;
+ this.color = color;
+ }
+
+ @Override public String toString() {
+ return "Node(" + key + "," + val + "," + (color ? "R" : "B") + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ }
+ }
+
+
+ private Node<K,V> root = null;
+
+
+ private FunctionalMap() {
+ // private constructor, use static factory method to instantiate
+ }
+
+ // factory method makes it cleaner to instantiate objects
+ public static <K extends Comparable<K>,V> FunctionalMap<K,V> emptyMap() {
+ return new FunctionalMap<K,V>();
+ }
+
+
+ /**
+ * Returns a new map that contains the key-value pair.
+ * @throws NullPointerException if key is null
+ */
+ public FunctionalMap<K,V> insert(K key, V val) {
+ if(key == null)
+ throw new NullPointerException();
+
+ FunctionalMap<K,V> newMap = new FunctionalMap<K,V>();
+ newMap.root = insert(this.root, key, val);
+ newMap.root.color = BLACK; // force the root to be black
+
+ assert checkInvariants(newMap.root);
+
+ return newMap;
+ }
+
+
+ private Node<K,V> insert(Node<K,V> n, K key, V val) {
+ if(n == null)
+ return new Node<K,V>(key, val, RED, null, null); // new nodes are always red
+
+ int c = key.compareTo(n.key);
+ if(c < 0)
+ return balance(n.key, n.val, n.color, insert(n.left, key, val), n.right);
+ else if(c > 0)
+ return balance(n.key, n.val, n.color, n.left, insert(n.right, key, val));
+ else // equal, create a new node that overwrites the old value
+ return new Node<K,V>(key, val, n.color, n.left, n.right);
+ }
+
+
+ private Node<K,V> balance(K key, V val, boolean color, Node<K,V> left, Node<K,V> right) {
+ if(color == RED)
+ return new Node<K,V>(key, val, color, left, right);
+
+ final Node<K,V> newLeft, newRight;
+
+ // now for the madness...
+
+ if(left != null && left.color == RED) {
+ if(left.left != null && left.left.color == RED) {
+ newLeft = new Node<K,V>(left.left.key, left.left.val, BLACK, left.left.left, left.left.right);
+ newRight = new Node<K,V>(key, val, BLACK, left.right, right);
+ return new Node<K,V>(left.key, left.val, RED, newLeft, newRight);
+ }
+ if(left.right != null && left.right.color == RED) {
+ newLeft = new Node<K,V>(left.key, left.val, BLACK, left.left, left.right.left);
+ newRight = new Node<K,V>(key, val, BLACK, left.right.right, right);
+ return new Node<K,V>(left.right.key, left.right.val, RED, newLeft, newRight);
+ }
+ }
+ if(right != null && right.color == RED) {
+ if(right.left != null && right.left.color == RED) {
+ newLeft = new Node<K,V>(key, val, BLACK, left, right.left.left);
+ newRight = new Node<K,V>(right.key, right.val, BLACK, right.left.right, right.right);
+ return new Node<K,V>(right.left.key, right.left.val, RED, newLeft, newRight);
+ }
+ if(right.right != null && right.right.color == RED) {
+ newLeft = new Node<K,V>(key, val, BLACK, left, right.left);
+ newRight = new Node<K,V>(right.right.key, right.right.val, BLACK, right.right.left, right.right.right);
+ return new Node<K,V>(right.key, right.val, RED, newLeft, newRight);
+ }
+ }
+
+ return new Node<K,V>(key, val, BLACK, left, right);
+ }
+
+
+ /**
+ * Returns the value if it is in the map, null otherwise.
+ * @throws NullPointerException if key is null
+ */
+ public V lookup(K key) {
+ if(key == null)
+ throw new NullPointerException();
+
+ // no need for recursion here
+ Node<K,V> n = root;
+ while(n != null) {
+ int x = key.compareTo(n.key); // throws NPE if key is null
+ if(x == 0)
+ return n.val;
+ n = (x < 0) ? n.left : n.right;
+ }
+ return null;
+ }
+
+
+ /**
+ * Returns true if there exists a mapping with the given key
+ * in this map.
+ * @throws NullPointerException if key is null
+ */
+ public boolean containsKey(K key) {
+ if(key == null)
+ throw new NullPointerException();
+
+ // lookup uses an iterative algorithm
+ Node<K,V> n = root;
+ while(n != null) {
+ int x = key.compareTo(n.key); // throws NPE if key is null
+ if(x == 0)
+ return true;
+ n = (x < 0) ? n.left : n.right;
+ }
+ return false;
+ }
+
+
+ public boolean isEmpty() {
+ return root == null;
+ }
+
+ @Override public String toString() {
+ StringBuilder sb = new StringBuilder('[');
+ inorderPrint(root, sb);
+ sb.append(']');
+ return sb.toString();
+ }
+
+ private static <K,V> void inorderPrint(Node<K,V> n, StringBuilder sb) {
+ if(n == null)
+ return;
+
+ inorderPrint(n.left, sb);
+ if(sb.length() > 1)
+ sb.append(", ");//$NON-NLS-1$
+ sb.append(n.toString());
+ inorderPrint(n.right, sb);
+ }
+
+
+ void printStructure() {
+ if(root == null)
+ System.out.println("empty map"); //$NON-NLS-1$
+ else
+ printStructure(root, 0);
+ }
+
+ private static <K,V> void printStructure(Node<K,V> node, int level) {
+ for(int i = 0; i < level; i++)
+ System.out.print("--");//$NON-NLS-1$
+
+ if(node == null) {
+ System.out.println("null");//$NON-NLS-1$
+ }
+ else if(node.right == null && node.left == null) {
+ System.out.println(node);
+ }
+ else {
+ System.out.println(node);
+ printStructure(node.right, level + 1);
+ printStructure(node.left, level + 1);
+ }
+ }
+
+
+ private static <K,V> int depth(Node<K,V> node) {
+ if(node == null)
+ return 0;
+ return Math.max(depth(node.left), depth(node.right)) + 1;
+ }
+
+
+ /**
+ * Warning, this is a linear operation.
+ */
+ public int size() {
+ return size(root);
+ }
+
+ private static <K,V> int size(Node<K,V> node) {
+ if(node == null)
+ return 0;
+ return size(node.left) + size(node.right) + 1;
+ }
+
+
+
+ /**********************************************************************************************
+ * Built-in testing
+ **********************************************************************************************/
+
+
+ private boolean checkInvariants(Node<K,V> n) {
+ // the number of black nodes on every path through the tree is the same
+ assertBalanced(n);
+ return true;
+ }
+
+ // not exactly sure if this is right
+ private int assertBalanced(Node<K,V> node) {
+ if(node == null)
+ return 1; // nulls are considered as black children
+
+ // both children of every red node are black
+ if(node.color == RED) {
+ assert node.left == null || node.left.color == BLACK;
+ assert node.right == null || node.right.color == BLACK;
+ }
+
+ int left = assertBalanced(node.left);
+ int right = assertBalanced(node.right);
+
+ assert left == right;
+
+ return left + (node.color == BLACK ? 1 : 0);
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/IASTNodeFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/IASTNodeFactory.java
new file mode 100644
index 00000000000..3910661510b
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/IASTNodeFactory.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action;
+
+import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
+import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTForStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
+import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
+import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
+import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+
+
+/**
+ * Abstract factory interface for creating AST node objects.
+ *
+ * @author Mike Kucera
+ */
+public interface IASTNodeFactory {
+
+ public IASTName newName(char[] name);
+
+ public IASTName newName();
+
+ // TODO this should return IASTCompletionNode
+ public ASTCompletionNode newCompletionNode(String prefix, IASTTranslationUnit tu);
+
+ public IASTLiteralExpression newLiteralExpression(int kind, String rep);
+
+ public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand);
+
+ public IASTIdExpression newIdExpression(IASTName name);
+
+ public IASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
+
+ public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList);
+
+ public IASTExpressionList newExpressionList();
+
+ public IASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand);
+
+ public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2);
+
+ public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3);
+
+ public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement);
+
+ public IASTCaseStatement newCaseStatement(IASTExpression expr);
+
+ public IASTDefaultStatement newDefaultStatement();
+
+ public IASTExpressionStatement newExpressionStatement(IASTExpression expression);
+
+ public IASTNullStatement newNullStatement();
+
+ public IASTCompoundStatement newCompoundStatement();
+
+ public IASTSwitchStatement newSwitchStatment(IASTExpression controller, IASTStatement body);
+
+ public IASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause);
+
+ public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
+
+ public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition);
+
+ public IASTGotoStatement newGotoStatement(IASTName name);
+
+ public IASTContinueStatement newContinueStatement();
+
+ public IASTBreakStatement newBreakStatement();
+
+ public IASTReturnStatement newReturnStatement(IASTExpression retValue);
+
+ public IASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
+ IASTExpression iterationExpression, IASTStatement body);
+
+ public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration);
+
+ public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId);
+
+ public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator);
+
+ public IASTDeclarator newDeclarator(IASTName name);
+
+ public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier);
+
+ public IASTInitializerExpression newInitializerExpression(IASTExpression expression);
+
+ public IASTInitializerList newInitializerList();
+
+ public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
+ IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
+
+ public IASTTranslationUnit newTranslationUnit();
+
+ public IASTStandardFunctionDeclarator newFunctionDeclarator(IASTName name);
+
+ public IASTASMDeclaration newASMDeclaration(String assembly);
+
+ public IASTProblemDeclaration newProblemDeclaration();
+
+ public IASTProblemStatement newProblemStatement();
+
+ public IASTProblemExpression newProblemExpression();
+
+ public IASTProblem newProblem(int id, char[] arg, boolean warn, boolean error);
+
+ public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name);
+
+ public IASTEnumerator newEnumerator(IASTName name, IASTExpression value);
+
+ public IASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
+
+ public IASTArrayModifier newArrayModifier(IASTExpression expr);
+
+ public IASTArrayDeclarator newArrayDeclarator(IASTName name);
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ITokenMap.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ITokenMap.java
new file mode 100644
index 00000000000..57ff7245bf8
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ITokenMap.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright (c) 2006, 2008 IBM Corporation and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* IBM Corporation - initial API and implementation
+*********************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action;
+
+
+
+/**
+ * Maps tokens defined in parser extensions back to the token kinds
+ * defined in the lr parsers.
+ *
+ * When LPG is used to generate a parser extension it will
+ * generate all-new token kinds. In order for the semantic actions to be able
+ * to interpret these token kinds correctly they will be mapped back
+ * to the token kinds defined in C99Parsersym.
+ *
+ * @author Mike Kucera
+ */
+public interface ITokenMap {
+
+ /**
+ * Maps the given token kind back to the same token kind defined in C99Parsersym.
+ */
+ int mapKind(int kind);
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ScopedStack.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ScopedStack.java
new file mode 100644
index 00000000000..b9dedb6a52b
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ScopedStack.java
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.dom.lrparser.action;
+
+import static org.eclipse.cdt.core.dom.lrparser.util.CollectionUtils.reverseIterable;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+/**
+ * A stack that can be "marked", that is the stack can be divided
+ * into chunks that can be conveniently processed. There is always at
+ * least one open scope.
+ *
+ *
+ * This stack was designed to be used to store AST nodes while
+ * the AST is built during the parse, however it is useful for other
+ * purposes as well.
+ *
+ * Some grammar rules have arbitrary length lists on the right side.
+ * For example the rule for compound statements (where block_item_list is any
+ * number of statements or declarations):
+ *
+ * compound-statement ::= '{' <openscope-ast> block_item_list '}'
+ *
+ * There is a problem when trying to build the AST node for the compound statement...
+ * you don't know how many block_items are contained in the compound statement, so
+ * you don't know how many times to pop the AST stack.
+ *
+ * One inelegant solution is to count the block-items as they are parsed. This
+ * is inelegant because nested compound-statements are allowed so you would
+ * have to maintain several counts at the same time.
+ *
+ * Another solution would be to build the list of block-items as part of the
+ * block_item_list rule, but just using this stack is simpler.
+ *
+ * This class can be used as an AST stack that is implemented as a stack of "AST Scopes".
+ * There is a special grammar rule <openscope-ast> that creates a new AST Scope.
+ * So, in order to consume all the block_items, all that has to be done is
+ * iterate over the topmost scope and then close it when done.
+ *
+ *
+ * @author Mike Kucera
+ */
+public class ScopedStack<T> {
+
+ private LinkedList<T> topScope;
+
+ // A stack of stacks, used to implement scoping
+ private final LinkedList<LinkedList<T>> scopeStack;
+
+
+
+ /**
+ * Creates a new ScopedStack with the first scope already open.
+ */
+ public ScopedStack() {
+ topScope = new LinkedList<T>();
+ scopeStack = new LinkedList<LinkedList<T>>();
+ }
+
+
+ /**
+ * Opens a new scope.
+ */
+ public void openScope() {
+ scopeStack.add(topScope);
+ topScope = new LinkedList<T>();
+ }
+
+ /**
+ * Marks the stack then pushes all the items in the given list.
+ *
+ * @throws NullPointerException if items is null
+ */
+ public void openScope(List<T> items) {
+ openScope();
+ for(T item : items)
+ push(item);
+ }
+
+ /**
+ * Marks the stack then pushes all the items in the given array.
+ *
+ * @throws NullPointerException if items is null
+ */
+ public void openScope(T[] items) {
+ // looks the same as above but compiles into different bytecode
+ openScope();
+ for(T item : items)
+ push(item);
+ }
+
+ /**
+ * Pops all the items in the topmost scope.
+ * The outermost scope cannot be closed.
+ *
+ * @throws NoSuchElementException If the outermost scope is closed.
+ */
+ public List<T> closeScope() {
+ if(scopeStack.isEmpty())
+ throw new NoSuchElementException("cannot close outermost scope"); //$NON-NLS-1$
+
+ List<T> top = topScope;
+ topScope = scopeStack.removeLast();
+ return top;
+ }
+
+ /**
+ * Pushes an item onto the topmost scope.
+ */
+ public void push(T o) {
+ topScope.add(o);
+ }
+
+ /**
+ * @throws NoSuchElementException if the topmost scope is empty
+ */
+ public T pop() {
+ return topScope.removeLast();
+ }
+
+ /**
+ * @throws NoSuchElementException if the topmost scope is empty
+ */
+ public T peek() {
+ return topScope.getLast();
+ }
+
+ /**
+ * Returns the entire top scope as a List.
+ */
+ public List<T> topScope() {
+ return topScope;
+ }
+
+ /**
+ * Returns the next outermost scope.
+ * @throws NoSuchElementException if size() < 2
+ */
+ public List<T> outerScope() {
+ return scopeStack.getLast();
+ }
+
+
+ public boolean isEmpty() {
+ return topScope.isEmpty() && scopeStack.isEmpty();
+ }
+
+
+ /**
+ * Why oh why does java not have reverse iterators?????
+ */
+ public void print() {
+ final String separator = "----------"; //$NON-NLS-1$
+ System.out.println();
+ System.out.println('-');
+
+ printScope(topScope);
+ System.out.println(separator);
+
+ for(LinkedList<T> list : reverseIterable(scopeStack)) {
+ printScope(list);
+ }
+
+ System.out.println();
+ }
+
+ private void printScope(List<T> scope) {
+ for(T t : reverseIterable(scope)) {
+ System.out.println(t);
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ for(List<T> scope : scopeStack)
+ appendScopeContents(sb, scope);
+ appendScopeContents(sb, topScope);
+ return sb.toString();
+ }
+
+ private void appendScopeContents(StringBuilder sb, List<T> scope) {
+ sb.append('[');
+ boolean first = true;
+ for(T t : scope) {
+ if(first)
+ first = false;
+ else
+ sb.append(',');
+ sb.append(t);
+ }
+ sb.append(']');
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/TokenMap.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/TokenMap.java
new file mode 100644
index 00000000000..8589ad319db
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/TokenMap.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+* Copyright (c) 2006, 2008 IBM Corporation and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* IBM Corporation - initial API and implementation
+*********************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+
+
+/**
+ * Maps token kinds from a sub-parser back to the corresponding
+ * token kinds in a base parser.
+ *
+ * @author Mike Kucera
+ */
+public class TokenMap implements ITokenMap {
+
+ // LPG token kinds start at 0
+ // the kind is not part of the base language parser
+ public static int INVALID_KIND = -1;
+
+ private int[] kindMap = null;
+
+
+ /**
+ * @param toSymbols An array of symbols where the index is the token kind and the
+ * element data is a string representing the token kind. It is expected
+ * to pass the orderedTerminalSymbols field from an LPG generated symbol
+ * file, for example C99Parsersym.orderedTerminalSymbols.
+ */
+ public TokenMap(String[] toSymbols, String[] fromSymbols) {
+ // If this map is not being used with an extension then it becomes an "identity map".
+ if(toSymbols == fromSymbols)
+ return;
+
+ kindMap = new int[fromSymbols.length];
+ Map<String,Integer> toMap = new HashMap<String,Integer>();
+
+ for(int i = 0; i < toSymbols.length; i++) {
+ toMap.put(toSymbols[i], new Integer(i));
+ }
+
+ for(int i = 0; i < fromSymbols.length; i++) {
+ Integer kind = toMap.get(fromSymbols[i]);
+ kindMap[i] = kind == null ? INVALID_KIND : kind.intValue();
+ }
+ }
+
+
+ /**
+ * Maps a token kind back to the corresponding kind define in the base C99 parser.
+ */
+ public int mapKind(int kind) {
+ if(kindMap == null)
+ return kind;
+
+ if(kind < 0 || kind >= kindMap.length)
+ return INVALID_KIND;
+
+ return kindMap[kind];
+ }
+} \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99ASTNodeFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99ASTNodeFactory.java
new file mode 100644
index 00000000000..1dadbed0429
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99ASTNodeFactory.java
@@ -0,0 +1,425 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
+import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTForStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
+import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
+import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
+import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
+import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
+import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
+import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
+import org.eclipse.cdt.core.dom.lrparser.action.ASTCompletionNode;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTASMDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTAmbiguousExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTAmbiguousStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTArrayDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTArrayDesignator;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTArrayModifier;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTArraySubscriptExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTBinaryExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTBreakStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTCaseStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTCastExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTCompositeTypeSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTCompoundStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTConditionalExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTContinueStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTDeclarationStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTDefaultStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTDesignatedInitializer;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTDoStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTEnumerationSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTEnumerator;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTExpressionList;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTExpressionStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTFieldDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTFieldDesignator;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTFieldReference;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTForStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTFunctionCallExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTFunctionDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTFunctionDefinition;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTGotoStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTIdExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTIfStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTInitializerExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTInitializerList;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTKnRFunctionDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTLabelStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTLiteralExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTModifiedArrayModifier;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTName;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTNullStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTParameterDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTPointer;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTProblem;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTProblemDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTProblemExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTProblemStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTReturnStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTSimpleDeclSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTSimpleDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTSwitchStatement;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTTranslationUnit;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTTypeId;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTTypeIdExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTTypeIdInitializerExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTTypedefNameSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTUnaryExpression;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTWhileStatement;
+
+@SuppressWarnings("restriction") // all AST node constructors are internal
+/**
+ * Abstract factory implementation that creates AST nodes for C99.
+ * These can be overridden in subclasses to change the
+ * implementations of the nodes.
+ *
+ * @author Mike Kucera
+ */
+public class C99ASTNodeFactory implements IC99ASTNodeFactory {
+
+ public static final C99ASTNodeFactory DEFAULT_INSTANCE = new C99ASTNodeFactory();
+
+
+ public IASTName newName(char[] name) {
+ return new CASTName(name);
+ }
+
+ public IASTName newName() {
+ return new CASTName();
+ }
+
+ /**
+ * TODO: this should return IASTCompletionNode
+ */
+ public ASTCompletionNode newCompletionNode(String prefix, IASTTranslationUnit tu) {
+ return new ASTCompletionNode((prefix == null || prefix.length() == 0) ? null : prefix, tu);
+ }
+
+ public IASTLiteralExpression newLiteralExpression(int kind, String rep) {
+ return new CASTLiteralExpression(kind, rep);
+ }
+
+ public IASTIdExpression newIdExpression(IASTName name) {
+ return new CASTIdExpression(name);
+ }
+
+ public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) {
+ return new CASTBinaryExpression(op, expr1, expr2);
+ }
+
+ public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3) {
+ return new CASTConditionalExpression(expr1, expr2, expr3);
+ }
+
+ public IASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript) {
+ return new CASTArraySubscriptExpression(arrayExpr, subscript);
+ }
+
+ public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList) {
+ return new CASTFunctionCallExpression(idExpr, argList);
+ }
+
+ public IASTExpressionList newExpressionList() {
+ return new CASTExpressionList();
+ }
+
+ public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner, boolean isPointerDereference) {
+ return new CASTFieldReference(name, owner, isPointerDereference);
+ }
+
+ public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) {
+ return new CASTUnaryExpression(operator, operand);
+ }
+
+ public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
+ return new CASTTypeIdExpression(operator, typeId);
+ }
+
+ public ICASTTypeIdInitializerExpression newCTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializerList list) {
+ return new CASTTypeIdInitializerExpression(typeId, list);
+ }
+
+ public IASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand) {
+ return new CASTCastExpression(typeId, operand);
+ }
+
+ public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
+ return new CASTTypeId(declSpecifier, declarator);
+ }
+
+ public IASTDeclarator newDeclarator(IASTName name) {
+ return new CASTDeclarator(name);
+ }
+
+ public IASTArrayDeclarator newArrayDeclarator(IASTName name) {
+ return new CASTArrayDeclarator(name);
+ }
+
+ public ICASTArrayModifier newModifiedArrayModifier() {
+ return new CASTModifiedArrayModifier();
+ }
+
+ public IASTArrayModifier newArrayModifier(IASTExpression expr) {
+ return new CASTArrayModifier(expr);
+ }
+
+ public IASTStandardFunctionDeclarator newFunctionDeclarator(IASTName name) {
+ return new CASTFunctionDeclarator(name);
+ }
+
+ public ICASTKnRFunctionDeclarator newCKnRFunctionDeclarator() {
+ return new CASTKnRFunctionDeclarator();
+ }
+
+ public ICASTPointer newCPointer() {
+ return new CASTPointer();
+ }
+
+ public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
+ return new CASTParameterDeclaration(declSpec, declarator);
+ }
+
+ public IASTInitializerExpression newInitializerExpression(IASTExpression expression) {
+ return new CASTInitializerExpression(expression);
+ }
+
+ public IASTInitializerList newInitializerList() {
+ return new CASTInitializerList();
+ }
+
+ public ICASTDesignatedInitializer newCDesignatedInitializer(IASTInitializer rhs) {
+ return new CASTDesignatedInitializer(rhs);
+ }
+
+ public ICASTArrayDesignator newCArrayDesignator(IASTExpression exp) {
+ return new CASTArrayDesignator(exp);
+ }
+
+ public ICASTFieldDesignator newCFieldDesignator(IASTName name) {
+ return new CASTFieldDesignator(name);
+ }
+
+ public ICASTSimpleDeclSpecifier newCSimpleDeclSpecifier() {
+ return new CASTSimpleDeclSpecifier();
+ }
+
+ public ICASTTypedefNameSpecifier newCTypedefNameSpecifier() {
+ return new CASTTypedefNameSpecifier();
+ }
+
+ public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
+ return new CASTSimpleDeclaration(declSpecifier);
+ }
+
+ public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
+ return new CASTFieldDeclarator(name, bitFieldSize);
+ }
+
+ public ICASTCompositeTypeSpecifier newCCompositeTypeSpecifier(int key, IASTName name) {
+ return new CASTCompositeTypeSpecifier(key, name);
+ }
+
+ public IASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) {
+ return new CASTElaboratedTypeSpecifier(kind, name);
+ }
+
+ public IASTEnumerator newEnumerator(IASTName name, IASTExpression value) {
+ return new CASTEnumerator(name, value);
+ }
+
+ public IASTCompoundStatement newCompoundStatement() {
+ return new CASTCompoundStatement();
+ }
+
+ public IASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
+ IASTExpression iterationExpression, IASTStatement body) {
+ return new CASTForStatement(init, condition, iterationExpression, body);
+ }
+
+ public IASTExpressionStatement newExpressionStatement(IASTExpression expr) {
+ return new CASTExpressionStatement(expr);
+ }
+
+ public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) {
+ return new CASTDeclarationStatement(declaration);
+ }
+
+ public IASTNullStatement newNullStatement() {
+ return new CASTNullStatement();
+ }
+
+ public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
+ return new CASTWhileStatement(condition, body);
+ }
+
+ public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) {
+ return new CASTDoStatement(body, condition);
+ }
+
+ public IASTGotoStatement newGotoStatement(IASTName name) {
+ return new CASTGotoStatement(name);
+ }
+
+ public IASTContinueStatement newContinueStatement() {
+ return new CASTContinueStatement();
+ }
+
+ public IASTBreakStatement newBreakStatement() {
+ return new CASTBreakStatement();
+ }
+
+ public IASTReturnStatement newReturnStatement(IASTExpression retValue) {
+ return new CASTReturnStatement(retValue);
+ }
+
+ public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement) {
+ return new CASTLabelStatement(name, nestedStatement);
+ }
+
+ public IASTCaseStatement newCaseStatement(IASTExpression expression) {
+ return new CASTCaseStatement(expression);
+ }
+
+ public IASTDefaultStatement newDefaultStatement() {
+ return new CASTDefaultStatement();
+ }
+
+ public IASTSwitchStatement newSwitchStatment(IASTExpression controller, IASTStatement body) {
+ return new CASTSwitchStatement(controller, body);
+ }
+
+ public IASTIfStatement newIfStatement(IASTExpression expr, IASTStatement thenStat, IASTStatement elseClause) {
+ return new CASTIfStatement(expr, thenStat, elseClause);
+ }
+
+ public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
+ IASTFunctionDeclarator declarator, IASTStatement bodyStatement) {
+ return new CASTFunctionDefinition(declSpecifier, declarator, bodyStatement);
+ }
+
+ public IASTProblemDeclaration newProblemDeclaration() {
+ return new CASTProblemDeclaration();
+ }
+
+ public IASTProblemStatement newProblemStatement() {
+ return new CASTProblemStatement();
+ }
+
+ public IASTProblemExpression newProblemExpression() {
+ return new CASTProblemExpression();
+ }
+
+ public IASTProblem newProblem(int id, char[] arg, boolean warn, boolean error) {
+ return new CASTProblem(id, arg, warn, error);
+ }
+
+ public IASTAmbiguousExpression newAmbiguousExpression() {
+ return new CASTAmbiguousExpression();
+ }
+
+ public IASTAmbiguousStatement newAmbiguousStatement() {
+ return new CASTAmbiguousStatement();
+ }
+
+ public IASTTranslationUnit newTranslationUnit() {
+ return new CASTTranslationUnit();
+ }
+
+ public IASTASMDeclaration newASMDeclaration(String assembly) {
+ return new CASTASMDeclaration(assembly);
+ }
+
+ public ICASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) {
+ return new CASTEnumerationSpecifier(name);
+ }
+
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99BuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99BuildASTParserAction.java
new file mode 100644
index 00000000000..69020d7568d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99BuildASTParserAction.java
@@ -0,0 +1,974 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Completion;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK__Bool;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK__Complex;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_auto;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_char;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_const;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_double;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_extern;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_float;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_identifier;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_inline;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_int;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_long;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_register;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_restrict;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_short;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_signed;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_static;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_typedef;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_unsigned;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_void;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_volatile;
+
+import java.util.List;
+
+import lpg.lpgjavaruntime.IToken;
+
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTPointer;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
+import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
+import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
+import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
+import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
+import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+import org.eclipse.cdt.core.dom.lrparser.action.BuildASTParserAction;
+import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
+import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
+import org.eclipse.cdt.core.dom.lrparser.util.CollectionUtils;
+import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym;
+import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+
+/**
+ * Semantic actions called by the C99 parser to build an AST.
+ *
+ * @author Mike Kucera
+ */
+@SuppressWarnings("restriction")
+public class C99BuildASTParserAction extends BuildASTParserAction {
+
+ private ITokenMap tokenMap = null;
+
+ /** Used to create the AST node objects */
+ protected final IC99ASTNodeFactory nodeFactory;
+
+ /**
+ * @param parser
+ * @param orderedTerminalSymbols When an instance of this class is created for a parser
+ * that parsers token kinds will be mapped back to the base C99 parser's token kinds.
+ */
+ public C99BuildASTParserAction(IC99ASTNodeFactory nodeFactory, IParserActionTokenProvider parser, IASTTranslationUnit tu) {
+ super(nodeFactory, parser, tu);
+ this.nodeFactory = nodeFactory;
+ }
+
+
+ @Override protected boolean isCompletionToken(IToken token) {
+ return asC99Kind(token) == TK_Completion;
+ }
+
+
+ public void setTokenMap(String[] orderedTerminalSymbols) {
+ this.tokenMap = new TokenMap(C99Parsersym.orderedTerminalSymbols, orderedTerminalSymbols);
+ }
+
+
+ int asC99Kind(IToken token) {
+ return asC99Kind(token.getKind());
+ }
+
+ private int asC99Kind(int tokenKind) {
+ return tokenMap == null ? tokenKind : tokenMap.mapKind(tokenKind);
+ }
+
+
+
+
+
+ /********************************************************************
+ * Start of semantic actions.
+ ********************************************************************/
+
+
+ /**
+ * postfix_expression ::= postfix_expression '.' ident
+ * postfix_expression ::= postfix_expression '->' ident
+ */
+ public void consumeExpressionFieldReference(/*IBinding field, */ boolean isPointerDereference) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = createName(parser.getRightIToken());
+ //name.setBinding(field);
+ IASTExpression owner = (IASTExpression) astStack.pop();
+ IASTFieldReference expr = nodeFactory.newFieldReference(name, owner, isPointerDereference);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * postfix_expression ::= '(' type_name ')' '{' <openscope> initializer_list '}'
+ * postfix_expression ::= '(' type_name ')' '{' <openscope> initializer_list ',' '}'
+ */
+ public void consumeExpressionTypeIdInitializer() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ consumeInitializerList(); // closes the scope
+ IASTInitializerList list = (IASTInitializerList) astStack.pop();
+ IASTTypeId typeId = (IASTTypeId) astStack.pop();
+ ICASTTypeIdInitializerExpression expr = nodeFactory.newCTypeIdInitializerExpression(typeId, list);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * Sets a token specifier.
+ * Needs to be overrideable for new decl spec keywords.
+ *
+ * @param token Allows subclasses to override this method and use any
+ * object to determine how to set a specifier.
+ */
+ protected void setSpecifier(ICASTDeclSpecifier node, IToken token) {
+ int kind = asC99Kind(token);
+ switch(kind){
+ case TK_typedef: node.setStorageClass(IASTDeclSpecifier.sc_typedef); return;
+ case TK_extern: node.setStorageClass(IASTDeclSpecifier.sc_extern); return;
+ case TK_static: node.setStorageClass(IASTDeclSpecifier.sc_static); return;
+ case TK_auto: node.setStorageClass(IASTDeclSpecifier.sc_auto); return;
+ case TK_register: node.setStorageClass(IASTDeclSpecifier.sc_register); return;
+ case TK_inline: node.setInline(true); return;
+ case TK_const: node.setConst(true); return;
+ case TK_restrict: node.setRestrict(true); return;
+ case TK_volatile: node.setVolatile(true); return;
+ }
+
+ if(node instanceof ICASTSimpleDeclSpecifier) {
+ ICASTSimpleDeclSpecifier n = (ICASTSimpleDeclSpecifier) node;
+ switch(kind) {
+ case TK_void: n.setType(IASTSimpleDeclSpecifier.t_void); break;
+ case TK_char: n.setType(IASTSimpleDeclSpecifier.t_char); break;
+ case TK__Bool: n.setType(ICASTSimpleDeclSpecifier.t_Bool); break;
+ case TK_int: n.setType(IASTSimpleDeclSpecifier.t_int); break;
+ case TK_float: n.setType(IASTSimpleDeclSpecifier.t_float); break;
+ case TK_double: n.setType(IASTSimpleDeclSpecifier.t_double); break;
+ case TK_signed: n.setSigned(true); break;
+ case TK_unsigned: n.setUnsigned(true); break;
+ case TK_short: n.setShort(true); break;
+ case TK__Complex: n.setComplex(true); break;
+ case TK_long:
+ boolean isLong = n.isLong();
+ n.setLongLong(isLong);
+ n.setLong(!isLong);
+ break;
+ }
+ }
+ }
+
+
+
+
+ @Deprecated public void consumeDeclaratorComplete(/*IBinding binding*/) {
+// if(DEBUG) DebugUtil.printMethodTrace();
+//
+// IASTDeclarator declarator = (IASTDeclarator) astStack.peek();
+//
+// IASTDeclarator nested;
+// while((nested = declarator.getNestedDeclarator()) != null) {
+// declarator = nested;
+// }
+//
+// //declarator.getName().setBinding(binding);
+ }
+
+
+ /**
+ * declarator ::= <openscope> pointer direct_declarator
+ *
+ * abstract_declarator -- a declarator that does not include an identifier
+ * ::= <openscope> pointer
+ * | <openscope> pointer direct_abstract_declarator
+ */
+ public void consumeDeclaratorWithPointer(boolean hasDeclarator) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclarator decl;
+ if(hasDeclarator)
+ decl = (IASTDeclarator) astStack.pop();
+ else
+ decl = nodeFactory.newDeclarator(nodeFactory.newName());
+
+ // add all the pointers to the declarator
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> scope = astStack.closeScope();
+
+ for(Object o : scope) {
+ decl.addPointerOperator((ICASTPointer)o);
+ }
+
+ setOffsetAndLength(decl);
+ astStack.push(decl);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+
+
+ /**
+ * type_qualifier ::= const | restrict | volatile
+ */
+ private void collectArrayModifierTypeQualifiers(ICASTArrayModifier arrayModifier) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+ for(Object o : astStack.closeScope()) {
+ switch(asC99Kind((IToken)o)) {
+ case TK_const:
+ arrayModifier.setConst(true);
+ break;
+ case TK_restrict:
+ arrayModifier.setRestrict(true);
+ break;
+ case TK_volatile:
+ arrayModifier.setVolatile(true);
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * array_modifier
+ * ::= '[' <openscope> type_qualifier_list ']'
+ * | '[' <openscope> type_qualifier_list assignment_expression ']'
+ * | '[' 'static' assignment_expression ']'
+ * | '[' 'static' <openscope> type_qualifier_list assignment_expression ']'
+ * | '[' <openscope> type_qualifier_list 'static' assignment_expression ']'
+ * | '[' '*' ']'
+ * | '[' <openscope> type_qualifier_list '*' ']'
+ *
+ * The main reason to separate array_modifier into its own rule is to
+ * make calculating the offset and length much easier.
+ */
+ public void consumeDirectDeclaratorModifiedArrayModifier(boolean isStatic,
+ boolean isVarSized, boolean hasTypeQualifierList, boolean hasAssignmentExpr) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ assert isStatic || isVarSized || hasTypeQualifierList;
+
+ ICASTArrayModifier arrayModifier = nodeFactory.newModifiedArrayModifier();
+
+ // consume all the stuff between the square brackets into an array modifier
+ arrayModifier.setStatic(isStatic);
+ arrayModifier.setVariableSized(isVarSized);
+
+ if(hasAssignmentExpr)
+ arrayModifier.setConstantExpression((IASTExpression)astStack.pop());
+
+ if(hasTypeQualifierList)
+ collectArrayModifierTypeQualifiers(arrayModifier);
+
+ setOffsetAndLength(arrayModifier);
+ astStack.push(arrayModifier);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+
+ /**
+ * init_declarator ::= declarator '=' initializer
+ */
+ public void consumeDeclaratorWithInitializer() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTInitializer initializer = (IASTInitializer) astStack.pop();
+ IASTDeclarator declarator = (IASTDeclarator) astStack.peek();
+ declarator.setInitializer(initializer);
+ setOffsetAndLength(declarator); // adjust the length to include the initializer
+ }
+
+
+ @Deprecated public void consumeDeclaratorCompleteField(/*IBinding binding*/) {
+ //IASTDeclarator declarator = (IASTDeclarator) astStack.peek();
+ //declarator.getName().setBinding(binding);
+ }
+
+
+ /**
+ * direct_declarator ::= direct_declarator '(' <openscope> parameter_type_list ')'
+ * direct_declarator ::= direct_declarator '(' ')'
+ */
+ public void consumeDirectDeclaratorFunctionDeclarator(boolean hasParameters) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = nodeFactory.newName();
+ IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name);
+
+ if(hasParameters) {
+ boolean isVarArgs = astStack.pop() == PLACE_HOLDER;
+ declarator.setVarArgs(isVarArgs);
+
+ for(Object o : astStack.closeScope()) {
+ declarator.addParameterDeclaration((IASTParameterDeclaration)o);
+ }
+ }
+
+ int endOffset = endOffset(parser.getRightIToken());
+ consumeDirectDeclaratorFunctionDeclarator(declarator, endOffset);
+ }
+
+
+ /**
+ * direct_declarator ::= direct_declarator '(' <openscope> identifier_list ')'
+ */
+ public void consumeDirectDeclaratorFunctionDeclaratorKnR() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ ICASTKnRFunctionDeclarator declarator = nodeFactory.newCKnRFunctionDeclarator();
+ IASTName[] names = astStack.topScope().toArray(new IASTName[0]);
+ declarator.setParameterNames(names);
+ astStack.closeScope();
+ int endOffset = endOffset(parser.getRightIToken());
+ consumeDirectDeclaratorFunctionDeclarator(declarator, endOffset);
+ }
+
+
+ /**
+ * identifier_list
+ * ::= 'identifier'
+ * | identifier_list ',' 'identifier'
+ */
+ public void consumeIdentifierKnR() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = createName(parser.getRightIToken());
+ astStack.push(name);
+ }
+
+
+
+
+
+
+ /**
+ * pointer ::= '*'
+ * | pointer '*'
+ */
+ public void consumePointer() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTPointer pointer = nodeFactory.newCPointer();
+ IToken star = parser.getRightIToken();
+ setOffsetAndLength(pointer, star);
+ astStack.push(pointer);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * pointer ::= '*' <openscope> type_qualifier_list
+ * | pointer '*' <openscope> type_qualifier_list
+ */
+ public void consumePointerTypeQualifierList() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ ICASTPointer pointer = nodeFactory.newCPointer();
+
+ for(Object o : astStack.closeScope()) {
+ IToken token = (IToken)o;
+ switch(asC99Kind(token)) {
+ default: assert false;
+ case TK_const: pointer.setConst(true); break;
+ case TK_volatile: pointer.setVolatile(true); break;
+ case TK_restrict: pointer.setRestrict(true); break;
+ }
+ }
+
+ setOffsetAndLength(pointer);
+ astStack.push(pointer);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * parameter_declaration ::= declaration_specifiers declarator
+ * | declaration_specifiers abstract_declarator
+ */
+ public void consumeParameterDeclaration() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclarator declarator = (IASTDeclarator) astStack.pop();
+ IASTDeclSpecifier declSpec = (IASTDeclSpecifier) astStack.pop();
+ IASTParameterDeclaration declaration = nodeFactory.newParameterDeclaration(declSpec, declarator);
+ setOffsetAndLength(declaration);
+ astStack.push(declaration);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * parameter_declaration ::= declaration_specifiers
+ */
+ public void consumeParameterDeclarationWithoutDeclarator(/*IBinding binding*/) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ // offsets need to be calculated differently in this case
+ final int endOffset = parser.getRightIToken().getEndOffset() + 1;
+
+ IASTName name = nodeFactory.newName();
+ setOffsetAndLength(name, endOffset, 0);
+ //name.setBinding(binding);
+
+ // it appears that a declarator is always required in the AST here
+ IASTDeclarator declarator = nodeFactory.newDeclarator(name);
+ setOffsetAndLength(declarator, endOffset, 0);
+
+ IASTDeclSpecifier declSpec = (IASTDeclSpecifier) astStack.pop();
+ IASTParameterDeclaration declaration = nodeFactory.newParameterDeclaration(declSpec, declarator);
+
+ setOffsetAndLength(declaration);
+ astStack.push(declaration);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ @Deprecated public void consumeDeclaratorCompleteParameter(/*IBinding binding*/) {
+ //if(DEBUG) DebugUtil.printMethodTrace();
+
+ //IASTDeclarator declarator = (IASTDeclarator) astStack.peek();
+ //declarator.getName().setBinding(binding);
+ }
+
+
+ /**
+ * direct_abstract_declarator
+ * ::= array_modifier
+ * | direct_abstract_declarator array_modifier
+ */
+ public void consumeAbstractDeclaratorArrayModifier(boolean hasDeclarator) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTArrayModifier arrayModifier = (IASTArrayModifier) astStack.pop();
+
+ if(hasDeclarator) {
+ consumeDeclaratorArray(arrayModifier);
+ }
+ else {
+ IASTArrayDeclarator decl = nodeFactory.newArrayDeclarator(nodeFactory.newName());
+ decl.addArrayModifier(arrayModifier);
+ setOffsetAndLength(decl);
+ astStack.push(decl);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+ }
+
+
+ /**
+ * direct_abstract_declarator
+ * ::= '(' ')'
+ * | direct_abstract_declarator '(' ')'
+ * | '(' <openscope> parameter_type_list ')'
+ * | direct_abstract_declarator '(' <openscope> parameter_type_list ')'
+ */
+ public void consumeAbstractDeclaratorFunctionDeclarator(boolean hasDeclarator, boolean hasParameters) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(nodeFactory.newName());
+
+ if(hasParameters) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+ for(Object o : astStack.closeScope()) {
+ declarator.addParameterDeclaration((IASTParameterDeclaration)o);
+ }
+ }
+
+ if(hasDeclarator) {
+ consumeDirectDeclaratorFunctionDeclarator(declarator, endOffset(parser.getRightIToken()));
+ }
+ else {
+ setOffsetAndLength(declarator);
+ astStack.push(declarator);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+ }
+
+
+
+ /**
+ * designated_initializer ::= <openscope> designation initializer
+ */
+ public void consumeInitializerDesignated() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTInitializer initializer = (IASTInitializer)astStack.pop();
+ ICASTDesignatedInitializer result = nodeFactory.newCDesignatedInitializer(initializer);
+
+ for(Object o : astStack.closeScope())
+ result.addDesignator((ICASTDesignator)o);
+
+ setOffsetAndLength(result);
+ astStack.push(result);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * designator ::= '[' constant_expression ']'
+ */
+ public void consumeDesignatorArray() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr = (IASTExpression) astStack.pop();
+ ICASTArrayDesignator designator = nodeFactory.newCArrayDesignator(expr);
+ setOffsetAndLength(designator);
+ astStack.push(designator);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * designator ::= '.' 'identifier'
+ */
+ public void consumeDesignatorField(/*IBinding binding*/) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = createName( parser.getRightIToken() );
+ //name.setBinding(binding);
+ ICASTFieldDesignator designator = nodeFactory.newCFieldDesignator(name);
+ setOffsetAndLength(designator);
+ astStack.push(designator);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * declaration_specifiers ::= <openscope> simple_declaration_specifiers
+ */
+ public void consumeDeclarationSpecifiersSimple() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ ICASTSimpleDeclSpecifier declSpec = nodeFactory.newCSimpleDeclSpecifier();
+
+ for(Object token : astStack.closeScope())
+ setSpecifier(declSpec, (IToken)token);
+
+ setOffsetAndLength(declSpec);
+ astStack.push(declSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * declaration_specifiers ::= <openscope> struct_or_union_declaration_specifiers
+ * declaration_specifiers ::= <openscope> enum_declaration_specifiers
+ */
+ public void consumeDeclarationSpecifiersStructUnionEnum() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> topScope = astStack.closeScope();
+ ICASTDeclSpecifier declSpec = CollectionUtils.findFirstAndRemove(topScope, ICASTDeclSpecifier.class);
+
+ // now apply the rest of the specifiers
+ for(Object token : topScope)
+ setSpecifier(declSpec, (IToken)token);
+
+ setOffsetAndLength(declSpec);
+ astStack.push(declSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * declaration_specifiers ::= <openscope> typdef_name_declaration_specifiers
+ */
+ public void consumeDeclarationSpecifiersTypedefName() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ ICASTTypedefNameSpecifier declSpec = nodeFactory.newCTypedefNameSpecifier();
+
+ for(Object o : astStack.topScope()) {
+ if(o instanceof IToken) {
+ IToken token = (IToken) o;
+ // There is one identifier token on the stack
+ int kind = asC99Kind(token);
+ if(kind == TK_identifier || kind == TK_Completion) {
+ IASTName name = createName(token);
+ //name.setBinding(binding);
+ declSpec.setName(name);
+ }
+ else {
+ setSpecifier(declSpec, token);
+ }
+ }
+ }
+
+ astStack.closeScope();
+ setOffsetAndLength(declSpec);
+ astStack.push(declSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * external_declaration ::= ';'
+ *
+ * TODO: doesn't the declaration need a name?
+ */
+ public void consumeDeclarationEmpty() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclSpecifier declSpecifier = nodeFactory.newCSimpleDeclSpecifier();
+ IASTSimpleDeclaration declaration = nodeFactory.newSimpleDeclaration(declSpecifier);
+ setOffsetAndLength(declSpecifier);
+ setOffsetAndLength(declaration);
+ astStack.push(declaration);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * a declaration inside of a struct
+ *
+ * struct_declaration ::= specifier_qualifier_list <openscope> struct_declarator_list ';'
+ *
+ * specifier_qualifier_list is a subset of declaration_specifiers,
+ * struct_declarators are declarators that are allowed inside a struct,
+ * a struct declarator is a regular declarator plus bit fields
+ */
+ public void consumeStructDeclaration(boolean hasDeclaration) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ consumeDeclarationSimple(hasDeclaration); // TODO this is ok as long as bit fields implement IASTDeclarator (see consumeDeclaration())
+ }
+
+
+ /**
+ * struct_declarator
+ * ::= ':' constant_expression
+ * | declarator ':' constant_expression
+ */
+ public void consumeStructBitField(boolean hasDeclarator) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr = (IASTExpression)astStack.pop();
+
+ IASTName name;
+ if(hasDeclarator) // it should have been parsed into a regular declarator
+ name = ((IASTDeclarator) astStack.pop()).getName();
+ else
+ name = nodeFactory.newName();
+
+ IASTFieldDeclarator fieldDecl = nodeFactory.newFieldDeclarator(name, expr);
+ setOffsetAndLength(fieldDecl);
+ astStack.push(fieldDecl);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * struct_or_union_specifier
+ * ::= 'struct' '{' <openscope> struct_declaration_list_opt '}'
+ * | 'union' '{' <openscope> struct_declaration_list_opt '}'
+ * | 'struct' struct_or_union_identifier '{' <openscope> struct_declaration_list_opt '}'
+ * | 'union' struct_or_union_identifier '{' <openscope> struct_declaration_list_opt '}'
+ *
+ * @param key either k_struct or k_union from IASTCompositeTypeSpecifier
+ */
+ public void consumeTypeSpecifierComposite(boolean hasName, int key) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = (hasName) ? createName(parser.getRuleTokens().get(1)) : nodeFactory.newName();
+
+ ICASTCompositeTypeSpecifier typeSpec = nodeFactory.newCCompositeTypeSpecifier(key, name);
+
+ for(Object o : astStack.closeScope())
+ typeSpec.addMemberDeclaration((IASTDeclaration)o);
+
+ setOffsetAndLength(typeSpec);
+ astStack.push(typeSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * struct_or_union_specifier
+ * ::= 'struct' struct_or_union_identifier
+ * | 'union' struct_or_union_identifier
+ *
+ * enum_specifier ::= 'enum' enum_identifier
+ */
+ public void consumeTypeSpecifierElaborated(int kind /*, IBinding binding*/) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = createName(parser.getRuleTokens().get(1));
+ //name.setBinding(binding);
+ IASTElaboratedTypeSpecifier typeSpec = nodeFactory.newElaboratedTypeSpecifier(kind, name);
+ setOffsetAndLength(typeSpec);
+ astStack.push(typeSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+
+ /**
+ * iteration_statement ::= 'while' '(' expression ')' statement
+ */
+ public void consumeStatementWhileLoop() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStatement body = (IASTStatement) astStack.pop();
+ IASTExpression condition = (IASTExpression) astStack.pop();
+ IASTWhileStatement whileStatement = nodeFactory.newWhileStatement(condition, body);
+ setOffsetAndLength(whileStatement);
+ astStack.push(whileStatement);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * block_item ::= declaration | statement
+ *
+ * Wrap a declaration in a DeclarationStatement.
+ */
+ public void consumeStatementDeclaration() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclaration decl = (IASTDeclaration) astStack.pop();
+
+ if(disambiguateHackIdentifierExpression(decl))
+ return;
+
+ IASTDeclarationStatement stat = nodeFactory.newDeclarationStatement(decl);
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+
+
+ /**
+ * Kludgy way to disambiguate a certain case.
+ * An identifier alone on a line will be parsed as a declaration
+ * but it probably should be an expression.
+ * eg) i;
+ *
+ * This only happens in the presence of a completion token.
+ *
+ * @return true if the hack was applied
+ */
+ private boolean disambiguateHackIdentifierExpression(IASTDeclaration decl) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ // this is only meant to work with content assist
+ List<IToken> tokens = parser.getRuleTokens();
+ if(tokens.size() != 2 || tokens.get(0).getKind() == TK_typedef)
+ return false;
+
+ if(decl instanceof IASTSimpleDeclaration) {
+ IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) decl;
+ if(declaration.getDeclarators() == IASTDeclarator.EMPTY_DECLARATOR_ARRAY) {
+ IASTDeclSpecifier declSpec = declaration.getDeclSpecifier();
+ if(declSpec instanceof ICASTTypedefNameSpecifier) {
+ ICASTTypedefNameSpecifier typedefNameSpec = (ICASTTypedefNameSpecifier) declSpec;
+ IASTName name = typedefNameSpec.getName();
+
+ if(offset(name) == offset(typedefNameSpec) && length(name) == length(typedefNameSpec)) {
+ IASTIdExpression idExpr = nodeFactory.newIdExpression(name);
+ IASTExpressionStatement stat = nodeFactory.newExpressionStatement(idExpr);
+
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+
+
+ /**
+ * selection_statement ::= switch '(' expression ')' statement
+ */
+ public void consumeStatementSwitch() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStatement body = (IASTStatement) astStack.pop();
+ IASTExpression expr = (IASTExpression) astStack.pop();
+ IASTSwitchStatement stat = nodeFactory.newSwitchStatment(expr, body);
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ public void consumeStatementIf(boolean hasElse) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStatement elseClause = null;
+ if(hasElse)
+ elseClause = (IASTStatement) astStack.pop();
+
+ IASTStatement thenClause = (IASTStatement) astStack.pop();
+ IASTExpression condition = (IASTExpression) astStack.pop();
+
+ IASTIfStatement ifStatement = nodeFactory.newIfStatement(condition, thenClause, elseClause);
+ setOffsetAndLength(ifStatement);
+ astStack.push(ifStatement);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * function_definition
+ * ::= declaration_specifiers <openscope> declarator compound_statement
+ * | function_declarator compound_statement
+ *
+ * The seemingly pointless <openscope> is just there to
+ * prevent a shift/reduce conflict in the grammar.
+ */
+ public void consumeFunctionDefinition(boolean hasDeclSpecifiers) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace(String.valueOf(hasDeclSpecifiers));
+
+ IASTCompoundStatement body = (IASTCompoundStatement) astStack.pop();
+ IASTFunctionDeclarator decl = (IASTFunctionDeclarator) astStack.pop();
+ astStack.closeScope();
+
+ IASTDeclSpecifier declSpecifier;
+ if(hasDeclSpecifiers) {
+ declSpecifier = (IASTDeclSpecifier) astStack.pop();
+ }
+ else { // there are no decl specifiers, implicit int
+ declSpecifier = nodeFactory.newCSimpleDeclSpecifier();
+ }
+
+ IASTFunctionDefinition def = nodeFactory.newFunctionDefinition(declSpecifier, decl, body);
+ setOffsetAndLength(def);
+ astStack.push(def);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ @Deprecated public void consumeFunctionDefinitionHeader(/*IBinding binding*/) {
+// Object o = astStack.peek();
+// if(o instanceof IASTFunctionDeclarator) {
+// ((IASTFunctionDeclarator)o).getName().setBinding(binding);
+// }
+ }
+
+
+ /**
+ * function_definition
+ * ::= declaration_specifiers <openscope> declarator
+ * <openscope> declaration_list compound_statement
+ */
+ public void consumeFunctionDefinitionKnR() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTCompoundStatement body = (IASTCompoundStatement) astStack.pop();
+
+ IASTDeclaration[] declarations = (IASTDeclaration[]) astStack.topScope().toArray(new IASTDeclaration[0]);
+ astStack.closeScope();
+
+ ICASTKnRFunctionDeclarator decl = (ICASTKnRFunctionDeclarator) astStack.pop();
+ astStack.closeScope();
+
+ ICASTSimpleDeclSpecifier declSpecifier = (ICASTSimpleDeclSpecifier) astStack.pop();
+ decl.setParameterDeclarations(declarations);
+
+ // re-compute the length of the declaration to take the parameter declarations into account
+ ASTNode lastDeclaration = (ASTNode) declarations[declarations.length-1];
+ int endOffset = lastDeclaration.getOffset() + lastDeclaration.getLength();
+ ((ASTNode)decl).setLength(endOffset - offset(decl));
+
+ IASTFunctionDefinition def = nodeFactory.newFunctionDefinition(declSpecifier, decl, body);
+ setOffsetAndLength(def);
+ astStack.push(def);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+} \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99ResolveParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99ResolveParserAction.java
new file mode 100644
index 00000000000..9a92132015d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99ResolveParserAction.java
@@ -0,0 +1,1560 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import static org.eclipse.cdt.core.dom.lrparser.action.c99.CNamespace.GOTO_LABEL;
+import static org.eclipse.cdt.core.dom.lrparser.action.c99.CNamespace.IDENTIFIER;
+import static org.eclipse.cdt.core.dom.lrparser.action.c99.CNamespace.STRUCT_TAG;
+import static org.eclipse.cdt.core.dom.lrparser.util.CollectionUtils.reverseIterable;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import lpg.lpgjavaruntime.IToken;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IArrayType;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IFunctionType;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IPointerType;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+import org.eclipse.cdt.core.dom.lrparser.action.ScopedStack;
+import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99ArrayType;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99BasicType;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Enumeration;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Enumerator;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Field;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Function;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99FunctionScope;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99FunctionType;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Label;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Parameter;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99PointerType;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99ProblemBinding;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Scope;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Structure;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Typedef;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Variable;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.IC99Binding;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.IC99Scope;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.ITypeable;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+/**
+ * This class was an attempt at doing full binding resolution during the parse
+ * as opposed to doing it after the parse as is normally done with the DOM parser.
+ *
+ *
+ * TODO: token mapping so that this will work with UPC
+ * TODO: what about function definitions, don't they count as declarations?
+ *
+ * Try to resolve bindings without using the ASTStack, that way I can resolve bindings
+ * without generating an AST. In the future I can remove this as a subclass of C99ParserAction.
+ *
+ * TODO: if I'm calculating scopes then those scopes need to be linked to AST nodes
+ *
+ * TODO: some language constructs are not handled yet: typeIds (casts), field designators
+ *
+ * @author Mike Kucera
+ *
+ * @deprecated Binding resolution is too hard, replacing with simpler C99TypedefTrackerParserAction
+ */
+@SuppressWarnings("restriction")
+@Deprecated public class C99ResolveParserAction {
+
+ private static final boolean DEBUG = true;
+ private static final String NO_IDENT = ""; //$NON-NLS-1$
+
+
+ // provides limited access to the token stream
+ private final IParserActionTokenProvider parser;
+
+ // The symbolTable currently in use
+ private C99SymbolTable symbolTable = C99SymbolTable.EMPTY_TABLE;
+
+ // A stack that keeps track of scopes in the symbol table, used to "close" scopes and to undo the opening of scopes
+ private final LinkedList<C99SymbolTable> symbolTableScopeStack = new LinkedList<C99SymbolTable>();
+
+ // A stack that keeps track of scopes that are set on bindings
+ private final LinkedList<IC99Scope> bindingScopeStack = new LinkedList<IC99Scope>();
+
+ // keeps track of nested declarations
+ private final LinkedList<DeclaratorFrame> declarationStack = new LinkedList<DeclaratorFrame>();
+
+ // keeps track of expression types
+ private final ScopedStack<IType> exprTypeStack = new ScopedStack<IType>();
+
+
+
+
+
+ private TypeQualifiers typeQualifiers; // TODO: can this go in the declaration stack?
+
+ private static class TypeQualifiers {
+ boolean isConst, isRestrict, isVolatile;
+ }
+
+
+ // "For every action there is an equal and opposite reaction." - Newton's third law
+ private final LinkedList<IUndoAction> undoStack = new LinkedList<IUndoAction>();
+
+
+ private interface IUndoAction {
+ void undo();
+ }
+
+ public void undo() {
+ undoStack.removeLast().undo();
+ }
+
+ public void undo(int steps) {
+ for(int i = 0; i < steps; i++) {
+ undo();
+ }
+ }
+
+ public IC99Scope getCurrentScope() {
+ return bindingScopeStack.getLast();
+ }
+
+
+ public C99ResolveParserAction(IParserActionTokenProvider parser) {
+ this.parser = parser;
+ bindingScopeStack.add(new C99Scope()); // the global scope
+ System.out.println();
+ }
+
+
+ private static IType rawType(IType type) {
+ while(type instanceof ITypedef) {
+ type = ((C99Typedef)type).getType();
+ }
+ return type;
+ }
+
+ /**
+ * Lexer feedback hack, used by the parser to identify typedefname tokens.
+ */
+ public boolean isTypedef(String ident) {
+ boolean result = symbolTable.lookup(IDENTIFIER, ident) instanceof ITypedef;
+ return result;
+ }
+
+
+ /**
+ * Methods used by tests, package local access.
+ */
+ C99SymbolTable getSymbolTable() {
+ return symbolTable;
+ }
+
+ int undoStackSize() {
+ return undoStack.size();
+ }
+
+ LinkedList<DeclaratorFrame> getDeclarationStack() {
+ return declarationStack;
+ }
+
+
+ /**
+ * Called from the grammar file in places where a scope is created.
+ *
+ * Scopes are created by compound statements, however special care
+ * must also be taken with for loops because they may contain
+ * declarations.
+ *
+ * TODO: scope object now need to be handled explicitly
+ */
+ public void openSymbolScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ symbolTableScopeStack.add(symbolTable);
+ bindingScopeStack.add(new C99Scope());
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace("undo");
+
+ bindingScopeStack.removeLast();
+ symbolTable = symbolTableScopeStack.removeLast();
+ }
+ });
+ }
+
+
+ public IC99Scope closeSymbolScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final C99SymbolTable undoTable = symbolTable;
+ symbolTable = symbolTableScopeStack.removeLast(); // close the scope
+
+ final IC99Scope undoScope = bindingScopeStack.removeLast();
+ if(!bindingScopeStack.isEmpty())
+ undoScope.setParent(bindingScopeStack.getLast());
+
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ undoScope.setParent(null);
+ bindingScopeStack.add(undoScope);
+
+ symbolTableScopeStack.add(symbolTable);
+ symbolTable = undoTable;
+ }
+ });
+
+ return undoScope;
+ }
+
+
+ // TODO, this needs an undo action
+ public void openPointerScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.openPointerModifierScope();
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ frame.closePointerModifierScope();
+ }
+ });
+ }
+
+
+ /**
+ * Called from the grammar before a declaration is about to be reduced.
+ */
+ public void openDeclarationScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.add(new DeclaratorFrame());
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.removeLast();
+ }
+ });
+ }
+
+
+ public void closeDeclarationScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame undoFrame = declarationStack.removeLast();
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.add(undoFrame);
+ }
+ });
+ }
+
+
+ public void consumeFunctionDefinition() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+// final IC99Scope undoScope = bindingScope;
+//
+// C99FunctionScope functionScope = new C99FunctionScope();
+// functionScope.setBodyScope(undoScope);
+// undoScope.setParent(functionScope);
+// bindingScope = bindingScopeStack.removeLast();
+// functionScope.setParent(bindingScope);
+
+
+ final IC99Scope undoScope = bindingScopeStack.removeLast();
+
+ C99FunctionScope functionScope = new C99FunctionScope();
+ functionScope.setBodyScope(undoScope);
+ undoScope.setParent(functionScope);
+ functionScope.setParent(bindingScopeStack.getLast());
+
+
+ final DeclaratorFrame frame = declarationStack.removeLast();
+
+ // the function binding needs to be available outside of the function's scope
+ String functionName = frame.getDeclaratorName().toString();
+ C99Function functionBinding = (C99Function) symbolTable.lookup(IDENTIFIER, functionName);
+ functionBinding.setFunctionScope(functionScope);
+
+ final C99SymbolTable undoTable = symbolTable;
+ final C99SymbolTable outerTable = symbolTableScopeStack.removeLast();
+ symbolTable = outerTable.insert(IDENTIFIER, functionName, functionBinding);
+
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ symbolTableScopeStack.add(outerTable);
+ symbolTable = undoTable;
+ declarationStack.add(frame);
+ bindingScopeStack.add(undoScope);
+ }
+ });
+ }
+
+
+ public void consumeAbstractDeclaratorFunctionDeclarator() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.setFunctionDeclarator(true);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ frame.setFunctionDeclarator(false);
+ }
+ });
+ }
+
+
+ public void consumeDirectDeclaratorFunctionDeclarator() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.setFunctionDeclarator(true);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ frame.setFunctionDeclarator(false);
+ }
+ });
+ }
+
+
+ public void consumeDeclSpecToken() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ IToken token = parser.getRightIToken();
+ final int kind = token.getKind();
+
+ // creates a DeclSpec if there isn't one already
+ DeclaratorFrame frame = declarationStack.getLast();
+ final DeclSpec declSpec = frame.getDeclSpec();
+ declSpec.add(kind);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declSpec.remove(kind);
+ }
+ });
+ }
+
+
+ /**
+ * A labeled statement is creates an implicit declaration of the label identifier.
+ *
+ * TODO: a label has function scope, meaning the same label cannot be declared twice
+ * in a function regardless of block scope.
+ * TODO: labels can be implicitly declared, that is a goto can exist above the label
+ */
+ public IBinding consumeStatementLabeled() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ IToken token = parser.getLeftIToken();
+ String ident = token.toString();
+
+ IC99Binding labelBinding = new C99Label(ident);
+ // TODO: strictly speaking the same label cannot be declared twice,
+ // but we aren't checking that here
+ final C99SymbolTable oldTable = symbolTable;
+ symbolTable = symbolTable.insert(GOTO_LABEL, ident, labelBinding);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ symbolTable = oldTable;
+ }
+ });
+
+ return labelBinding;
+ }
+
+
+ public IBinding consumeStatementGoto() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ List<IToken> ruleTokens = parser.getRuleTokens();
+ assert ruleTokens.size() == 3 : "a goto statement must always consist of 3 tokens"; //$NON-NLS-1$
+ String ident = ruleTokens.get(1).toString();
+
+ final C99SymbolTable oldTable = symbolTable;
+
+ IC99Binding labelBinding = symbolTable.lookup(GOTO_LABEL, ident);
+ if(labelBinding == null) {
+ labelBinding = new C99Label(ident);
+ symbolTable = symbolTable.insert(GOTO_LABEL, ident, labelBinding);
+ }
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ symbolTable = oldTable;
+ }
+ });
+
+
+ return labelBinding;
+ }
+
+
+ public IBinding consumeDeclarationSpecifiersTypedefName() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ // find the typedef token
+ String typedefName = null;
+ for(IToken token : parser.getRuleTokens()) {
+ // the token kind will still be TK_identifier, but there can only be one
+ if(token.getKind() == C99Parsersym.TK_identifier) {
+ typedefName = token.toString();
+ break;
+ }
+ }
+ assert typedefName != null : "a typedef token must have been parsed for this action to fire"; //$NON-NLS-1$
+
+ // we know that the binding is a typedef because the lexer feedback hack worked and got us here
+ ITypedef binding = (ITypedef) symbolTable.lookup(IDENTIFIER, typedefName);
+ // TODO: do I need to clone the typedef in case it is further modified like with const?
+ DeclaratorFrame frame = declarationStack.getLast();
+ final DeclSpec declSpec = frame.getDeclSpec();
+ declSpec.setType(binding);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ declSpec.setType(null);
+ }
+ });
+
+ return binding;
+ }
+
+
+
+ public void consumeDirectDeclaratorIdentifier() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ DebugUtil.printMethodTrace();
+ frame.setDeclaratorName(parser.getRightIToken());
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ DebugUtil.printMethodTrace();
+ frame.setDeclaratorName(null);
+ }
+ });
+ }
+
+
+
+ // TODO need to be careful, this is called in a lot of places in the grammar
+ public void consumeDeclaratorWithPointer() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ final LinkedList<C99PointerType> scope = frame.closePointerModifierScope();
+ final int scopeSize = scope.size();
+
+ for(C99PointerType pt : reverseIterable(scope)) {
+ frame.addTypeModifier(pt);
+ }
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ for(int i = 0; i < scopeSize; i++) {
+ frame.removeLastTypeModifier();
+ }
+ frame.openPointerModifierScope(scope);
+ }
+ });
+ }
+
+
+
+ public void consumeDirectDeclaratorBracketed() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ // Used to tell the difference between function prototype declarations and function pointer declarations
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.setDeclaratorBracketed(true);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ frame.setDeclaratorBracketed(false);
+ }
+ });
+ }
+
+
+ public IBinding consumeDeclaratorComplete() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+
+ IToken token = frame.getDeclaratorName();
+ IType type = frame.getDeclaratorType();
+ DeclSpec declSpec = frame.getDeclSpec();
+ boolean isFunction = frame.isFunctionDeclarator();
+ List<IBinding> nestedDeclarators = frame.getNestedDeclarations();
+
+ if(isFunction)
+ type = createFunctionType(type, nestedDeclarators);
+
+ String ident = (token == null) ? null : token.toString();
+
+ // compute the binding
+ IC99Binding binding;
+ if(declSpec.isTypedef())
+ binding = createTypedefBinding(ident, type);
+ else if(isFunction && !frame.isDeclaratorBracketed())
+ binding = createFunctionBinding(ident, (IFunctionType)type, declSpec, nestedDeclarators);
+ else
+ binding = createVariableBinding(ident, type, declSpec);
+
+ binding.setScope(bindingScopeStack.getLast());
+
+ // insert into symbol table
+ final C99SymbolTable oldTable = symbolTable;
+ if(ident != null)
+ symbolTable = symbolTable.insert(IDENTIFIER, ident, binding);
+
+ declarationStack.removeLast();
+ declarationStack.add(new DeclaratorFrame(frame.getDeclSpec())); // reset the declarator
+ exprTypeStack.push(type);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ exprTypeStack.pop();
+ declarationStack.removeLast();
+ declarationStack.add(frame);
+ symbolTable = oldTable;
+ }
+ });
+
+ return binding;
+ }
+
+ /**
+ * Just gets rid of the type that was on the type stack.
+ */
+ public void consumeInitDeclarator() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final IType type = exprTypeStack.pop();
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ exprTypeStack.push(type);
+ }
+ });
+ }
+
+
+ public IBinding consumeFunctionDefinitionHeader() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ DeclaratorFrame frame = declarationStack.getLast();
+ DeclSpec declSpec = frame.getDeclSpec();
+ String functionName = frame.getDeclaratorName().toString();
+
+ final C99SymbolTable oldTable = symbolTable;
+
+ // there may have been a function prototype, hence there may already be a binding for the function
+ IC99Binding binding = symbolTable.lookup(IDENTIFIER, functionName);
+ if(binding == null) {
+ IType type = frame.getDeclaratorType();
+ List<IBinding> nestedDeclarators = frame.getNestedDeclarations();
+
+ IFunctionType functionType = createFunctionType(type, nestedDeclarators);
+ binding = createFunctionBinding(functionName, functionType, declSpec, nestedDeclarators);
+
+ // a scope has already been opened for the function body, use the outer scope
+ IC99Scope topScope = bindingScopeStack.removeLast();
+ binding.setScope(bindingScopeStack.getLast());
+ bindingScopeStack.add(topScope);
+
+ symbolTable = symbolTable.insert(IDENTIFIER, functionName, binding);
+ }
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ symbolTable = oldTable;
+ }
+ });
+
+ return binding;
+ }
+
+
+ public IBinding consumeDeclaratorCompleteParameter() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.removeLast();
+ IToken token = frame.getDeclaratorName();
+ IType type = frame.getDeclaratorType();
+ DeclSpec declSpec = frame.getDeclSpec();
+ boolean isFunction = frame.isFunctionDeclarator();
+
+ // its a function pointer
+ if(isFunction)
+ type = createFunctionType(type, frame.getNestedDeclarations());
+
+ String ident = (token == null) ? NO_IDENT : token.toString();
+
+ IC99Binding parameterBinding = createParameterBinding(ident, type, declSpec);
+ parameterBinding.setScope(bindingScopeStack.getLast());
+
+ // check to see if there is already a parameter binding
+ String functionName = declarationStack.getLast().getDeclaratorName().toString();
+ C99Function function = (C99Function) symbolTable.lookup(IDENTIFIER, functionName);
+
+ if(function != null) {
+ // there is already a function binding for this function, that means there
+ // is a function prototype and there is already a binding for this parameter
+ int position = declarationStack.getLast().getNestedDeclarations().size();
+ IParameter[] parameters = function.getParameters();
+ if(parameters != null && position < parameters.length) {
+ parameterBinding = (IC99Binding)parameters[position];
+ }
+ }
+
+ // even if the binding is reused it still might be under a different name
+ final C99SymbolTable oldTable = symbolTable;
+ if(ident != null) {
+ symbolTable = symbolTable.insert(IDENTIFIER, ident, parameterBinding);
+ }
+
+ declarationStack.getLast().addNestedDeclaration(parameterBinding);
+
+ // parameter declarations can only have one declarator, so don't reset
+ //declarationStack.add(new DeclaratorFrame()); // reset
+
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ //declarationStack.removeLast();
+ declarationStack.getLast().removeLastNestedDeclaration();
+ declarationStack.add(frame);
+ symbolTable = oldTable;
+ }
+ });
+
+ return parameterBinding;
+ }
+
+
+ /**
+ * This is a special case for the rule:
+ * parameter_declaration ::= declaration_specifiers
+ *
+ * In this case there is no declarator at all
+ *
+ * TODO: creating bindings that have no identifier seems really dumb,
+ * why does it need to be done? Why not just have a null binding or
+ * for that matter don't even have a name node
+ *
+ */
+ public IBinding consumeParameterDeclarationWithoutDeclarator() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.removeLast();
+ DeclSpec declSpec = frame.getDeclSpec();
+ C99Parameter param = createParameterBinding(null, declSpec.getType(), declSpec);
+ declarationStack.getLast().addNestedDeclaration(param);
+
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ declarationStack.getLast().removeLastNestedDeclaration();
+ declarationStack.add(frame);
+ }
+ });
+
+ return param;
+ }
+
+
+ public IBinding consumeDeclaratorCompleteField() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ IToken token = frame.getDeclaratorName();
+ IType type = frame.getDeclaratorType();
+
+ // its a function pointer
+ if(frame.isFunctionDeclarator())
+ type = createFunctionType(type, frame.getNestedDeclarations());
+
+ IBinding binding = createFieldBinding(token.toString(), type, frame.getDeclSpec());
+
+ declarationStack.removeLast();
+ declarationStack.getLast().addNestedDeclaration(binding);
+ declarationStack.add(new DeclaratorFrame(frame.getDeclSpec())); // reset the declarator
+ exprTypeStack.push(type);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ declarationStack.removeLast();
+ declarationStack.getLast().removeLastNestedDeclaration();
+ declarationStack.add(frame);
+ }
+ });
+
+ return binding;
+ }
+
+
+ /**
+ * An abstract declarator used as part of an expression, eg) a cast.
+ * Only need the type.
+ *
+ * TODO: this isn't enough, I need a binding for the abstract declarator
+ * what I really need is a consumeDeclaratorCompleteTypeId similar to above
+ */
+ public void consumeTypeId() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.removeLast();
+ IType type = frame.getDeclaratorType();
+ if(frame.isFunctionDeclarator()) // its a function pointer
+ type = createFunctionType(type, frame.getNestedDeclarations());
+
+ exprTypeStack.push(type);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ declarationStack.add(frame);
+ }
+ });
+ }
+
+
+ public void consumeDirectDeclaratorArrayModifier() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.addTypeModifier(new C99ArrayType());
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ frame.removeLastTypeModifier();
+ }
+ });
+ }
+
+
+ public void consumeAbstractDeclaratorArrayModifier() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.addTypeModifier(new C99ArrayType());
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ frame.removeLastTypeModifier();
+ }
+ });
+ }
+
+
+ public void consumeDirectDeclaratorModifiedArrayModifier(boolean isStatic, boolean isVarSized, boolean hasTypeQualifierList) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ C99ArrayType arrayType = new C99ArrayType();
+ arrayType.setStatic(isStatic);
+ arrayType.setVariableLength(isVarSized);
+
+ if(hasTypeQualifierList) {
+ arrayType.setConst(typeQualifiers.isConst);
+ arrayType.setRestrict(typeQualifiers.isRestrict);
+ arrayType.setVolatile(typeQualifiers.isVolatile);
+ }
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.addTypeModifier(arrayType);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ frame.removeLastTypeModifier();
+ }
+ });
+ }
+
+
+
+ public void consumePointer() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.addPointerModifier(new C99PointerType());
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ frame.removeLastPointerModifier();
+ }
+ });
+ }
+
+
+ public void consumePointerTypeQualifierList() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ C99PointerType pointerType = new C99PointerType();
+ pointerType.setConst(typeQualifiers.isConst);
+ pointerType.setRestrict(typeQualifiers.isRestrict);
+ pointerType.setVolatile(typeQualifiers.isVolatile);
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.addPointerModifier(pointerType);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ frame.removeLastPointerModifier();
+ }
+ });
+ }
+
+
+ public void consumeTypeQualifiers() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ typeQualifiers = new TypeQualifiers();
+
+ for(IToken token : parser.getRuleTokens()) {
+ switch(token.getKind()) {
+ case C99Parsersym.TK_const:
+ typeQualifiers.isConst = true;
+ break;
+ case C99Parsersym.TK_restrict:
+ typeQualifiers.isRestrict = true;
+ break;
+ case C99Parsersym.TK_volatile:
+ typeQualifiers.isVolatile = true;
+ break;
+ }
+ }
+
+ // I don't think this is really necessary but I need an undo action anyway
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ typeQualifiers = null;
+ }
+ });
+ }
+
+
+
+ /**
+ * Works for structs, unions and enums.
+ * If the struct tag is not in the symbol table then it is treated
+ * as a declaration.
+ */
+ public IBinding consumeTypeSpecifierElaborated(int kind) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ String tag = parser.getRightIToken().toString();
+
+ IC99Binding structBinding = symbolTable.lookup(STRUCT_TAG, tag);
+
+ final C99SymbolTable undoTable;
+
+ final boolean isDeclaration = (structBinding == null);
+
+ if(isDeclaration) { // declaration of an incomplete type
+ if(kind == IASTElaboratedTypeSpecifier.k_enum)
+ structBinding = new C99Enumeration();
+ else
+ structBinding = new C99Structure(kind);
+
+ undoTable = symbolTable;
+ symbolTable = symbolTable.insert(STRUCT_TAG, tag, structBinding);
+ }
+ else {
+ undoTable = null; // final variable must be initialized
+ }
+
+ final DeclSpec declSpec = declarationStack.getLast().getDeclSpec();
+ declSpec.setType((IType)structBinding); // upcast
+
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ declSpec.setType(null);
+
+ if(isDeclaration) {
+ assert undoTable != null;
+ symbolTable = undoTable;
+ }
+ }
+ });
+
+ return structBinding;
+ }
+
+
+ /**
+ * @param key A field in IASTCompositeTypeSpecifier.
+ */
+ public IBinding consumeTypeSpecifierComposite(final boolean hasName, int key) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ // If the symbol table isn't updated then its still ok to undo
+ // because setting symbolTable to oldTable will effectively be a no-op.
+ final C99SymbolTable oldTable = symbolTable;
+
+ C99Structure struct;
+ if(hasName) {
+ String ident = parser.getRuleTokens().get(1).toString();
+ struct = (C99Structure) symbolTable.lookup(STRUCT_TAG, ident); // structure may have already been declared
+ if(struct == null) {
+ struct = new C99Structure(ident, key);
+ symbolTable = symbolTable.insert(STRUCT_TAG, ident, struct);
+ }
+ }
+ else {
+ struct = new C99Structure(key);
+ }
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ for(IBinding binding : frame.getNestedDeclarations()) {
+ // the parser may allow invalid declarations like typedefs inside of structures, ignore those
+ if(binding instanceof C99Field) {
+ C99Field field = (C99Field)binding;
+ struct.addField(field);
+ field.setCompositeTypeOwner(struct);
+ }
+ }
+
+ frame.getDeclSpec().setType(struct);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ frame.getDeclSpec().setType(null);
+ symbolTable = oldTable;
+ }
+ });
+
+ return struct;
+ }
+
+
+ public IBinding consumeTypeSpecifierEnumeration(final boolean hasName) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ C99Enumeration enumeration = new C99Enumeration();
+
+ final C99SymbolTable oldTable = symbolTable;
+ if(hasName) {
+ String ident = parser.getRuleTokens().get(1).toString();
+ enumeration.setName(ident);
+ symbolTable = symbolTable.insert(STRUCT_TAG, ident, enumeration);
+ }
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ for(IBinding binding : frame.getNestedDeclarations()) {
+ C99Enumerator enumerator = (C99Enumerator)binding;
+ enumeration.addEnumerator(enumerator);
+ enumerator.setType(enumeration);
+ }
+
+ frame.getDeclSpec().setType(enumeration);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ frame.getDeclSpec().setType(null);
+ if(hasName)
+ symbolTable = oldTable;
+ }
+ });
+
+ return enumeration;
+ }
+
+
+
+ public IBinding consumeEnumerator(boolean hasInitializer) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ IToken token = parser.getLeftIToken();
+ String ident = token.toString();
+ C99Enumerator enumerator = new C99Enumerator(ident);
+
+ final C99SymbolTable oldTable = symbolTable;
+ symbolTable = symbolTable.insert(IDENTIFIER, ident, enumerator);
+
+ // enumerators are not declarations in the standard sense, so a scope won't be opened for them
+ declarationStack.getLast().addNestedDeclaration(enumerator);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ declarationStack.getLast().removeLastNestedDeclaration();
+ symbolTable = oldTable;
+ }
+ });
+
+ return enumerator;
+ }
+
+
+
+ public IField consumeDesignatorBaseField() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+
+ IType baseType = getInitializerType();
+ String fieldName = parser.getRightIToken().toString();
+
+ C99Field fieldBinding = computeFieldBinding(baseType, fieldName, false);
+ IType type = fieldBinding == null ? C99ProblemBinding.badType() : fieldBinding.getType();
+
+ exprTypeStack.push(type);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ }
+ });
+
+ return fieldBinding;
+ }
+
+
+
+ private IType getInitializerType() {
+ List<IType> outerScope = exprTypeStack.outerScope();
+ return outerScope.get(outerScope.size()-1);
+ }
+
+
+ public void consumeDesignatorBaseArray() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ IType baseType = getInitializerType();
+
+ IType type = C99ProblemBinding.badType();
+ if(baseType instanceof C99ArrayType) {
+ type = ((C99ArrayType)baseType).getType();
+ }
+
+ exprTypeStack.push(type);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ }
+ });
+ }
+
+ public void consumeInitializerStartPositional() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ DebugUtil.printMethodTrace();
+
+ IType type = getInitializerType();
+ type = rawType(type);
+
+ IType positionType;
+ if(type instanceof C99Structure) {
+ int position = exprTypeStack.topScope().size();
+ C99Field field = (C99Field)((C99Structure)type).getFields()[position];
+ positionType = field.getType();
+ }
+ else if(type instanceof IArrayType) {
+ positionType = ((C99ArrayType)type).getType();
+ }
+ else {
+ positionType = C99ProblemBinding.badType();
+ }
+
+ exprTypeStack.push(positionType);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ }
+ });
+ }
+
+
+ private static C99FunctionType createFunctionType(IType returnType, List<IBinding> parameterDeclarations) {
+ C99FunctionType functionType = new C99FunctionType();
+ functionType.setReturnType(returnType);
+ for(IBinding b : parameterDeclarations) {
+ C99Variable parameter = (C99Variable) b;
+ functionType.addParameterType(parameter.getType());
+ }
+ return functionType;
+ }
+
+
+
+ // helper functions for creating binding objects
+
+ private static C99Function createFunctionBinding(String ident, IFunctionType type, DeclSpec declSpec) {
+ C99Function func = new C99Function(ident == null ? NO_IDENT : ident, type);
+ declSpec.modifyBinding(func);
+ return func;
+ }
+
+ private static C99Function createFunctionBinding(String ident, IFunctionType type, DeclSpec declSpec, List<IBinding> params) {
+ C99Function func = createFunctionBinding(ident, type, declSpec);
+ for(IBinding b : params) {
+ func.addParameter((IParameter)b);
+ }
+ return func;
+ }
+
+ private static C99Field createFieldBinding(String ident, IType type, DeclSpec declSpec) {
+ C99Field var = new C99Field(ident == null ? NO_IDENT : ident);
+ var.setType(type);
+ declSpec.modifyBinding(var);
+ return var;
+ }
+
+ private static C99Parameter createParameterBinding(String ident, IType type, DeclSpec declSpec) {
+ C99Parameter param = new C99Parameter(ident == null ? NO_IDENT : ident);
+ param.setType(type);
+ declSpec.modifyBinding(param);
+ return param;
+ }
+
+ private static C99Variable createVariableBinding(String ident, IType type, DeclSpec declSpec) {
+ C99Variable var = new C99Variable(ident == null ? NO_IDENT : ident);
+ var.setType(type);
+ declSpec.modifyBinding(var);
+ return var;
+ }
+
+ private static C99Typedef createTypedefBinding(String ident, IType type) {
+ return new C99Typedef(type, ident == null ? NO_IDENT : ident);
+ }
+
+
+
+ public void openTypeScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ exprTypeStack.openScope();
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.closeScope();
+ }
+ });
+ }
+
+
+
+ public void consumeExpressionConstant(int kind) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ //super.consumeExpressionConstant(kind);
+ // TODO: this is incomplete, what about double constants, int constants with long suffix etc
+ String constant = parser.getRightIToken().toString();
+
+ IType type = null;
+ switch(kind) {
+ case IASTLiteralExpression.lk_char_constant:
+ if(constant.startsWith("L")) {//unsigned short int
+ C99BasicType charType = new C99BasicType(IBasicType.t_int);
+ charType.setShort(true);
+ charType.setUnsigned(true);
+ type = charType;
+ }
+ else
+ type = new C99BasicType(IBasicType.t_char);
+ break;
+
+ case IASTLiteralExpression.lk_float_constant:
+ C99BasicType floatType;
+ if(constant.contains("f") || constant.contains("F"))
+ floatType = new C99BasicType(IBasicType.t_float);
+ else
+ floatType = new C99BasicType(IBasicType.t_double);
+
+ if(constant.contains("l") || constant.contains("L"))
+ floatType.setLong(true);
+
+ type = floatType;
+ break;
+
+ case IASTLiteralExpression.lk_integer_constant:
+ C99BasicType intType = new C99BasicType(IBasicType.t_int);
+ if(constant.contains("l") || constant.contains("L"))
+ intType.setLong(true);
+
+ if(constant.contains("ll") || constant.contains("LL")) {
+ intType.setLongLong(true);
+ intType.setLong(false);
+ }
+ if(constant.contains("u") || constant.contains("U"))
+ intType.setUnsigned(true);
+
+ type = intType;
+ break;
+
+ case IASTLiteralExpression.lk_string_literal:
+ type = new C99PointerType(new C99BasicType(IBasicType.t_char));
+ break;
+
+ default:
+ assert false : "can't get here"; //$NON-NLS-1$
+ }
+
+ exprTypeStack.push(type);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ }
+ });
+ }
+
+
+ public IBinding consumeExpressionID() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ IToken token = parser.getRightIToken();
+ String ident = token.toString();
+ IBinding binding = symbolTable.lookup(IDENTIFIER, ident);
+
+ IType type = C99ProblemBinding.badType();
+ if(binding instanceof ITypeable)
+ type = ((ITypeable)binding).getType();
+
+ exprTypeStack.push(type);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ }
+ });
+
+ return binding;
+ }
+
+
+ public IField consumeExpressionFieldReference(boolean isPointerDereference) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ String memberName = parser.getRightIToken().toString();
+ final IType identType = exprTypeStack.pop();
+
+ C99Field field = computeFieldBinding(identType, memberName, isPointerDereference);
+ IType resultType = field == null ? C99ProblemBinding.badType() : field.getType();
+
+ exprTypeStack.push(resultType);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ exprTypeStack.push(identType);
+ }
+ });
+
+ return field;
+ }
+
+ /**
+ * Computes the type of a field member access in an expression.
+ * eg) x.a; computes the type of a
+ */
+ private C99Field computeFieldBinding(IType identType, String memberName, boolean isPointerDereference) {
+ try {
+ IType type = identType;
+ if(isPointerDereference) {
+ if(type instanceof IPointerType)
+ type = ((ITypeContainer)type).getType(); // do the dereference
+ else
+ return null;
+ }
+
+ type = rawType(type);
+ if(type instanceof ICompositeType) {
+ ICompositeType struct = (ICompositeType) type;
+ return (C99Field) struct.findField(memberName);
+ }
+ } catch(DOMException _) {}
+
+ return null;
+ }
+
+
+ // TODO In C a function name can be used without parenthesis, the result is the address of
+ // the function (which is an int I think). This means an identifier that happens to be
+ // a function name should probably evaluate to an int, and then if it subsequently gets parsed
+ // as a function call we can look up its function type from the symbol table.
+ public void consumeExpressionFunctionCall(final boolean hasArgs) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final List<IType> scope = hasArgs ? exprTypeStack.closeScope() : null;
+ final IType identifierType = exprTypeStack.pop();
+
+ IType resultType = C99ProblemBinding.badType();
+
+ if(identifierType instanceof IFunctionType) {
+ // TODO: check the parameter types
+ IFunctionType functionType = (IFunctionType)identifierType;
+ try {
+ resultType = functionType.getReturnType();
+ } catch (DOMException e) { } // do nothing, the problem binding is fine
+ }
+
+ exprTypeStack.push(resultType);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ exprTypeStack.push(identifierType);
+ if(hasArgs)
+ exprTypeStack.openScope(scope);
+ }
+ });
+ }
+
+
+ public void consumeExpressionArraySubscript() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ // Not doing type checking so it doesn't matter that this is integral type
+ final IType subscriptType = exprTypeStack.pop();
+ final IType exprType = exprTypeStack.pop();
+
+ IType resultType = C99ProblemBinding.badType();
+ if(exprType instanceof IArrayType) {
+ IArrayType arrType = (IArrayType) exprType;
+ try {
+ resultType = arrType.getType(); // strip off the array type
+ } catch (DOMException e) { }
+ }
+
+ exprTypeStack.push(resultType);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ exprTypeStack.push(exprType);
+ exprTypeStack.push(subscriptType);
+ }
+ });
+ }
+
+
+ public void consumeExpressionUnaryOperator(int operator) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ // TODO: this is lazy, need to check the actual rules for types and operators
+ final IType expressionType = exprTypeStack.pop();
+
+ IType resultType = new C99BasicType(IBasicType.t_int);
+ exprTypeStack.push(resultType);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ exprTypeStack.push(expressionType);
+ }
+ });
+ }
+
+
+ public void consumeExpressionUnarySizeofTypeName() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final IType typeNameType = exprTypeStack.pop();
+
+ IType resultType = new C99BasicType(IBasicType.t_int);
+ exprTypeStack.push(resultType);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ exprTypeStack.push(typeNameType);
+ }
+ });
+ }
+
+
+ public void consumeExpressionCast() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final IType exprType = exprTypeStack.pop();
+
+ // pop then push is no-op
+ //IType castType = exprTypeStack.pop();
+ //exprTypeStack.push(castType);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.push(exprType);
+ }
+ });
+ }
+
+
+ public void consumeExpressionTypeIdInitializer() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ // Throw away the types of the initializer list
+ final List<IType> scope = exprTypeStack.closeScope();
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.openScope(scope);
+ }
+ });
+ }
+
+ public void consumeExpressionInitializer() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final IType type = exprTypeStack.pop();
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ exprTypeStack.push(type);
+ }
+ });
+ }
+
+
+ public void consumeExpressionBinaryOperator(int op) {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final IType op2type = exprTypeStack.pop();
+ final IType op1type = exprTypeStack.pop();
+
+ switch(op) {
+ case IASTBinaryExpression.op_assign:
+ case IASTBinaryExpression.op_multiplyAssign:
+ case IASTBinaryExpression.op_divideAssign:
+ case IASTBinaryExpression.op_moduloAssign:
+ case IASTBinaryExpression.op_plusAssign:
+ case IASTBinaryExpression.op_minusAssign:
+ case IASTBinaryExpression.op_shiftLeftAssign:
+ case IASTBinaryExpression.op_shiftRightAssign:
+ case IASTBinaryExpression.op_binaryAndAssign:
+ case IASTBinaryExpression.op_binaryXorAssign:
+ case IASTBinaryExpression.op_binaryOrAssign:
+ exprTypeStack.push(op1type);
+ break;
+
+ default:
+ IType resultType = new C99BasicType(IBasicType.t_int);
+ exprTypeStack.push(resultType);
+ }
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ exprTypeStack.pop();
+ exprTypeStack.push(op1type);
+ exprTypeStack.push(op2type);
+ }
+ });
+ }
+
+ public void consumeExpressionConditional() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final IType expr2Type = exprTypeStack.pop();
+ final IType expr1Type = exprTypeStack.pop();
+ final IType condType = exprTypeStack.pop();
+ exprTypeStack.push(expr1Type);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ exprTypeStack.pop();
+ exprTypeStack.push(condType);
+ exprTypeStack.push(expr1Type);
+ exprTypeStack.push(expr2Type);
+ }
+ });
+ }
+
+// // TODO: expression lists are changing
+// public void consumeExpressionList(boolean baseCase) {
+// // This is a hack, the type of an expression
+// // list will be the first expression in the list.
+// if(!baseCase) {
+// exprTypeStack.pop();
+// }
+// }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99SymbolTable.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99SymbolTable.java
new file mode 100644
index 00000000000..142c5cafd01
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99SymbolTable.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+
+import org.eclipse.cdt.core.dom.lrparser.action.FunctionalMap;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.IC99Binding;
+
+/**
+ * A facade for a FunctionalMap to make it behave like
+ * a symbol table for C99.
+ *
+ * In particular we need to be able to lookup identifiers based both
+ * on the String representation of the identifier and its "namespace".
+ *
+ * @author Mike Kucera
+ */
+@Deprecated public class C99SymbolTable {
+
+ /**
+ * Adapter objects are used as the keys. The trick here is to implement
+ * compareTo() in such a way that identifiers are separated by their namespace.
+ */
+ private static class Key implements Comparable<Key> {
+ private final String ident;
+ private final CNamespace namespace;
+
+ public Key(CNamespace namespace, String ident) {
+ if(namespace == null || ident == null)
+ throw new NullPointerException();
+
+ this.ident = ident;
+ this.namespace = namespace;
+ }
+
+ public int compareTo(Key x) {
+ // this separates namespaces in the symbol table
+ int c = namespace.compareTo(x.namespace);
+ // only if the namespace is the same do we check the identifier
+ return (c == 0) ? ident.compareTo(x.ident) : c;
+ }
+
+ @Override public String toString() {
+ return ident + "::" + namespace;//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Start with EMPTY_TABLE and build up a symbol table using insert().
+ */
+ public static final C99SymbolTable EMPTY_TABLE = new C99SymbolTable();
+
+
+ // the map we are providing a facade for
+ private final FunctionalMap<Key,IC99Binding> map;
+
+
+ /**
+ * Constructors are private, start with EMPTY_TABLE
+ * and build it up using insert().
+ */
+ private C99SymbolTable() {
+ map = FunctionalMap.emptyMap();
+ }
+
+ private C99SymbolTable(FunctionalMap<Key,IC99Binding> newRoot) {
+ map = newRoot;
+ }
+
+ /**
+ * Returns a new symbol table that contains the given mapping.
+ * @throws NullPointerException if the namespace or key is null.
+ */
+ public C99SymbolTable insert(CNamespace ns, String key, IC99Binding binding) {
+ return new C99SymbolTable(map.insert(new Key(ns, key), binding));
+ }
+
+ /**
+ * Looks up the binding given its namespace and identifier.
+ * @return null If there is no binding corresponding to the key.
+ * @throws NullPointerException if the namespace or key is null.
+ */
+ public IC99Binding lookup(CNamespace ns, String key) {
+ return map.lookup(new Key(ns, key));
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ public boolean isEmpty() {
+ return map.size() == 0;
+ }
+
+ @Override public String toString() {
+ return map.toString();
+ }
+
+// void printStructure() {
+// map.printStructure();
+// }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99TypedefTrackerParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99TypedefTrackerParserAction.java
new file mode 100644
index 00000000000..dcc59a8fb61
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99TypedefTrackerParserAction.java
@@ -0,0 +1,354 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import java.util.LinkedList;
+
+import lpg.lpgjavaruntime.IToken;
+
+import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+/**
+ * A simple set of trial and undo actions that just keep track
+ * of typedef names. This information is then fed back to the parser
+ * in order to disambiguate certain parser grammar rules.
+ *
+ * The command design pattern is used to implement undo actions.
+ *
+ * @author Mike Kucera
+ */
+public class C99TypedefTrackerParserAction {
+
+ private static final boolean DEBUG = true;
+
+
+ // provides limited access to the token stream
+ private final IParserActionTokenProvider parser;
+
+ // The symbolTable currently in use
+ private TypedefSymbolTable symbolTable = TypedefSymbolTable.EMPTY_TABLE;
+
+ // A stack that keeps track of scopes in the symbol table, used to "close" scopes and to undo the opening of scopes
+ private final LinkedList<TypedefSymbolTable> symbolTableScopeStack = new LinkedList<TypedefSymbolTable>();
+
+ // keeps track of nested declarations
+ private final LinkedList<DeclaratorFrame> declarationStack = new LinkedList<DeclaratorFrame>();
+
+
+ // "For every action there is an equal and opposite reaction." - Newton's third law
+ private final LinkedList<IUndoAction> undoStack = new LinkedList<IUndoAction>();
+
+
+ /**
+ * A command object that provides undo functionality.
+ */
+ private interface IUndoAction {
+ void undo();
+ }
+
+
+ /**
+ * Undoes the last fired action.
+ */
+ public void undo() {
+ undoStack.removeLast().undo();
+ }
+
+
+ public C99TypedefTrackerParserAction(IParserActionTokenProvider parser) {
+ this.parser = parser;
+ }
+
+
+ /**
+ * Lexer feedback hack, used by the parser to identify typedefname tokens.
+ */
+ public boolean isTypedef(String ident) {
+ return symbolTable.contains(ident);
+ }
+
+
+ /**
+ * Methods used by tests, package local access.
+ */
+ TypedefSymbolTable getSymbolTable() {
+ return symbolTable;
+ }
+
+ int undoStackSize() {
+ return undoStack.size();
+ }
+
+ LinkedList<DeclaratorFrame> getDeclarationStack() {
+ return declarationStack;
+ }
+
+
+ /**
+ * Called from the grammar file in places where a scope is created.
+ *
+ * Scopes are created by compound statements, however special care
+ * must also be taken with for loops because they may contain
+ * declarations.
+ *
+ * TODO: scope object now need to be handled explicitly
+ */
+ public void openSymbolScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ symbolTableScopeStack.add(symbolTable);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ symbolTable = symbolTableScopeStack.removeLast();
+ }
+ });
+ }
+
+
+ public void closeSymbolScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final TypedefSymbolTable undoTable = symbolTable;
+ symbolTable = symbolTableScopeStack.removeLast(); // close the scope
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ symbolTableScopeStack.add(symbolTable);
+ symbolTable = undoTable;
+ }
+ });
+ }
+
+
+
+ /**
+ * Called from the grammar before a declaration is about to be reduced.
+ */
+ public void openDeclarationScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.add(new DeclaratorFrame());
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.removeLast();
+ }
+ });
+ }
+
+
+ public void closeDeclarationScope() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame undoFrame = declarationStack.removeLast();
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.add(undoFrame);
+ }
+ });
+ }
+
+
+ public void consumeFunctionDefinition() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.removeLast();
+
+ final TypedefSymbolTable undoTable = symbolTable;
+ symbolTable = symbolTableScopeStack.removeLast();
+
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ symbolTableScopeStack.add(symbolTable);
+ symbolTable = undoTable;
+
+ declarationStack.add(frame);
+ }
+ });
+ }
+
+
+
+
+ public void consumeDeclSpecToken() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ IToken token = parser.getRightIToken();
+ final int kind = token.getKind();
+
+ // creates a DeclSpec if there isn't one already
+ DeclaratorFrame frame = declarationStack.getLast();
+ final DeclSpec declSpec = frame.getDeclSpec();
+ declSpec.add(kind);
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declSpec.remove(kind);
+ }
+ });
+ }
+
+
+
+ public void consumeDirectDeclaratorIdentifier() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+ frame.setDeclaratorName(parser.getRightIToken());
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ frame.setDeclaratorName(null);
+ }
+ });
+ }
+
+
+ public void consumeDeclaratorComplete() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.getLast();
+
+ IToken token = frame.getDeclaratorName();
+ DeclSpec declSpec = frame.getDeclSpec();
+
+ String ident = (token == null) ? null : token.toString();
+ //System.out.println("declarator complete: " + ident);
+
+ final TypedefSymbolTable oldTable = symbolTable;
+ if(declSpec.isTypedef()) {
+ //System.out.println("adding typedef: " + ident);
+ symbolTable = symbolTable.add(ident);
+ }
+
+ declarationStack.removeLast();
+ declarationStack.add(new DeclaratorFrame(frame.getDeclSpec())); // reset the declarator
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.removeLast();
+ declarationStack.add(frame);
+ symbolTable = oldTable;
+ }
+ });
+ }
+
+
+
+
+ public void consumeDeclaratorCompleteParameter() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.removeLast();
+
+ //declarationStack.getLast().addNestedDeclaration(parameterBinding);
+
+ // parameter declarations can only have one declarator, so don't reset
+ //declarationStack.add(new DeclaratorFrame()); // reset
+
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+ //declarationStack.removeLast();
+ //declarationStack.getLast().removeLastNestedDeclaration();
+ declarationStack.add(frame);
+ }
+ });
+ }
+
+
+ /**
+ * This is a special case for the rule:
+ * parameter_declaration ::= declaration_specifiers
+ *
+ * In this case there is no declarator at all
+ *
+ * TODO: creating bindings that have no identifier seems really dumb,
+ * why does it need to be done? Why not just have a null binding or
+ * for that matter don't even have a name node
+ *
+ */
+ public void consumeParameterDeclarationWithoutDeclarator() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.removeLast();
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.add(frame);
+ }
+ });
+ }
+
+
+ public void consumeDeclaratorCompleteField() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.removeLast();
+
+ declarationStack.add(new DeclaratorFrame(frame.getDeclSpec())); // reset the declarator
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.removeLast();
+
+ declarationStack.add(frame);
+ }
+ });
+ }
+
+
+ /**
+ * An abstract declarator used as part of an expression, eg) a cast.
+ * Only need the type.
+ *
+ * TODO: this isn't enough, I need a binding for the abstract declarator
+ * what I really need is a consumeDeclaratorCompleteTypeId similar to above
+ */
+ public void consumeTypeId() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ final DeclaratorFrame frame = declarationStack.removeLast();
+
+ undoStack.add(new IUndoAction() {
+ public void undo() {
+ if(DEBUG) DebugUtil.printMethodTrace();
+
+ declarationStack.add(frame);
+ }
+ });
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/CNamespace.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/CNamespace.java
new file mode 100644
index 00000000000..8fb561f09a1
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/CNamespace.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+/**
+ * The C language has 4 namespaces for identifiers.
+ * This enum represents three of them, the "member" namespace
+ * is represented by IStructure.getFields().
+ *
+ * The symbol table uses these to mark identifiers and keep
+ * the namespaces separate.
+ *
+ * @author Mike Kucera
+ */
+@Deprecated public enum CNamespace {
+
+ GOTO_LABEL, // goto labels
+ STRUCT_TAG,// structs, unions, enums
+ IDENTIFIER; // all other identifiers
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/DeclSpec.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/DeclSpec.java
new file mode 100644
index 00000000000..377a09a4969
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/DeclSpec.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99BasicType;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Function;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99QualifierType;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99Variable;
+
+/**
+ * Keeps track of declaration specifiers during the parse.
+ * Used to compute types and determine if a declarator is a typedef.
+ *
+ * @author Mike Kucera
+ */
+class DeclSpec {
+
+ // maps token kinds to the number of occurrences of that kind
+ private Map<Integer,Integer> tokenKindMap = new HashMap<Integer,Integer>();
+
+ private IType type = null;
+
+
+ public void add(int kind) {
+ tokenKindMap.put(kind, count(kind) + 1);
+ }
+
+ public void remove(final int kind) {
+ Integer count = tokenKindMap.get(kind);
+ if(count == null)
+ return;
+
+ if(count <= 1)
+ tokenKindMap.remove(kind);
+ else
+ tokenKindMap.put(kind, count - 1);
+ }
+
+ public boolean contains(int kind) {
+ return tokenKindMap.containsKey(kind);
+ }
+
+
+ public boolean isTypedef() {
+ return contains(C99Parsersym.TK_typedef);
+ }
+
+ /**
+ * Need to keep track of how many times a particular
+ * declaration specifier appears in order to support
+ * long long.
+ */
+ public int count(int kind) {
+ Integer count = tokenKindMap.get(kind);
+ return count == null ? 0 : count;
+ }
+
+ /**
+ * Set if the type should be a structure.
+ */
+ public void setType(IType type) {
+ this.type = type;
+ }
+
+
+
+ public IType getType() {
+ if(type != null)
+ return type;
+ if(tokenKindMap.isEmpty()) // there are no type tokens, so it must be implicit int
+ return new C99BasicType(ICBasicType.t_int);
+
+ C99BasicType basicType = new C99BasicType();
+
+ for(int kind : tokenKindMap.keySet()) {
+ switch(kind) {
+ case TK_void:
+ basicType.setType(ICBasicType.t_void);
+ break;
+ case TK_char:
+ basicType.setType(ICBasicType.t_char);
+ break;
+ case TK_int:
+ basicType.setType(ICBasicType.t_int);
+ break;
+ case TK_float:
+ basicType.setType(ICBasicType.t_float);
+ break;
+ case TK_double:
+ basicType.setType(ICBasicType.t_double);
+ break;
+ case TK_long:
+ boolean isLongLong = count(TK_long) > 1;
+ basicType.setLongLong(isLongLong);
+ basicType.setLong(!isLongLong);
+ break;
+ case TK_signed:
+ basicType.setSigned(true);
+ break;
+ case TK_unsigned:
+ basicType.setUnsigned(true);
+ break;
+ case TK_short:
+ basicType.setShort(true);
+ break;
+ case TK__Bool:
+ basicType.setType(ICBasicType.t_Bool);
+ break;
+ case TK__Complex:
+ basicType.setComplex(true);
+ break;
+ case TK__Imaginary:
+ basicType.setImaginary(true);
+ break;
+ }
+ }
+
+ boolean isConst = contains(TK_const);
+ boolean isRestrict = contains(TK_restrict);
+ boolean isVolatile = contains(TK_volatile);
+
+ if(isConst || isRestrict || isVolatile)
+ return new C99QualifierType(basicType, isConst, isVolatile, isRestrict);
+ else
+ return basicType;
+ }
+
+
+ public void modifyBinding(C99Variable var) {
+ if(!var.isAuto())
+ var.setAuto(contains(TK_auto));
+ if(!var.isExtern())
+ var.setExtern(contains(TK_extern));
+ if(!var.isRegister())
+ var.setRegister(contains(TK_register));
+ if(!var.isStatic())
+ var.setStatic(contains(TK_static));
+ }
+
+ public void modifyBinding(C99Function function) {
+ if(!function.isAuto())
+ function.setAuto(contains(TK_auto));
+ if(!function.isExtern())
+ function.setExtern(contains(TK_extern));
+ if(!function.isInline())
+ function.setInline(contains(TK_inline));
+ if(!function.isRegister())
+ function.setRegister(contains(TK_register));
+ if(!function.isStatic())
+ function.setStatic(contains(TK_static));
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/DeclaratorFrame.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/DeclaratorFrame.java
new file mode 100644
index 00000000000..48fa25410e6
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/DeclaratorFrame.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import lpg.lpgjavaruntime.IToken;
+
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.C99PointerType;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+
+/**
+ * Represents a frame on the declaration stack used by the resolver actions.
+ *
+ * TODO: document this class better
+ *
+ * @author Mike Kucera
+ */
+@SuppressWarnings("restriction")
+public class DeclaratorFrame {
+ private DeclSpec declSpec;
+ //IBinding declarator;
+ private IToken declaratorName;
+ private boolean isDeclaratorBracketed;
+ private boolean isFunctionDeclarator = false;
+
+ // temporary storage for pointer modifiers
+ private LinkedList<LinkedList<C99PointerType>> pointerModifiers = new LinkedList<LinkedList<C99PointerType>>();
+
+ // stores pointer and array modifiers that are applied to the declarator
+ private LinkedList<ITypeContainer> typeModifiers = new LinkedList<ITypeContainer>();
+
+ private LinkedList<IBinding> nestedDeclarations = new LinkedList<IBinding>();
+
+
+ public DeclaratorFrame() {
+ }
+
+ public DeclaratorFrame(DeclSpec declSpec) {
+ this.declSpec = declSpec;
+ }
+
+
+ public DeclSpec getDeclSpec() {
+ if(declSpec == null)
+ declSpec = new DeclSpec();
+
+ return declSpec;
+ }
+
+ public IType getDeclaratorType() {
+ // the declSpec may be null, so use getDeclSpec()
+ IType baseType = getDeclSpec().getType();
+
+ if(typeModifiers.isEmpty())
+ return baseType;
+
+ IType type = typeModifiers.get(0);
+
+ // link the types together
+ for(int i = 1; i < typeModifiers.size(); i++) {
+ ITypeContainer t1 = typeModifiers.get(i-1);
+ ITypeContainer t2 = typeModifiers.get(i);
+ t1.setType(t2);
+ }
+
+ ITypeContainer last = typeModifiers.get(typeModifiers.size()-1);
+ last.setType(baseType);
+ return type;
+ }
+
+ public IToken getDeclaratorName() {
+ return declaratorName;
+ }
+ public void setDeclaratorName(IToken declaratorName) {
+ this.declaratorName = declaratorName;
+ }
+ public boolean isDeclaratorBracketed() {
+ return isDeclaratorBracketed;
+ }
+ public void setDeclaratorBracketed(boolean isDeclaratorBracketed) {
+ this.isDeclaratorBracketed = isDeclaratorBracketed;
+ }
+ public boolean isFunctionDeclarator() {
+ return isFunctionDeclarator;
+ }
+ public void setFunctionDeclarator(boolean isFunctionDeclarator) {
+ this.isFunctionDeclarator = isFunctionDeclarator;
+ }
+
+ public List<IBinding> getNestedDeclarations() {
+ return nestedDeclarations;
+ }
+
+ public void addNestedDeclaration(IBinding binding) {
+ nestedDeclarations.add(binding);
+ }
+
+ public void removeLastNestedDeclaration() {
+ nestedDeclarations.removeLast();
+ }
+
+ public void addTypeModifier(ITypeContainer x) {
+ typeModifiers.add(x);
+ }
+
+ public void removeLastTypeModifier() {
+ typeModifiers.removeLast();
+ }
+
+ public void addPointerModifier(C99PointerType x) {
+ pointerModifiers.getLast().add(x);
+ }
+
+ public void removeLastPointerModifier() {
+ pointerModifiers.getLast().removeLast();
+ }
+
+ public void openPointerModifierScope() {
+ pointerModifiers.add(new LinkedList<C99PointerType>());
+ }
+
+ public void openPointerModifierScope(LinkedList<C99PointerType> scope) {
+ pointerModifiers.add(scope);
+ }
+
+ public LinkedList<C99PointerType> closePointerModifierScope() {
+ return pointerModifiers.removeLast();
+ }
+}
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/IC99ASTNodeFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/IC99ASTNodeFactory.java
new file mode 100644
index 00000000000..b15d85fd267
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/IC99ASTNodeFactory.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
+import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
+import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
+import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
+import org.eclipse.cdt.core.dom.lrparser.action.IASTNodeFactory;
+
+/**
+ * Factory for AST nodes that are just used by C and not by C++.
+ *
+ * @author Mike Kucera
+ */
+public interface IC99ASTNodeFactory extends IASTNodeFactory {
+
+
+ public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner, boolean isPointerDereference);
+
+ public ICASTTypeIdInitializerExpression newCTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializerList list);
+
+ public ICASTArrayModifier newModifiedArrayModifier();
+
+ public ICASTKnRFunctionDeclarator newCKnRFunctionDeclarator();
+
+ public ICASTPointer newCPointer();
+
+ public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
+
+ public ICASTDesignatedInitializer newCDesignatedInitializer(IASTInitializer rhs);
+
+ public ICASTArrayDesignator newCArrayDesignator(IASTExpression exp);
+
+ public ICASTFieldDesignator newCFieldDesignator(IASTName name);
+
+ public ICASTSimpleDeclSpecifier newCSimpleDeclSpecifier();
+
+ public ICASTTypedefNameSpecifier newCTypedefNameSpecifier();
+
+ public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
+
+ public ICASTCompositeTypeSpecifier newCCompositeTypeSpecifier(int key, IASTName name);
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ImperativeSymbolTable.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ImperativeSymbolTable.java
new file mode 100644
index 00000000000..c1648dc0f9b
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/ImperativeSymbolTable.java
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.IC99Binding;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.IC99Scope;
+
+
+/**
+ * Used to compute binding resolution during the parse.
+ *
+ * Imperative style symbol table with destructive update.
+ *
+ * Consists of two data structures, a hash table for fast lookup
+ * of bindings given their names, and a stack used to keep track
+ * of scopes.
+ *
+ * @deprecated Use FunctionalSymbolTable now that undo actions are needed
+ *
+ * @author Mike Kucera
+ */
+@Deprecated public class ImperativeSymbolTable {
+
+ private static final int TABLE_SIZE = 256;
+
+ private Bucket[] table = new Bucket[TABLE_SIZE];
+
+ private LinkedList<SymbolScope> scopeStack = new LinkedList<SymbolScope>();
+
+
+
+ /**
+ * Represents a scope in the C language.
+ */
+ private static class SymbolScope {
+
+ /**
+ * List of buckets that have been modified in the current scope.
+ * When the scope is closed these buckets are popped, returning the
+ * symbol table to the state it was in before the scope was opened.
+ */
+ List<Integer> modifiedBuckets = new ArrayList<Integer>();
+
+ /**
+ * List of inner scopes that have been closed.
+ */
+ List<IC99Scope> innerScopes = new ArrayList<IC99Scope>();
+ }
+
+
+ /**
+ * A bucket object used to hold elements in the hash table.
+ */
+ private static class Bucket {
+ String key;
+ CNamespace namespace;
+ IC99Binding binding;
+ Bucket next;
+
+ Bucket(Bucket next, CNamespace namespace, String key, IC99Binding binding) {
+ this.key = key;
+ this.namespace = namespace;
+ this.binding = binding;
+ this.next = next;
+ }
+ }
+
+
+ public ImperativeSymbolTable() {
+ openScope(); // open the global scope
+ // TODO populate the global scope with built-ins
+ }
+
+
+ /**
+ * Hashes a key into an index in the hash table.
+ */
+ private int index(String key) {
+ return Math.abs(key.hashCode() % TABLE_SIZE);
+ }
+
+
+ /**
+ * Adds a binding to the symbol table in the current scope.
+ *
+ * @param mask A bit mask used to identify the namespace of the identifier.
+ */
+ public void put(CNamespace namespace, String ident, IC99Binding b) {
+ int index = index(ident);
+ table[index] = new Bucket(table[index], namespace, ident, b);
+
+ SymbolScope scope = scopeStack.getLast();
+ scope.modifiedBuckets.add(index);
+ }
+
+
+ /**
+ * Special version of put that adds the binding to the scope that contains
+ * the current scope.
+ *
+ * This is here because the scope for a function body is opened before
+ * the function binding is created.
+ */
+ public void putInOuterScope(CNamespace namespace, String ident, IC99Binding b) {
+ LinkedList<Bucket> poppedBindings = new LinkedList<Bucket>();
+ SymbolScope scope = scopeStack.removeLast();
+
+ for(int index : scope.modifiedBuckets) {
+ Bucket bucket = table[index];
+ poppedBindings.add(bucket);
+ table[index] = bucket.next;
+ }
+
+ put(namespace, ident, b);
+
+ for(int index : scope.modifiedBuckets) {
+ Bucket bucket = poppedBindings.removeFirst();
+ bucket.next = table[index];
+ table[index] = bucket;
+ }
+
+ scopeStack.add(scope);
+ }
+
+
+ /**
+ * Returns the binding associated with the given identifier, or
+ * null if there is none.
+ *
+ * @param mask A bit mask used to identify the namespace of the identifier.
+ */
+ public IC99Binding get(CNamespace namespace, String ident) {
+ Bucket b = table[index(ident)];
+ while(b != null) {
+ if(namespace == b.namespace && ident.equals(b.key))
+ return b.binding;
+ b = b.next;
+ }
+ return null;
+ }
+
+
+ List<IC99Scope> getInnerScopes() {
+ return scopeStack.getLast().innerScopes;
+ }
+
+
+ /**
+ * Opens a new inner scope for identifiers.
+ *
+ * If an identifier is added that already exists in an outer scope
+ * then it will be shadowed.
+ */
+ public void openScope() {
+ scopeStack.add(new SymbolScope());
+ }
+
+
+ /**
+ * Remove all the symbols defined in the scope that is being closed.
+ *
+ * @param scope An IScope object that will be used to represent this scope.
+ * @throws SymbolTableException If the global scope has already been closed or if bindingScope is null.
+ */
+ public void closeScope(IC99Scope bindingScope) {
+ SymbolScope poppedScope = scopeStack.removeLast(); // pop the scopeStack
+
+ for(IC99Scope innerScope : poppedScope.innerScopes) {
+ innerScope.setParent(bindingScope);
+ }
+
+ if(!scopeStack.isEmpty()) { // would be empty if the global scope was popped
+ SymbolScope outerScope = scopeStack.getLast();
+ outerScope.innerScopes.add(bindingScope);
+ }
+
+ // pop each bucket that was modified in the scope
+ for(int index : poppedScope.modifiedBuckets) {
+ Bucket bucket = table[index];
+ bucket.binding.setScope(bindingScope);
+ table[index] = bucket.next;
+ }
+ }
+
+
+ public String toString() {
+ StringBuilder buff = new StringBuilder("[");
+ for(Bucket b : table) {
+ while(b != null) {
+ buff.append("<").append(b.key).append(": ").append(b.binding).append(">, ");
+ b = b.next;
+ }
+ }
+ return buff.append("]").toString();
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/TypedefSymbolTable.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/TypedefSymbolTable.java
new file mode 100644
index 00000000000..68c4b11b027
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/TypedefSymbolTable.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.c99;
+
+
+import org.eclipse.cdt.core.dom.lrparser.action.FunctionalMap;
+
+/**
+ * A facade for a FunctionalMap that is used just to track typedef
+ * declarations.
+ *
+ * This class acts like a set. No information needs to be associated
+ * with a typedef declaration, all we need to know is if the identifier
+ * has been declared as a typedef.
+ *
+ * @author Mike Kucera
+ */
+public class TypedefSymbolTable {
+
+ /**
+ * Start with EMPTY_TABLE and build up a symbol table using add().
+ */
+ public static final TypedefSymbolTable EMPTY_TABLE = new TypedefSymbolTable();
+
+
+ // the map we are providing a facade for
+ private final FunctionalMap<String,Object> map;
+
+
+ /**
+ * Constructors are private, start with EMPTY_TABLE
+ * and build it up using insert().
+ */
+ private TypedefSymbolTable() {
+ map = FunctionalMap.emptyMap();
+ }
+
+ private TypedefSymbolTable(FunctionalMap<String,Object> newRoot) {
+ map = newRoot;
+ }
+
+
+ public TypedefSymbolTable add(String typedefIdent) {
+ return new TypedefSymbolTable(map.insert(typedefIdent, null));
+ }
+
+
+ public boolean contains(String typedef) {
+ return map.containsKey(typedef);
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ public boolean isEmpty() {
+ return map.size() == 0;
+ }
+
+ @Override public String toString() {
+ return map.toString();
+ }
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTNodeFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTNodeFactory.java
new file mode 100644
index 00000000000..22ac610ae3c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTNodeFactory.java
@@ -0,0 +1,498 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
+import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTForStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
+import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPointer;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
+import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
+import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
+import org.eclipse.cdt.core.dom.lrparser.action.ASTCompletionNode;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTASMDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArraySubscriptExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBaseSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBreakStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCaseStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCastExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCatchHandler;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTConditionalExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTConstructorInitializer;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTContinueStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTConversionName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarationStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDefaultStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeleteExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDoStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEnumerationSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEnumerator;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExplicitTemplateInstantiation;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionList;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTForStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTGotoStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIfStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTInitializerExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTInitializerList;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLabelStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLinkageSpecification;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamedTypeSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceAlias;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceDefinition;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNewExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNullStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTOperatorName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTPointer;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTPointerToMember;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTProblem;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTProblemDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTProblemExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTProblemStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReferenceOperator;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleTypeConstructorExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSwitchStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateSpecialization;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTryBlockStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeIdExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypenameExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTUnaryExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTUsingDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTUsingDirective;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTVisibilityLabel;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTWhileStatement;
+
+@SuppressWarnings("restriction") // all AST node constructors are internal
+/**
+ * Abstract factory implementation that creates C++ AST nodes.
+ *
+ * @author Mike Kucera
+ */
+public class CPPASTNodeFactory implements ICPPASTNodeFactory {
+
+ public static final CPPASTNodeFactory DEFAULT_INSTANCE = new CPPASTNodeFactory();
+
+
+ public ASTCompletionNode newCompletionNode(String prefix, IASTTranslationUnit tu) {
+ return new ASTCompletionNode((prefix == null || prefix.length() == 0) ? null : prefix, tu);
+ }
+
+ public IASTName newName(char[] name) {
+ return new CPPASTName(name);
+ }
+
+ public IASTName newName() {
+ return new CPPASTName();
+ }
+
+ public ICPPASTOperatorName newCPPOperatorName(char[] name) {
+ return new CPPASTOperatorName(name);
+ }
+
+ public IASTProblem newProblem(int id, char[] arg, boolean warn, boolean error) {
+ return new CPPASTProblem(id, arg, warn, error);
+ }
+
+ public IASTProblemDeclaration newProblemDeclaration() {
+ return new CPPASTProblemDeclaration();
+ }
+
+ public IASTProblemExpression newProblemExpression() {
+ return new CPPASTProblemExpression();
+ }
+
+ public IASTProblemStatement newProblemStatement() {
+ return new CPPASTProblemStatement();
+ }
+
+ public IASTLiteralExpression newLiteralExpression(int kind, String rep) {
+ return new CPPASTLiteralExpression(kind, rep);
+ }
+
+ public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) {
+ return new CPPASTUnaryExpression(operator, operand);
+ }
+
+ public IASTIdExpression newIdExpression(IASTName name) {
+ return new CPPASTIdExpression(name);
+ }
+
+ public IASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript) {
+ return new CPPASTArraySubscriptExpression(arrayExpr, subscript);
+ }
+
+ public IASTExpressionList newExpressionList() {
+ return new CPPASTExpressionList();
+ }
+
+ public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList) {
+ return new CPPASTFunctionCallExpression(idExpr, argList);
+ }
+
+ public IASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand) {
+ return new CPPASTCastExpression(operator, typeId, operand);
+ }
+
+ public ICPPASTNewExpression newCPPNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId) {
+ return new CPPASTNewExpression(placement, initializer, typeId);
+ }
+
+ public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) {
+ return new CPPASTBinaryExpression(op, expr1, expr2);
+ }
+
+ public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3) {
+ return new CPPASTConditionalExpression(expr1, expr2, expr3);
+ }
+
+ public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner, boolean isPointerDereference, boolean isTemplate) {
+ return new CPPASTFieldReference(name, owner, isPointerDereference, isTemplate);
+ }
+
+ public ICPPASTTemplateId newCPPTemplateId(IASTName templateName) {
+ return new CPPASTTemplateId(templateName);
+ }
+
+ public ICPPASTConversionName newCPPConversionName(char[] name, IASTTypeId typeId) {
+ return new CPPASTConversionName(name, typeId);
+ }
+
+ public ICPPASTQualifiedName newCPPQualifiedName() {
+ return new CPPASTQualifiedName();
+ }
+
+ public IASTCaseStatement newCaseStatement(IASTExpression expr) {
+ return new CPPASTCaseStatement(expr);
+ }
+
+ public IASTDefaultStatement newDefaultStatement() {
+ return new CPPASTDefaultStatement();
+ }
+
+ public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement) {
+ return new CPPASTLabelStatement(name, nestedStatement);
+ }
+
+ public IASTExpressionStatement newExpressionStatement(IASTExpression expression) {
+ return new CPPASTExpressionStatement(expression);
+ }
+
+ public IASTNullStatement newNullStatement() {
+ return new CPPASTNullStatement();
+ }
+
+ public IASTCompoundStatement newCompoundStatement() {
+ return new CPPASTCompoundStatement();
+ }
+
+ public IASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause) {
+ return new CPPASTIfStatement(condition, then, elseClause);
+ }
+
+ public IASTSwitchStatement newSwitchStatment(IASTExpression controller, IASTStatement body) {
+ return new CPPASTSwitchStatement(controller, body);
+ }
+
+ public IASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause) {
+ return new CPPASTIfStatement(condition, then, elseClause);
+ }
+
+ public IASTSwitchStatement newSwitchStatment(IASTDeclaration controller, IASTStatement body) {
+ return new CPPASTSwitchStatement(controller, body);
+ }
+
+ public IASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body) {
+ return new CPPASTWhileStatement(condition, body);
+ }
+
+ public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) {
+ return new CPPASTDoStatement(body, condition);
+ }
+
+ public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
+ return new CPPASTWhileStatement(condition, body);
+ }
+
+ public IASTBreakStatement newBreakStatement() {
+ return new CPPASTBreakStatement();
+ }
+
+ public IASTContinueStatement newContinueStatement() {
+ return new CPPASTContinueStatement();
+ }
+
+ public IASTGotoStatement newGotoStatement(IASTName name) {
+ return new CPPASTGotoStatement(name);
+ }
+
+ public IASTReturnStatement newReturnStatement(IASTExpression retValue) {
+ return new CPPASTReturnStatement(retValue);
+ }
+
+ public IASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
+ IASTExpression iterationExpr, IASTStatement body) {
+ return new CPPASTForStatement(init, condition, iterationExpr, body);
+ }
+
+ public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) {
+ return new CPPASTDeclarationStatement(declaration);
+ }
+
+ public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
+ return new CPPASTTypeIdExpression(operator, typeId);
+ }
+
+ public IASTDeclarator newDeclarator(IASTName name) {
+ return new CPPASTDeclarator(name);
+ }
+
+ public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
+ return new CPPASTTypeId(declSpecifier, declarator);
+ }
+
+ public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand) {
+ return new CPPASTDeleteExpression(operand);
+ }
+
+ public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
+ return new CPPASTSimpleDeclaration(declSpecifier);
+ }
+
+ public IASTInitializerExpression newInitializerExpression(IASTExpression expression) {
+ return new CPPASTInitializerExpression(expression);
+ }
+
+ public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
+ IASTStatement bodyStatement) {
+ return new CPPASTFunctionDefinition(declSpecifier, declarator, bodyStatement);
+ }
+
+ public IASTTranslationUnit newTranslationUnit() {
+ return new CPPASTTranslationUnit();
+ }
+
+ public ICPPASTSimpleDeclSpecifier newCPPSimpleDeclSpecifier() {
+ return new CPPASTSimpleDeclSpecifier();
+ }
+
+ public IASTStandardFunctionDeclarator newFunctionDeclarator(IASTName name) {
+ return new CPPASTFunctionDeclarator(name);
+ }
+
+ public ICPPASTSimpleTypeConstructorExpression newCPPSimpleTypeConstructorExpression(
+ int type, IASTExpression expression) {
+ return new CPPASTSimpleTypeConstructorExpression(type, expression);
+ }
+
+ public ICPPASTTypenameExpression newCPPTypenameExpression(
+ ICPPASTQualifiedName qualifiedName, IASTExpression expr, boolean isTemplate) {
+ return new CPPASTTypenameExpression(qualifiedName, expr, isTemplate);
+ }
+
+ public IASTASMDeclaration newASMDeclaration(String assembly) {
+ return new CPPASTASMDeclaration(assembly);
+ }
+
+ public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName) {
+ return new CPPASTNamespaceAlias(alias, qualifiedName);
+ }
+
+ public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name) {
+ return new CPPASTUsingDeclaration(name);
+ }
+
+ public ICPPASTUsingDirective newUsingDirective(IASTName name) {
+ return new CPPASTUsingDirective(name);
+ }
+
+ public ICPPASTLinkageSpecification newLinkageSpecification(String name) {
+ return new CPPASTLinkageSpecification(name);
+ }
+
+ public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name) {
+ return new CPPASTNamespaceDefinition(name);
+ }
+
+ public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration) {
+ return new CPPASTTemplateDeclaration(declaration);
+ }
+
+ public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration) {
+ return new CPPASTExplicitTemplateInstantiation(declaration);
+ }
+
+ public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration) {
+ return new CPPASTTemplateSpecialization(declaration);
+ }
+
+ public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body) {
+ return new CPPASTTryBlockStatement(body);
+ }
+
+ public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body) {
+ return new CPPASTCatchHandler(decl, body);
+ }
+
+ public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) {
+ return new CPPASTEnumerationSpecifier(name);
+ }
+
+ public IASTEnumerator newEnumerator(IASTName name, IASTExpression value) {
+ return new CPPASTEnumerator(name, value);
+ }
+
+ public ICPPASTVisiblityLabel newVisibilityLabel(int visibility) {
+ return new CPPASTVisibilityLabel(visibility);
+ }
+
+ public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual) {
+ return new CPPASTBaseSpecifier(name, visibility, isVirtual);
+ }
+
+ public ICPPASTCompositeTypeSpecifier newCPPCompositeTypeSpecifier(int key, IASTName name) {
+ return new CPPASTCompositeTypeSpecifier(key, name);
+ }
+
+ public ICPPASTNamedTypeSpecifier newCPPNamedTypeSpecifier(IASTName name, boolean typename) {
+ return new CPPASTNamedTypeSpecifier(name, typename);
+ }
+
+ public IASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) {
+ return new CPPASTElaboratedTypeSpecifier(kind, name);
+ }
+
+ public IASTPointer newCPPPointer() {
+ return new CPPASTPointer();
+ }
+
+ public ICPPASTReferenceOperator newReferenceOperator() {
+ return new CPPASTReferenceOperator();
+ }
+
+ public ICPPASTPointerToMember newPointerToMember(IASTName name) {
+ return new CPPASTPointerToMember(name);
+ }
+
+ public IASTInitializerList newInitializerList() {
+ return new CPPASTInitializerList();
+ }
+
+ public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp) {
+ return new CPPASTConstructorInitializer(exp);
+ }
+
+ public IASTArrayModifier newArrayModifier(IASTExpression expr) {
+ return new CPPASTArrayModifier(expr);
+ }
+
+ public IASTArrayDeclarator newArrayDeclarator(IASTName name) {
+ return new CPPASTArrayDeclarator(name);
+ }
+
+ public ICPPASTFunctionDeclarator newCPPFunctionDeclarator(IASTName name) {
+ return new CPPASTFunctionDeclarator(name);
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java
new file mode 100644
index 00000000000..3fb0a84ced3
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java
@@ -0,0 +1,1370 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.cpp;
+
+import static org.eclipse.cdt.core.dom.lrparser.util.CollectionUtils.findFirstAndRemove;
+import static org.eclipse.cdt.core.dom.lrparser.util.CollectionUtils.reverseIterable;
+import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.*;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import lpg.lpgjavaruntime.IToken;
+
+import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTPointer;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
+import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+import org.eclipse.cdt.core.dom.lrparser.action.BuildASTParserAction;
+import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+
+/**
+ * Semantic actions that build the AST during the parse. These are the actions
+ * that are specific to the C++ parser.
+ *
+ * @author Mike Kucera
+ *
+ */
+public class CPPBuildASTParserAction extends BuildASTParserAction {
+
+
+ /** Used to create the AST node objects */
+ protected final ICPPASTNodeFactory nodeFactory;
+
+ /**
+ * @param parser
+ * @param orderedTerminalSymbols When an instance of this class is created for a parser
+ * that parsers token kinds will be mapped back to the base C99 parser's token kinds.
+ */
+ public CPPBuildASTParserAction(ICPPASTNodeFactory nodeFactory, IParserActionTokenProvider parser, IASTTranslationUnit tu) {
+ super(nodeFactory, parser, tu);
+ this.nodeFactory = nodeFactory;
+ }
+
+ @Override protected boolean isCompletionToken(IToken token) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+// /**
+// * Used only for debugging purposes.
+// *
+// * Use this to make expression the start symbol for the grammar,
+// * it will be inserted into the translation unit inside a function.
+// */
+// @Deprecated public void consumeExpressionAsTranslationUnit() {
+// if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+//
+// IASTExpression expression = (IASTExpression) astStack.pop();
+//
+// ICPPASTSimpleDeclSpecifier declSpec = nodeFactory.newCPPSimpleDeclSpecifier();
+// declSpec.setType(IASTSimpleDeclSpecifier.t_int);
+//
+// IASTFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(nodeFactory.newName("main".toCharArray())); //$NON-NLS-1$
+//
+// IASTCompoundStatement body = nodeFactory.newCompoundStatement();
+// body.addStatement(nodeFactory.newExpressionStatement(expression));
+//
+//
+// IASTFunctionDefinition funcDef =
+// nodeFactory.newFunctionDefinition(declSpec, declarator, body);
+//
+// tu.addDeclaration(funcDef);
+// }
+
+
+
+ /**
+ * new_expression
+ * ::= dcolon_opt 'new' new_placement_opt new_type_id <openscope-ast> new_array_expressions_op new_initializer_opt
+ * | dcolon_opt 'new' new_placement_opt '(' type_id ')' new_initializer_opt
+ */
+ public void consumeExpressionNew(boolean isNewTypeId) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression initializer = (IASTExpression) astStack.pop(); // may be null
+
+ List<Object> arrayExpressions = Collections.emptyList();
+ if(isNewTypeId) {
+ arrayExpressions = astStack.closeScope();
+ }
+
+ IASTTypeId typeId = (IASTTypeId) astStack.pop();
+ IASTExpression placement = (IASTExpression) astStack.pop(); // may be null
+
+ boolean hasDoubleColon = astStack.pop() == PLACE_HOLDER;
+
+ ICPPASTNewExpression newExpression = nodeFactory.newCPPNewExpression(placement, initializer, typeId);
+ newExpression.setIsGlobal(hasDoubleColon);
+ newExpression.setIsNewTypeId(isNewTypeId);
+
+ for(Object expr : arrayExpressions) {
+ newExpression.addNewTypeIdArrayExpression((IASTExpression)expr);
+ }
+
+ setOffsetAndLength(newExpression);
+ astStack.push(newExpression);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * new_declarator -- pointer operators are part of the type id, held in an empty declarator
+ * ::= <openscope-ast> new_pointer_operators
+ */
+ public void consumeNewDeclarator() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = nodeFactory.newName();
+ IASTDeclarator declarator = nodeFactory.newDeclarator(name);
+
+ for(Object pointer : astStack.closeScope()) {
+ declarator.addPointerOperator((IASTPointerOperator)pointer);
+ }
+
+ setOffsetAndLength(declarator);
+ astStack.push(declarator);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * throw_expression
+ * ::= 'throw'
+ * | 'throw' assignment_expression
+ */
+ public void consumeExpressionThrow(boolean hasExpr) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression operand = hasExpr ? (IASTExpression) astStack.pop() : null;
+ IASTUnaryExpression expr = nodeFactory.newUnaryExpression(ICPPASTUnaryExpression.op_throw, operand);
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * delete_expression
+ * ::= dcolon_opt 'delete' cast_expression
+ * | dcolon_opt 'delete' '[' ']' cast_expression
+ * @param isVectorized
+ */
+ public void consumeExpressionDelete(boolean isVectorized) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression operand = (IASTExpression) astStack.pop();
+ boolean hasDoubleColon = astStack.pop() == PLACE_HOLDER;
+
+ ICPPASTDeleteExpression deleteExpr = nodeFactory.newDeleteExpression(operand);
+ deleteExpr.setIsGlobal(hasDoubleColon);
+ deleteExpr.setIsVectored(isVectorized);
+
+ setOffsetAndLength(deleteExpr);
+ astStack.push(deleteExpr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ *
+ */
+ public void consumeExpressionFieldReference(boolean isPointerDereference, boolean hasTemplateKeyword) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = (IASTName) astStack.pop();
+ IASTExpression owner = (IASTExpression) astStack.pop();
+ IASTFieldReference expr = nodeFactory.newFieldReference(name, owner, isPointerDereference, hasTemplateKeyword);
+
+ setOffsetAndLength(expr);
+ astStack.push(expr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+ /**
+ * postfix_expression
+ * ::= simple_type_specifier '(' expression_list_opt ')'
+ */
+ public void consumeExpressionSimpleTypeConstructor() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expression = (IASTExpression) astStack.pop();
+ IToken token = (IToken) astStack.pop();
+
+ int type = asICPPASTSimpleTypeConstructorExpressionType(token);
+ ICPPASTSimpleTypeConstructorExpression typeConstructor = nodeFactory.newCPPSimpleTypeConstructorExpression(type, expression);
+
+ setOffsetAndLength(typeConstructor);
+ astStack.push(typeConstructor);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ private static int asICPPASTSimpleTypeConstructorExpressionType(IToken token) {
+ assert token != null;
+
+ switch(token.getKind()) {
+ case TK_char : return ICPPASTSimpleTypeConstructorExpression.t_char;
+ case TK_wchar_t : return ICPPASTSimpleTypeConstructorExpression.t_wchar_t;
+ case TK_bool : return ICPPASTSimpleTypeConstructorExpression.t_bool;
+ case TK_short : return ICPPASTSimpleTypeConstructorExpression.t_short;
+ case TK_int : return ICPPASTSimpleTypeConstructorExpression.t_int;
+ case TK_long : return ICPPASTSimpleTypeConstructorExpression.t_long;
+ case TK_signed : return ICPPASTSimpleTypeConstructorExpression.t_signed;
+ case TK_unsigned : return ICPPASTSimpleTypeConstructorExpression.t_unsigned;
+ case TK_float : return ICPPASTSimpleTypeConstructorExpression.t_float;
+ case TK_double : return ICPPASTSimpleTypeConstructorExpression.t_double;
+ case TK_void : return ICPPASTSimpleTypeConstructorExpression.t_void;
+
+ default:
+ assert false : "type parsed wrong"; //$NON-NLS-1$
+ return ICPPASTSimpleTypeConstructorExpression.t_unspecified;
+ }
+ }
+
+
+ /**
+ * postfix_expression
+ * ::= 'typename' dcolon_opt nested_name_specifier <empty> identifier_name '(' expression_list_opt ')'
+ * | 'typename' dcolon_opt nested_name_specifier template_opt template_id '(' expression_list_opt ')'
+ */
+ @SuppressWarnings("unchecked")
+ public void consumeExpressionTypeName() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr = (IASTExpression) astStack.pop();
+ IASTName name = (IASTName) astStack.pop();
+ boolean isTemplate = astStack.pop() == PLACE_HOLDER;
+ LinkedList<IASTName> nestedNames = (LinkedList<IASTName>) astStack.pop();
+ boolean hasDColon = astStack.pop() == PLACE_HOLDER;
+
+ nestedNames.addFirst(name);
+ ICPPASTQualifiedName qualifiedName = createQualifiedName(nestedNames, hasDColon);
+
+ ICPPASTTypenameExpression typenameExpr = nodeFactory.newCPPTypenameExpression(qualifiedName, expr, isTemplate);
+
+ setOffsetAndLength(typenameExpr);
+ astStack.push(typenameExpr);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * condition
+ * ::= type_specifier_seq declarator '=' assignment_expression
+ */
+ public void consumeConditionDeclaration() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expr = (IASTExpression) astStack.pop();
+ IASTDeclarator declarator = (IASTDeclarator) astStack.pop();
+ IASTDeclSpecifier declSpec = (IASTDeclSpecifier) astStack.pop();
+
+ IASTInitializerExpression initializer = nodeFactory.newInitializerExpression(expr);
+ setOffsetAndLength(initializer, offset(expr), length(expr));
+ declarator.setInitializer(initializer);
+
+ IASTSimpleDeclaration declaration = nodeFactory.newSimpleDeclaration(declSpec);
+ declaration.addDeclarator(declarator);
+
+ setOffsetAndLength(declaration);
+ astStack.push(declaration);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * template_id
+ * ::= template_name '<' <openscope-ast> template_argument_list_opt '>'
+ *
+ * operator_function_id
+ * ::= operator_id '<' <openscope-ast> template_argument_list_opt '>'
+ */
+ public void consumeTemplateId() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> templateArguments = astStack.closeScope();
+ IASTName name = (IASTName) astStack.pop();
+ ICPPASTTemplateId templateId = nodeFactory.newCPPTemplateId(name);
+
+ for(Object arg : templateArguments) {
+ if(arg instanceof IASTExpression)
+ templateId.addTemplateArgument((IASTExpression)arg);
+ else
+ templateId.addTemplateArgument((IASTTypeId)arg);
+ }
+
+ setOffsetAndLength(templateId);
+ astStack.push(templateId);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * operator_id
+ * ::= 'operator' overloadable_operator
+ */
+ public void consumeOperatorName() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<IToken> tokens = parser.getRuleTokens();
+ char[] operatorName = concatenateTokens(tokens.subList(1, tokens.size()));
+
+ ICPPASTOperatorName name = nodeFactory.newCPPOperatorName(operatorName);
+ setOffsetAndLength(name);
+ astStack.push(name);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ private static char[] concatenateTokens(List<IToken> tokens) {
+ StringBuilder sb = new StringBuilder(20); // longest operator name: operator delete[]
+
+ for(IToken t : tokens)
+ sb.append(t);
+
+ char[] cs = new char[sb.length()];
+ sb.getChars(0, sb.length(), cs, 0);
+ return cs;
+ }
+
+
+ /**
+ * conversion_function_id
+ * ::= 'operator' conversion_type_id
+ */
+ public void consumeConversionName() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ char[] chars = concatenateTokens(parser.getRuleTokens());
+ IASTTypeId typeId = (IASTTypeId) astStack.pop();
+
+ ICPPASTConversionName name = nodeFactory.newCPPConversionName(chars, typeId);
+
+ setOffsetAndLength(name);
+ astStack.push(name);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * unqualified_id
+ * ::= '~' class_name
+ */
+ public void consumeDestructorName() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ astStack.pop(); // throw away the name node thats already on the stack
+
+ char[] chars = concatenateTokens(parser.getRuleTokens());
+ IASTName name = nodeFactory.newName(chars);
+ setOffsetAndLength(name);
+ astStack.push(name);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * qualified_id
+ * ::= '::' identifier_name
+ * | '::' operator_function_id
+ * | '::' template_id
+ */
+ public void consumeGlobalQualifiedId() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = (IASTName) astStack.pop();
+
+ ICPPASTQualifiedName qualifiedName = nodeFactory.newCPPQualifiedName();
+ qualifiedName.addName(name);
+ qualifiedName.setFullyQualified(true);
+
+ setOffsetAndLength(qualifiedName);
+ astStack.push(name);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * selection_statement ::= switch '(' condition ')' statement
+ */
+ public void consumeStatementSwitch() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStatement body = (IASTStatement) astStack.pop();
+
+ Object condition = astStack.pop();
+
+ IASTSwitchStatement stat;
+ if(condition instanceof IASTExpression)
+ stat = nodeFactory.newSwitchStatment((IASTExpression)condition, body);
+ else
+ stat = nodeFactory.newSwitchStatment((IASTDeclaration)condition, body);
+
+
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ public void consumeStatementIf(boolean hasElse) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStatement elseClause = hasElse ? (IASTStatement)astStack.pop() : null;
+ IASTStatement thenClause = (IASTStatement) astStack.pop();
+
+ Object condition = astStack.pop();
+
+ IASTIfStatement ifStatement;
+ if(condition instanceof IASTExpression)
+ ifStatement = nodeFactory.newIfStatement((IASTExpression)condition, thenClause, elseClause);
+ else
+ ifStatement = nodeFactory.newIfStatement((IASTDeclaration)condition, thenClause, elseClause);
+
+ setOffsetAndLength(ifStatement);
+ astStack.push(ifStatement);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * iteration_statement ::= 'while' '(' condition ')' statement
+ */
+ public void consumeStatementWhileLoop() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStatement body = (IASTStatement) astStack.pop();
+
+ Object condition = astStack.pop();
+
+ IASTWhileStatement whileStatement;
+ if(condition instanceof IASTExpression)
+ whileStatement = nodeFactory.newWhileStatement((IASTExpression)condition, body);
+ else
+ whileStatement = nodeFactory.newWhileStatement((IASTDeclaration)condition, body);
+
+ setOffsetAndLength(whileStatement);
+ astStack.push(whileStatement);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * block_item ::= declaration | statement
+ *
+ * Wrap a declaration in a DeclarationStatement.
+ */
+ public void consumeStatementDeclaration() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclaration decl = (IASTDeclaration) astStack.pop();
+
+ IASTDeclarationStatement stat = nodeFactory.newDeclarationStatement(decl);
+ setOffsetAndLength(stat);
+ astStack.push(stat);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * try_block
+ * ::= 'try' compound_statement <openscope-ast> handler_seq
+ */
+ public void consumeStatementTryBlock() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> handlerSeq = astStack.closeScope();
+ IASTStatement body = (IASTStatement) astStack.pop();
+
+ ICPPASTTryBlockStatement tryStatement = nodeFactory.newTryBlockStatement(body);
+
+ for(Object handler : handlerSeq)
+ tryStatement.addCatchHandler((ICPPASTCatchHandler)handler);
+
+ setOffsetAndLength(tryStatement);
+ astStack.push(tryStatement);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * handler
+ * ::= 'catch' '(' exception_declaration ')' compound_statement
+ * | 'catch' '(' '...' ')' compound_statement
+ */
+ public void consumeStatementCatchHandler(boolean hasEllipsis) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTStatement body = (IASTStatement) astStack.pop();
+ IASTDeclaration decl = (hasEllipsis) ? (IASTDeclaration) astStack.pop() : null;
+
+ ICPPASTCatchHandler catchHandler = nodeFactory.newCatchHandler(decl, body);
+ catchHandler.setIsCatchAll(hasEllipsis);
+
+ setOffsetAndLength(catchHandler);
+ astStack.push(catchHandler);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * nested_name_specifier
+ * ::= class_or_namespace_name '::' nested_name_specifier_with_template
+ * | class_or_namespace_name '::'
+ *
+ * nested_name_specifier_with_template
+ * ::= class_or_namespace_name_with_template '::' nested_name_specifier_with_template
+ * | class_or_namespace_name_with_template '::'
+ *
+ *
+ * Creates and updates a list of the nested names on the stack.
+ * Important: the names in the list are in *reverse* order,
+ * this is because the actions fire in reverse order.
+ */
+ @SuppressWarnings("unchecked")
+ public void consumeNestedNameSpecifier(final boolean hasNested) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ LinkedList<IASTName> names;
+ if(hasNested)
+ names = (LinkedList<IASTName>) astStack.pop();
+ else
+ names = new LinkedList<IASTName>();
+
+ IASTName name = (IASTName) astStack.pop();
+ names.add(name);
+
+ astStack.push(names);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ public void consumeNestedNameSpecifierEmpty() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ astStack.push(new LinkedList<IASTName>());
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+
+ /**
+ * The template keyword is optional but must be the leftmost token.
+ */
+ @Deprecated public void consumeNameWithTemplateKeyword() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = (IASTName) astStack.pop();
+ boolean hasTemplateKeyword = astStack.pop() == PLACE_HOLDER;
+
+ if(hasTemplateKeyword)
+ name = addTemplateKeyword(parser.getLeftIToken(), name);
+
+ astStack.push(name);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ @Deprecated private IASTName addTemplateKeyword(final IToken templateKeyword, final IASTName name) {
+ IASTName replacement = nodeFactory.newName((templateKeyword + " " + name).toCharArray()); //$NON-NLS-1$
+ int offset = offset(templateKeyword);
+ int length = length(name) + (offset(name) - offset);
+ setOffsetAndLength(replacement, offset, length);
+ return replacement;
+ }
+
+
+
+ /**
+ * qualified_id
+ * ::= dcolon_opt nested_name_specifier any_name
+ */
+ public void consumeQualifiedId(boolean hasTemplateKeyword) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ ICPPASTQualifiedName qualifiedName = subRuleQualifiedName(hasTemplateKeyword);
+ astStack.push(qualifiedName);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * Creates a qualified name from a list of names (that must be in reverse order).
+ * Does not set the offset and length.
+ */
+ private ICPPASTQualifiedName createQualifiedName(LinkedList<IASTName> nestedNames, boolean hasDColon) {
+ ICPPASTQualifiedName qualifiedName = nodeFactory.newCPPQualifiedName();
+
+ int startOffset = offset(nestedNames.getLast());
+ int length = endOffset(nestedNames.getFirst()) - startOffset;
+ setOffsetAndLength(qualifiedName, startOffset, length);
+
+ for(IASTName name : reverseIterable(nestedNames))
+ qualifiedName.addName(name);
+
+ qualifiedName.setFullyQualified(hasDColon);
+
+ return qualifiedName;
+ }
+
+
+ /**
+ * Consumes grammar sub-rules of the following form:
+ *
+ * dcolon_opt nested_name_specifier_opt keyword_opt name
+ *
+ * Where name is any rule that produces an IASTName node on the stack.
+ * Does not place the resulting node on the stack, returns it instead.
+ */
+ @SuppressWarnings("unchecked")
+ private ICPPASTQualifiedName subRuleQualifiedName(boolean hasOptionalKeyword) {
+ IASTName subName = (IASTName) astStack.pop();
+
+ if(hasOptionalKeyword) // this is usually a template keyword and can be ignored
+ astStack.pop();
+
+ LinkedList<IASTName> nestedNames = (LinkedList<IASTName>) astStack.pop();
+ boolean hasDColon = astStack.pop() == PLACE_HOLDER;
+
+ nestedNames.addFirst(subName);
+ return createQualifiedName(nestedNames, hasDColon);
+ }
+
+
+
+ /**
+ * pseudo_destructor_name
+ * ::= dcolon_opt nested_name_specifier_opt type_name '::' '~' type_name
+ * | dcolon_opt nested_name_specifier 'template' template_id '::' '~' type_name
+ * | dcolon_opt nested_name_specifier_opt '~' type_name
+ */
+ @SuppressWarnings("unchecked")
+ public void consumePsudoDestructorName(boolean hasExtraTypeName) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName extraTypeName = null;
+ if(hasExtraTypeName)
+ extraTypeName = (IASTName) astStack.pop();
+
+ IASTName typeName = (IASTName) astStack.pop(); // or tempalte_id
+
+ LinkedList<IASTName> nestedNames = (LinkedList<IASTName>) astStack.pop();
+ boolean hasDColon = astStack.pop() == PLACE_HOLDER;
+
+ nestedNames.addFirst(typeName);
+
+ if(hasExtraTypeName)
+ nestedNames.addFirst(extraTypeName);
+
+ ICPPASTQualifiedName qualifiedName = createQualifiedName(nestedNames, hasDColon);
+
+ setOffsetAndLength(qualifiedName);
+ astStack.push(qualifiedName);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * asm_definition
+ * ::= 'asm' '(' 'stringlit' ')' ';'
+ */
+ public void consumeDeclarationASM() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ String s = parser.getRuleTokens().get(2).toString();
+ IASTASMDeclaration asm = nodeFactory.newASMDeclaration(s);
+
+ setOffsetAndLength(asm);
+ astStack.push(asm);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+ /**
+ * namespace_alias_definition
+ * ::= 'namespace' 'identifier' '=' dcolon_opt nested_name_specifier_opt namespace_name ';'
+ */
+ public void consumeNamespaceAliasDefinition() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ ICPPASTQualifiedName qualifiedName = subRuleQualifiedName(false);
+
+ IASTName alias = createName(parser.getRuleTokens().get(1));
+ ICPPASTNamespaceAlias namespaceAlias = nodeFactory.newNamespaceAlias(alias, qualifiedName);
+
+ setOffsetAndLength(namespaceAlias);
+ astStack.push(namespaceAlias);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * using_declaration
+ * ::= 'using' typename_opt dcolon_opt nested_name_specifier_opt unqualified_id ';'
+ */
+ public void consumeUsingDeclaration() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ ICPPASTQualifiedName qualifiedName = subRuleQualifiedName(false);
+ boolean hasTypenameKeyword = astStack.pop() == PLACE_HOLDER;
+
+ ICPPASTUsingDeclaration usingDeclaration = nodeFactory.newUsingDeclaration(qualifiedName);
+ usingDeclaration.setIsTypename(hasTypenameKeyword);
+
+ setOffsetAndLength(usingDeclaration);
+ astStack.push(usingDeclaration);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * using_directive
+ * ::= 'using' 'namespace' dcolon_opt nested_name_specifier_opt namespace_name ';'
+ */
+ public void consumeUsingDirective() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ ICPPASTQualifiedName qualifiedName = subRuleQualifiedName(false);
+
+ ICPPASTUsingDirective usingDirective = nodeFactory.newUsingDirective(qualifiedName);
+ setOffsetAndLength(usingDirective);
+ astStack.push(usingDirective);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * linkage_specification
+ * ::= 'extern' 'stringlit' '{' <openscope-ast> declaration_seq_opt '}'
+ * | 'extern' 'stringlit' <openscope-ast> declaration
+ */
+ public void consumeLinkageSpecification() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ String name = parser.getRuleTokens().get(1).toString();
+ ICPPASTLinkageSpecification linkageSpec = nodeFactory.newLinkageSpecification(name);
+
+ for(Object declaration : astStack.closeScope())
+ linkageSpec.addDeclaration((IASTDeclaration)declaration);
+
+ setOffsetAndLength(linkageSpec);
+ astStack.push(linkageSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+ /**
+ * original_namespace_definition
+ * ::= 'namespace' identifier_name '{' <openscope-ast> declaration_seq_opt '}'
+ *
+ * extension_namespace_definition
+ * ::= 'namespace' original_namespace_name '{' <openscope-ast> declaration_seq_opt '}'
+ *
+ * unnamed_namespace_definition
+ * ::= 'namespace' '{' <openscope-ast> declaration_seq_opt '}'
+ */
+ public void consumeNamespaceDefinition(boolean hasName) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> declarations = astStack.closeScope();
+ IASTName namespaceName = (hasName) ? (IASTName) astStack.pop() : null;
+
+ ICPPASTNamespaceDefinition definition = nodeFactory.newNamespaceDefinition(namespaceName);
+
+ for(Object declaration : declarations)
+ definition.addDeclaration((IASTDeclaration)declaration);
+
+ setOffsetAndLength(definition);
+ astStack.push(definition);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * template_declaration
+ * ::= export_opt 'template' '<' template_parameter_list '>' declaration
+ */
+ public void consumeTemplateDeclaration() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclaration declaration = (IASTDeclaration) astStack.pop();
+
+ ICPPASTTemplateDeclaration templateDeclaration = nodeFactory.newTemplateDeclaration(declaration);
+
+ for(Object param : astStack.closeScope())
+ templateDeclaration.addTemplateParamter((ICPPASTTemplateParameter)param);
+
+ boolean hasExportKeyword = astStack.pop() == PLACE_HOLDER;
+ templateDeclaration.setExported(hasExportKeyword);
+
+ setOffsetAndLength(templateDeclaration);
+ astStack.push(templateDeclaration);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * explicit_instantiation
+ * ::= 'template' declaration
+ */
+ public void consumeTemplateExplicitInstantiation() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclaration declaration = (IASTDeclaration) astStack.pop();
+ ICPPASTExplicitTemplateInstantiation instantiation = nodeFactory.newExplicitTemplateInstantiation(declaration);
+
+ setOffsetAndLength(instantiation);
+ astStack.push(instantiation);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * explicit_specialization
+ * ::= 'template' '<' '>' declaration
+ */
+ public void consumeTemplateExplicitSpecialization() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclaration declaration = (IASTDeclaration) astStack.pop();
+ ICPPASTTemplateSpecialization specialization = nodeFactory.newTemplateSpecialization(declaration);
+
+ setOffsetAndLength(specialization);
+ astStack.push(specialization);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * Sets a token specifier.
+ * Needs to be overrideable for new decl spec keywords.
+ *
+ * @param token Allows subclasses to override this method and use any
+ * object to determine how to set a specifier.
+ */
+ protected void setSpecifier(IASTDeclSpecifier node, IToken token) {
+ //TODO int kind = asC99Kind(token);
+
+ int kind = token.getKind();
+ switch(kind){
+ case TK_typedef: node.setStorageClass(IASTDeclSpecifier.sc_typedef); return;
+ case TK_extern: node.setStorageClass(IASTDeclSpecifier.sc_extern); return;
+ case TK_static: node.setStorageClass(IASTDeclSpecifier.sc_static); return;
+ case TK_auto: node.setStorageClass(IASTDeclSpecifier.sc_auto); return;
+ case TK_register: node.setStorageClass(IASTDeclSpecifier.sc_register); return;
+ case TK_inline: node.setInline(true); return;
+ case TK_const: node.setConst(true); return;
+ case TK_volatile: node.setVolatile(true); return;
+ }
+
+ // TODO: this isn't finished
+ if(node instanceof ICPPASTSimpleDeclSpecifier) {
+ ICPPASTSimpleDeclSpecifier n = (ICPPASTSimpleDeclSpecifier) node;
+ switch(kind) {
+ case TK_void: n.setType(IASTSimpleDeclSpecifier.t_void); break;
+ case TK_char: n.setType(IASTSimpleDeclSpecifier.t_char); break;
+ case TK_int: n.setType(IASTSimpleDeclSpecifier.t_int); break;
+ case TK_float: n.setType(IASTSimpleDeclSpecifier.t_float); break;
+ case TK_double: n.setType(IASTSimpleDeclSpecifier.t_double); break;
+ case TK_signed: n.setSigned(true); break;
+ case TK_unsigned: n.setUnsigned(true); break;
+ case TK_long: n.setLong(true); break;
+ case TK_short: n.setShort(true); break;
+ }
+ }
+ }
+
+
+ public void consumeDeclarationSpecifiersSimple() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTSimpleDeclSpecifier declSpec = nodeFactory.newCPPSimpleDeclSpecifier();
+
+ for(Object token : astStack.closeScope())
+ setSpecifier(declSpec, (IToken)token);
+
+ setOffsetAndLength(declSpec);
+ astStack.push(declSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * TODO: maybe move this into the superclass
+ */
+ public void consumeDeclarationSpecifiersComposite() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> topScope = astStack.closeScope();
+
+ // There's already a composite or elaborated or enum type specifier somewhere on the stack, find it.
+ IASTDeclSpecifier declSpec = findFirstAndRemove(topScope, IASTDeclSpecifier.class);
+
+ // now apply the rest of the specifiers
+ for(Object token : topScope)
+ setSpecifier(declSpec, (IToken)token);
+
+ setOffsetAndLength(declSpec);
+ astStack.push(declSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+
+
+// /**
+// * declaration_specifiers ::= <openscope> type_name_declaration_specifiers
+// */
+ public void consumeDeclarationSpecifiersTypeName() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> topScope = astStack.closeScope();
+ // There's a name somewhere on the stack, find it
+ IASTName typeName = findFirstAndRemove(topScope, IASTName.class);
+
+ // TODO what does the second argument mean?
+ ICPPASTNamedTypeSpecifier declSpec = nodeFactory.newCPPNamedTypeSpecifier(typeName, true);
+
+ // now apply the rest of the specifiers
+ for(Object token : topScope)
+ setSpecifier(declSpec, (IToken)token);
+
+ setOffsetAndLength(declSpec);
+ astStack.push(declSpec);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * elaborated_type_specifier
+ * ::= class_keyword dcolon_opt nested_name_specifier_opt identifier_name
+ * | class_keyword dcolon_opt nested_name_specifier_opt template_opt template_id_name
+ * | 'enum' dcolon_opt nested_name_specifier_opt identifier_name
+ */
+ public void consumeTypeSpecifierElaborated(boolean hasOptionalTemplateKeyword) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = subRuleQualifiedName(hasOptionalTemplateKeyword);
+ int kind = getElaboratedTypeSpecifier(parser.getLeftIToken());
+
+ IASTElaboratedTypeSpecifier typeSpecifier = nodeFactory.newElaboratedTypeSpecifier(kind, name);
+
+ setOffsetAndLength(typeSpecifier);
+ astStack.push(typeSpecifier);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ private static int getElaboratedTypeSpecifier(IToken token) {
+ switch(token.getKind()) {
+ default: assert false;
+ case TK_struct: return IASTElaboratedTypeSpecifier.k_struct;
+ case TK_union: return IASTElaboratedTypeSpecifier.k_union;
+ case TK_enum: return IASTElaboratedTypeSpecifier.k_enum;
+ case TK_class: return ICPPASTElaboratedTypeSpecifier.k_class;
+ }
+ }
+
+
+ /**
+ * visibility_label
+ * ::= access_specifier_keyword ':'
+ */
+ public void consumeVisibilityLabel() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ int visibility = getAccessSpecifier(parser.getLeftIToken());
+ ICPPASTVisiblityLabel visibilityLabel = nodeFactory.newVisibilityLabel(visibility);
+ setOffsetAndLength(visibilityLabel);
+ astStack.push(visibilityLabel);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ private static int getAccessSpecifier(IToken token) {
+ switch(token.getKind()) {
+ default: assert false;
+ case TK_private: return ICPPASTVisiblityLabel.v_private;
+ case TK_public: return ICPPASTVisiblityLabel.v_public;
+ case TK_protected: return ICPPASTVisiblityLabel.v_protected;
+ }
+ }
+
+
+ /**
+ * base_specifier
+ * ::= dcolon_opt nested_name_specifier_opt class_name
+ * | virtual_opt access_specifier_keyword virtual_opt dcolon_opt nested_name_specifier_opt class_name
+ */
+ public void consumeBaseSpecifier(boolean hasAccessSpecifier) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = subRuleQualifiedName(false);
+ boolean isVirtual = false;
+ int visibility = 0; // this is the default value that the DOM parser uses
+
+ if(hasAccessSpecifier) {
+ boolean hasVirtualKeyword2 = astStack.pop() == PLACE_HOLDER;
+ boolean hasVirtualKeyword1 = astStack.pop() == PLACE_HOLDER;
+ isVirtual = hasVirtualKeyword1 | hasVirtualKeyword2;
+
+ IToken accessSpecifierToken = parser.getRuleTokens().get(hasVirtualKeyword1 ? 1 : 0);
+ visibility = getAccessSpecifier(accessSpecifierToken);
+ }
+
+ ICPPASTBaseSpecifier baseSpecifier = nodeFactory.newBaseSpecifier(name, visibility, isVirtual);
+ setOffsetAndLength(baseSpecifier);
+ astStack.push(baseSpecifier);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * class_specifier
+ * ::= class_head '{' <openscope-ast> member_declaration_list_opt '}'
+ */
+ public void consumeClassSpecifier() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> declarations = astStack.closeScope();
+
+ // the class specifier is created by the rule for class_head
+ IASTCompositeTypeSpecifier classSpecifier = (IASTCompositeTypeSpecifier) astStack.pop();
+
+ for(Object declaration : declarations) {
+ classSpecifier.addMemberDeclaration((IASTDeclaration)declaration);
+ }
+
+ setOffsetAndLength(classSpecifier);
+ astStack.push(classSpecifier);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+ /**
+ * class_head
+ * ::= class_keyword identifier_name_opt <openscope-ast> base_clause_opt
+ * | class_keyword template_id <openscope-ast> base_clause_opt
+ * | class_keyword nested_name_specifier identifier_name <openscope-ast> base_clause_opt
+ * | class_keyword nested_name_specifier template_id <openscope-ast> base_clause_opt
+ */
+ @SuppressWarnings("unchecked")
+ public void consumeClassHead(boolean hasNestedNameSpecifier) {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ int key = getCompositeTypeSpecifier(parser.getLeftIToken());
+ List<Object> baseSpecifiers = astStack.closeScope();
+
+ // may be null, but if it is then hasNestedNameSpecifier == false
+ IASTName className = (IASTName) astStack.pop();
+
+ if(hasNestedNameSpecifier) {
+ LinkedList<IASTName> nestedNames = (LinkedList<IASTName>) astStack.pop();
+ nestedNames.addFirst(className);
+ className = createQualifiedName(nestedNames, false);
+ }
+
+ ICPPASTCompositeTypeSpecifier classSpecifier = nodeFactory.newCPPCompositeTypeSpecifier(key, className);
+
+ for(Object base : baseSpecifiers)
+ classSpecifier.addBaseSpecifier((ICPPASTBaseSpecifier)base);
+
+ // the offset and length are set in consumeClassSpecifier()
+ astStack.push(classSpecifier);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ private static int getCompositeTypeSpecifier(IToken token) {
+ switch(token.getKind()) {
+ default: assert false;
+ case TK_struct: return IASTCompositeTypeSpecifier.k_struct;
+ case TK_union: return IASTCompositeTypeSpecifier.k_union;
+ case TK_class: return ICPPASTCompositeTypeSpecifier.k_class;
+ }
+ }
+
+
+ /**
+ * ptr_operator
+ * ::= '*' <openscope-ast> cv_qualifier_seq_opt
+ */
+ public void consumePointer() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTPointer pointer = nodeFactory.newCPPPointer();
+ List<Object> tokens = astStack.closeScope();
+ addCVQualifiersToPointer(pointer, tokens);
+ setOffsetAndLength(pointer);
+ astStack.push(pointer);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ private static void addCVQualifiersToPointer(IASTPointer pointer, List<Object> tokens) {
+ for(Object t : tokens) {
+ IToken token = (IToken) t;
+ int kind = token.getKind(); // TODO this should be asXXXKind
+ switch(kind) {
+ default : assert false;
+ case TK_const: pointer.setConst(true); break;
+ case TK_volatile: pointer.setVolatile(true); break;
+ }
+ }
+ }
+
+ /**
+ * ptr_operator
+ * ::= '&'
+ */
+ public void consumeReferenceOperator() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ ICPPASTReferenceOperator referenceOperator = nodeFactory.newReferenceOperator();
+ setOffsetAndLength(referenceOperator);
+ astStack.push(referenceOperator);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * ptr_operator
+ * ::= dcolon_opt nested_name_specifier '*' <openscope-ast> cv_qualifier_seq_opt
+ */
+ @SuppressWarnings("unchecked")
+ public void consumePointerToMember() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ List<Object> qualifiers = astStack.closeScope();
+ LinkedList<IASTName> nestedNames = (LinkedList<IASTName>) astStack.pop();
+ boolean hasDColon = astStack.pop() == PLACE_HOLDER;
+ IASTName name = createQualifiedName(nestedNames, hasDColon);
+ ICPPASTPointerToMember pointer = nodeFactory.newPointerToMember(name);
+ addCVQualifiersToPointer(pointer, qualifiers);
+ setOffsetAndLength(pointer);
+ astStack.push(pointer);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * declarator
+ * ::= <openscope-ast> ptr_operator_seq_opt direct_declarator
+ */
+ public void consumeDeclaratorWithPointer() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTDeclarator declarator = (IASTDeclarator) astStack.pop();
+
+ for(Object ptr : astStack.closeScope()) {
+ declarator.addPointerOperator((IASTPointerOperator) ptr);
+ }
+
+ setOffsetAndLength(declarator); // TODO is it correct to change the offset and length?
+ astStack.push(declarator);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * init_declarator
+ * ::= declarator initializer
+ */
+ public void consumeDeclaratorWithInitializer() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTInitializer initializer = (IASTInitializer) astStack.pop();
+ IASTDeclarator declarator = (IASTDeclarator) astStack.peek();
+ declarator.setInitializer(initializer);
+ setOffsetAndLength(declarator); // adjust the length to include the initializer
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * initializer
+ * ::= '(' expression_list ')'
+ */
+ public void consumeInitializerConstructor() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTExpression expression = (IASTExpression) astStack.pop();
+ ICPPASTConstructorInitializer initializer = nodeFactory.newConstructorInitializer(expression);
+ setOffsetAndLength(initializer);
+ astStack.push(initializer);
+
+ if(TRACE_AST_STACK) System.out.println(astStack);
+ }
+
+
+ /**
+ * function_direct_declarator
+ * ::= basic_direct_declarator '(' <openscope-ast> parameter_declaration_clause ')'
+ * <openscope-ast> cv_qualifier_seq_opt <openscope-ast> exception_specification_opt
+ */
+ public void consumeDirectDeclaratorFunctionDeclarator() {
+ if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
+
+ IASTName name = nodeFactory.newName();
+ ICPPASTFunctionDeclarator declarator = nodeFactory.newCPPFunctionDeclarator(name);
+
+ for(Object typeId : astStack.closeScope()) {
+ declarator.addExceptionSpecificationTypeId((IASTTypeId) typeId);
+ }
+ for(Object token : astStack.closeScope()) {
+ switch(((IToken)token).getKind()) {
+ default: assert false;
+ case TK_const: declarator.setConst(true); break;
+ case TK_volatile: declarator.setVolatile(true); break;
+ }
+ }
+
+ boolean isVarArgs = astStack.pop() == PLACE_HOLDER;
+ declarator.setVarArgs(isVarArgs);
+
+ for(Object o : astStack.closeScope()) {
+ declarator.addParameterDeclaration((IASTParameterDeclaration)o);
+ }
+
+ int endOffset = endOffset(parser.getRightIToken());
+ consumeDirectDeclaratorFunctionDeclarator(declarator, endOffset);
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/ICPPASTNodeFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/ICPPASTNodeFactory.java
new file mode 100644
index 00000000000..2b3fc47edef
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/ICPPASTNodeFactory.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.action.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTPointer;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
+import org.eclipse.cdt.core.dom.lrparser.action.IASTNodeFactory;
+
+/**
+ * TODO remove CPP from method names.
+ *
+ * @author Mike Kucera
+ */
+public interface ICPPASTNodeFactory extends IASTNodeFactory {
+
+ public ICPPASTOperatorName newCPPOperatorName(char[] name);
+
+ public ICPPASTNewExpression newCPPNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId);
+
+ public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner, boolean isPointerDereference, boolean isTemplate);
+
+ public ICPPASTTemplateId newCPPTemplateId(IASTName templateName);
+
+ public ICPPASTConversionName newCPPConversionName(char[] name, IASTTypeId typeId);
+
+ public ICPPASTQualifiedName newCPPQualifiedName();
+
+ public IASTSwitchStatement newSwitchStatment(IASTDeclaration controller, IASTStatement body);
+
+ public IASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause);
+
+ public IASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body);
+
+ public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
+
+ public ICPPASTSimpleDeclSpecifier newCPPSimpleDeclSpecifier();
+
+ public ICPPASTSimpleTypeConstructorExpression newCPPSimpleTypeConstructorExpression(int type, IASTExpression expression);
+
+ public ICPPASTTypenameExpression newCPPTypenameExpression(ICPPASTQualifiedName qualifiedName, IASTExpression expr, boolean isTemplate);
+
+ public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName);
+
+ public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name);
+
+ public ICPPASTUsingDirective newUsingDirective(IASTName name);
+
+ public ICPPASTLinkageSpecification newLinkageSpecification(String name);
+
+ public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name);
+
+ public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration);
+
+ public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
+
+ public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration);
+
+ public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
+
+ public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body);
+
+ public ICPPASTVisiblityLabel newVisibilityLabel(int visibility);
+
+ public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual);
+
+ public ICPPASTCompositeTypeSpecifier newCPPCompositeTypeSpecifier(int key, IASTName name);
+
+ public ICPPASTNamedTypeSpecifier newCPPNamedTypeSpecifier(IASTName name, boolean typename);
+
+ public IASTPointer newCPPPointer();
+
+ public ICPPASTReferenceOperator newReferenceOperator();
+
+ public ICPPASTPointerToMember newPointerToMember(IASTName name);
+
+ public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp);
+
+ public ICPPASTFunctionDeclarator newCPPFunctionDeclarator(IASTName name);
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/C99Language.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/C99Language.java
new file mode 100644
index 00000000000..a05e0260368
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/C99Language.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.c99;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.IParser;
+import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
+import org.eclipse.cdt.core.dom.lrparser.action.c99.C99ASTNodeFactory;
+import org.eclipse.cdt.core.model.IContributedModelBuilder;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parser;
+
+/**
+ * ILanguage implementation for the C99 parser.
+ *
+ * @author Mike Kucera
+ */
+public class C99Language extends BaseExtensibleLanguage {
+
+ public static final String PLUGIN_ID = "org.eclipse.cdt.core.lrparser"; //$NON-NLS-1$
+ public static final String ID = PLUGIN_ID + ".c99"; //$NON-NLS-1$
+
+ private static final ITokenMap TOKEN_MAP = DOMToC99TokenMap.DEFAULT_MAP;
+ private static GCCLanguage GCC_LANGUAGE = GCCLanguage.getDefault();
+
+
+ private static C99Language DEFAULT = new C99Language();
+
+
+ public static C99Language getDefault() {
+ return DEFAULT;
+ }
+
+ @Override
+ protected IParser getParser() {
+ return new C99Parser();
+ }
+
+ @Override
+ protected ITokenMap getTokenMap() {
+ return TOKEN_MAP;
+ }
+
+ public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
+ return null;
+ }
+
+ public String getId() {
+ return ID;
+ }
+
+ public int getLinkageID() {
+ return ILinkage.C_LINKAGE_ID;
+ }
+
+ public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
+ return GCC_LANGUAGE.getSelectedNames(ast, start, length);
+ }
+
+ public String[] getBuiltinTypes() {
+ return GCC_LANGUAGE.getBuiltinTypes();
+ }
+
+ public String[] getKeywords() {
+ return GCC_LANGUAGE.getKeywords();
+ }
+
+ public String[] getPreprocessorKeywords() {
+ return GCC_LANGUAGE.getPreprocessorKeywords();
+ }
+
+ @Override
+ protected IASTTranslationUnit createASTTranslationUnit() {
+ return C99ASTNodeFactory.DEFAULT_INSTANCE.newTranslationUnit();
+ }
+
+ @Override
+ protected ParserLanguage getParserLanguageForPreprocessor() {
+ return ParserLanguage.C;
+ }
+
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/DOMToC99TokenMap.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/DOMToC99TokenMap.java
new file mode 100644
index 00000000000..0c47d8c6974
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/DOMToC99TokenMap.java
@@ -0,0 +1,329 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.c99;
+
+import static org.eclipse.cdt.core.parser.IToken.tAMPER;
+import static org.eclipse.cdt.core.parser.IToken.tAMPERASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tAND;
+import static org.eclipse.cdt.core.parser.IToken.tARROW;
+import static org.eclipse.cdt.core.parser.IToken.tASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tBITCOMPLEMENT;
+import static org.eclipse.cdt.core.parser.IToken.tBITOR;
+import static org.eclipse.cdt.core.parser.IToken.tBITORASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tCHAR;
+import static org.eclipse.cdt.core.parser.IToken.tCOLON;
+import static org.eclipse.cdt.core.parser.IToken.tCOMMA;
+import static org.eclipse.cdt.core.parser.IToken.tCOMPLETION;
+import static org.eclipse.cdt.core.parser.IToken.tDECR;
+import static org.eclipse.cdt.core.parser.IToken.tDIV;
+import static org.eclipse.cdt.core.parser.IToken.tDIVASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tDOT;
+import static org.eclipse.cdt.core.parser.IToken.tELLIPSIS;
+import static org.eclipse.cdt.core.parser.IToken.tEND_OF_INPUT;
+import static org.eclipse.cdt.core.parser.IToken.tEOC;
+import static org.eclipse.cdt.core.parser.IToken.tEQUAL;
+import static org.eclipse.cdt.core.parser.IToken.tFLOATINGPT;
+import static org.eclipse.cdt.core.parser.IToken.tGT;
+import static org.eclipse.cdt.core.parser.IToken.tGTEQUAL;
+import static org.eclipse.cdt.core.parser.IToken.tIDENTIFIER;
+import static org.eclipse.cdt.core.parser.IToken.tINCR;
+import static org.eclipse.cdt.core.parser.IToken.tINTEGER;
+import static org.eclipse.cdt.core.parser.IToken.tLBRACE;
+import static org.eclipse.cdt.core.parser.IToken.tLBRACKET;
+import static org.eclipse.cdt.core.parser.IToken.tLCHAR;
+import static org.eclipse.cdt.core.parser.IToken.tLPAREN;
+import static org.eclipse.cdt.core.parser.IToken.tLSTRING;
+import static org.eclipse.cdt.core.parser.IToken.tLT;
+import static org.eclipse.cdt.core.parser.IToken.tLTEQUAL;
+import static org.eclipse.cdt.core.parser.IToken.tMINUS;
+import static org.eclipse.cdt.core.parser.IToken.tMINUSASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tMOD;
+import static org.eclipse.cdt.core.parser.IToken.tMODASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tNOT;
+import static org.eclipse.cdt.core.parser.IToken.tNOTEQUAL;
+import static org.eclipse.cdt.core.parser.IToken.tOR;
+import static org.eclipse.cdt.core.parser.IToken.tPLUS;
+import static org.eclipse.cdt.core.parser.IToken.tPLUSASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tQUESTION;
+import static org.eclipse.cdt.core.parser.IToken.tRBRACE;
+import static org.eclipse.cdt.core.parser.IToken.tRBRACKET;
+import static org.eclipse.cdt.core.parser.IToken.tRPAREN;
+import static org.eclipse.cdt.core.parser.IToken.tSEMI;
+import static org.eclipse.cdt.core.parser.IToken.tSHIFTL;
+import static org.eclipse.cdt.core.parser.IToken.tSHIFTLASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tSHIFTR;
+import static org.eclipse.cdt.core.parser.IToken.tSHIFTRASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tSTAR;
+import static org.eclipse.cdt.core.parser.IToken.tSTARASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.tSTRING;
+import static org.eclipse.cdt.core.parser.IToken.tUNKNOWN_CHAR;
+import static org.eclipse.cdt.core.parser.IToken.tXOR;
+import static org.eclipse.cdt.core.parser.IToken.tXORASSIGN;
+import static org.eclipse.cdt.core.parser.IToken.t__Bool;
+import static org.eclipse.cdt.core.parser.IToken.t__Complex;
+import static org.eclipse.cdt.core.parser.IToken.t__Imaginary;
+import static org.eclipse.cdt.core.parser.IToken.t_auto;
+import static org.eclipse.cdt.core.parser.IToken.t_break;
+import static org.eclipse.cdt.core.parser.IToken.t_case;
+import static org.eclipse.cdt.core.parser.IToken.t_char;
+import static org.eclipse.cdt.core.parser.IToken.t_const;
+import static org.eclipse.cdt.core.parser.IToken.t_continue;
+import static org.eclipse.cdt.core.parser.IToken.t_default;
+import static org.eclipse.cdt.core.parser.IToken.t_do;
+import static org.eclipse.cdt.core.parser.IToken.t_double;
+import static org.eclipse.cdt.core.parser.IToken.t_else;
+import static org.eclipse.cdt.core.parser.IToken.t_enum;
+import static org.eclipse.cdt.core.parser.IToken.t_extern;
+import static org.eclipse.cdt.core.parser.IToken.t_float;
+import static org.eclipse.cdt.core.parser.IToken.t_for;
+import static org.eclipse.cdt.core.parser.IToken.t_goto;
+import static org.eclipse.cdt.core.parser.IToken.t_if;
+import static org.eclipse.cdt.core.parser.IToken.t_inline;
+import static org.eclipse.cdt.core.parser.IToken.t_int;
+import static org.eclipse.cdt.core.parser.IToken.t_long;
+import static org.eclipse.cdt.core.parser.IToken.t_register;
+import static org.eclipse.cdt.core.parser.IToken.t_restrict;
+import static org.eclipse.cdt.core.parser.IToken.t_return;
+import static org.eclipse.cdt.core.parser.IToken.t_short;
+import static org.eclipse.cdt.core.parser.IToken.t_signed;
+import static org.eclipse.cdt.core.parser.IToken.t_sizeof;
+import static org.eclipse.cdt.core.parser.IToken.t_static;
+import static org.eclipse.cdt.core.parser.IToken.t_struct;
+import static org.eclipse.cdt.core.parser.IToken.t_switch;
+import static org.eclipse.cdt.core.parser.IToken.t_typedef;
+import static org.eclipse.cdt.core.parser.IToken.t_union;
+import static org.eclipse.cdt.core.parser.IToken.t_unsigned;
+import static org.eclipse.cdt.core.parser.IToken.t_void;
+import static org.eclipse.cdt.core.parser.IToken.t_volatile;
+import static org.eclipse.cdt.core.parser.IToken.t_while;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_And;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_AndAnd;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_AndAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Arrow;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Assign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Bang;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Caret;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_CaretAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Colon;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Comma;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Completion;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Dot;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_DotDotDot;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_EOF_TOKEN;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_EQ;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_EndOfCompletion;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_GE;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_GT;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Invalid;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_LE;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_LT;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_LeftBrace;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_LeftBracket;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_LeftParen;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_LeftShift;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_LeftShiftAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Minus;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_MinusAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_MinusMinus;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_NE;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Or;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_OrAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_OrOr;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Percent;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_PercentAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Plus;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_PlusAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_PlusPlus;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Question;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_RightBrace;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_RightBracket;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_RightParen;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_RightShift;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_RightShiftAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_SemiColon;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Slash;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_SlashAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Star;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_StarAssign;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Tilde;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK__Bool;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK__Complex;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK__Imaginary;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_auto;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_break;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_case;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_char;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_charconst;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_const;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_continue;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_default;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_do;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_double;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_else;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_enum;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_extern;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_float;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_floating;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_for;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_goto;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_identifier;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_if;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_inline;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_int;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_integer;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_long;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_register;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_restrict;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_return;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_short;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_signed;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_sizeof;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_static;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_stringlit;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_struct;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_switch;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_typedef;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_union;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_unsigned;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_void;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_volatile;
+import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_while;
+
+import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
+
+/**
+ * Maps tokens types returned by CPreprocessor to token types
+ * expected by the C99 parser.
+ *
+ *
+ * TODO: Make token maps composable.
+ *
+ * The idea would be to combine a DOM->C99 map with a C99->UPC map
+ * to get a DOM->UPC map.
+ *
+ * @author Mike Kucera
+ *
+ */
+public final class DOMToC99TokenMap implements ITokenMap {
+
+
+ public static final DOMToC99TokenMap DEFAULT_MAP = new DOMToC99TokenMap();
+
+ private DOMToC99TokenMap() {
+ // just a private constructor
+ }
+
+ public int mapKind(int kind) {
+
+ switch(kind) {
+ case tIDENTIFIER : return TK_identifier;
+ case tINTEGER : return TK_integer;
+ case tCOLON : return TK_Colon;
+ case tSEMI : return TK_SemiColon;
+ case tCOMMA : return TK_Comma;
+ case tQUESTION : return TK_Question;
+ case tLPAREN : return TK_LeftParen;
+ case tRPAREN : return TK_RightParen;
+ case tLBRACKET : return TK_LeftBracket;
+ case tRBRACKET : return TK_RightBracket;
+ case tLBRACE : return TK_LeftBrace;
+ case tRBRACE : return TK_RightBrace;
+ case tPLUSASSIGN : return TK_PlusAssign;
+ case tINCR : return TK_PlusPlus;
+ case tPLUS : return TK_Plus;
+ case tMINUSASSIGN : return TK_MinusAssign;
+ case tDECR : return TK_MinusMinus;
+ case tARROW : return TK_Arrow;
+ case tMINUS : return TK_Minus;
+ case tSTARASSIGN : return TK_StarAssign;
+ case tSTAR : return TK_Star;
+ case tMODASSIGN : return TK_PercentAssign;
+ case tMOD : return TK_Percent;
+ case tXORASSIGN : return TK_CaretAssign;
+ case tXOR : return TK_Caret;
+ case tAMPERASSIGN : return TK_AndAssign;
+ case tAND : return TK_AndAnd;
+ case tAMPER : return TK_And;
+ case tBITORASSIGN : return TK_OrAssign;
+ case tOR : return TK_OrOr;
+ case tBITOR : return TK_Or;
+ case tBITCOMPLEMENT: return TK_Tilde;
+ case tNOTEQUAL : return TK_NE;
+ case tNOT : return TK_Bang;
+ case tEQUAL : return TK_EQ;
+ case tASSIGN : return TK_Assign;
+ case tUNKNOWN_CHAR : return TK_Invalid;
+ case tSHIFTL : return TK_LeftShift;
+ case tLTEQUAL : return TK_LE;
+ case tLT : return TK_LT;
+ case tSHIFTRASSIGN : return TK_RightShiftAssign;
+ case tSHIFTR : return TK_RightShift;
+ case tGTEQUAL : return TK_GE;
+ case tGT : return TK_GT;
+ case tSHIFTLASSIGN : return TK_LeftShiftAssign;
+ case tELLIPSIS : return TK_DotDotDot;
+ case tDOT : return TK_Dot;
+ case tDIVASSIGN : return TK_SlashAssign;
+ case tDIV : return TK_Slash;
+
+ case t_auto : return TK_auto;
+ case t_break : return TK_break;
+ case t_case : return TK_case;
+ case t_char : return TK_char;
+ case t_const : return TK_const;
+ case t_continue : return TK_continue;
+ case t_default : return TK_default;
+ case t_do : return TK_do;
+ case t_double : return TK_double;
+ case t_else : return TK_else;
+ case t_enum : return TK_enum;
+ case t_extern : return TK_extern;
+ case t_float : return TK_float;
+ case t_for : return TK_for;
+ case t_goto : return TK_goto;
+ case t_if : return TK_if;
+ case t_inline : return TK_inline;
+ case t_int : return TK_int;
+ case t_long : return TK_long;
+ case t_register : return TK_register;
+ case t_return : return TK_return;
+ case t_short : return TK_short;
+ case t_sizeof : return TK_sizeof;
+ case t_static : return TK_static;
+ case t_signed : return TK_signed;
+ case t_struct : return TK_struct;
+ case t_switch : return TK_switch;
+ case t_typedef : return TK_typedef;
+ case t_union : return TK_union;
+ case t_unsigned : return TK_unsigned;
+ case t_void : return TK_void;
+ case t_volatile : return TK_volatile;
+ case t_while : return TK_while;
+ case tFLOATINGPT : return TK_floating;
+ case tSTRING : return TK_stringlit;
+ case tLSTRING : return TK_stringlit;
+ case tCHAR : return TK_charconst;
+ case tLCHAR : return TK_charconst;
+ case t__Bool : return TK__Bool;
+ case t__Complex : return TK__Complex;
+ case t__Imaginary : return TK__Imaginary;
+ case t_restrict : return TK_restrict;
+ case tCOMPLETION : return TK_Completion;
+ case tEOC : return TK_EndOfCompletion;
+ case tEND_OF_INPUT : return TK_EOF_TOKEN;
+
+ default:
+ assert false : "token not recognized by the C99 parser: " + kind; //$NON-NLS-1$
+ return TK_Invalid;
+ }
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/DOMToISOCPPTokenMap.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/DOMToISOCPPTokenMap.java
new file mode 100644
index 00000000000..1dc65f8c311
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/DOMToISOCPPTokenMap.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.cpp;
+
+import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
+
+import static org.eclipse.cdt.core.parser.IToken.*;
+import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.*;
+
+/**
+ * Maps tokens types returned by CPreprocessor to token types
+ * expected by the C++ parser.
+ *
+ * TODO: Make token maps composable.
+ *
+ * The idea would be to combine a DOM->C99 map with a C99->UPC map
+ * to get a DOM->UPC map.
+ *
+ * @author Mike Kucera
+ *
+ */
+public class DOMToISOCPPTokenMap implements ITokenMap {
+
+
+ public static final DOMToISOCPPTokenMap DEFAULT_MAP = new DOMToISOCPPTokenMap();
+
+ private DOMToISOCPPTokenMap() {
+ // just a private constructor
+ }
+
+ public int mapKind(int kind) {
+
+ switch(kind) {
+ case tIDENTIFIER : return TK_identifier;
+ case tINTEGER : return TK_integer;
+ case tCOLONCOLON : return TK_ColonColon;
+ case tCOLON : return TK_Colon;
+ case tSEMI : return TK_SemiColon;
+ case tCOMMA : return TK_Comma;
+ case tQUESTION : return TK_Question;
+ case tLPAREN : return TK_LeftParen;
+ case tRPAREN : return TK_RightParen;
+ case tLBRACKET : return TK_LeftBracket;
+ case tRBRACKET : return TK_RightBracket;
+ case tLBRACE : return TK_LeftBrace;
+ case tRBRACE : return TK_RightBrace;
+ case tPLUSASSIGN : return TK_PlusAssign;
+ case tINCR : return TK_PlusPlus;
+ case tPLUS : return TK_Plus;
+ case tMINUSASSIGN : return TK_MinusAssign;
+ case tDECR : return TK_MinusMinus;
+ case tARROWSTAR : return TK_ArrowStar;
+ case tARROW : return TK_Arrow;
+ case tMINUS : return TK_Minus;
+ case tSTARASSIGN : return TK_StarAssign;
+ case tSTAR : return TK_Star;
+ case tMODASSIGN : return TK_PercentAssign;
+ case tMOD : return TK_Percent;
+ case tXORASSIGN : return TK_CaretAssign;
+ case tXOR : return TK_Caret;
+ case tAMPERASSIGN : return TK_AndAssign;
+ case tAND : return TK_AndAnd;
+ case tAMPER : return TK_And;
+ case tBITORASSIGN : return TK_OrAssign;
+ case tOR : return TK_OrOr;
+ case tBITOR : return TK_Or;
+ case tBITCOMPLEMENT: return TK_Tilde;
+ case tNOTEQUAL : return TK_NE;
+ case tNOT : return TK_Bang;
+ case tEQUAL : return TK_EQ;
+ case tASSIGN : return TK_Assign;
+ case tUNKNOWN_CHAR : return TK_Invalid;
+ case tSHIFTL : return TK_LeftShift;
+ case tLTEQUAL : return TK_LE;
+ case tLT : return TK_LT;
+ case tSHIFTRASSIGN : return TK_RightShiftAssign;
+ case tSHIFTR : return TK_RightShift;
+ case tGTEQUAL : return TK_GE;
+ case tGT : return TK_GT;
+ case tSHIFTLASSIGN : return TK_LeftShiftAssign;
+ case tELLIPSIS : return TK_DotDotDot;
+ case tDOTSTAR : return TK_DotStar;
+ case tDOT : return TK_Dot;
+ case tDIVASSIGN : return TK_SlashAssign;
+ case tDIV : return TK_Slash;
+
+ case t_asm : return TK_asm;
+ case t_auto : return TK_auto;
+ case t_bool : return TK_bool;
+ case t_break : return TK_break;
+ case t_case : return TK_case;
+ case t_catch : return TK_catch;
+ case t_char : return TK_char;
+ case t_class : return TK_class;
+ case t_const : return TK_const;
+ case t_const_cast : return TK_const_cast;
+ case t_continue : return TK_continue;
+ case t_default : return TK_default;
+ case t_delete : return TK_delete;
+ case t_do : return TK_do;
+ case t_double : return TK_double;
+ case t_dynamic_cast: return TK_dynamic_cast;
+ case t_else : return TK_else;
+ case t_enum : return TK_enum;
+ case t_explicit : return TK_explicit;
+ case t_export : return TK_export;
+ case t_extern : return TK_extern;
+ case t_false : return TK_false;
+ case t_float : return TK_float;
+ case t_for : return TK_for;
+ case t_friend : return TK_friend;
+ case t_goto : return TK_goto;
+ case t_if : return TK_if;
+ case t_inline : return TK_inline;
+ case t_int : return TK_int;
+ case t_long : return TK_long;
+ case t_mutable : return TK_mutable;
+ case t_namespace : return TK_namespace;
+ case t_new : return TK_new;
+ case t_operator : return TK_operator;
+ case t_private : return TK_private;
+ case t_protected : return TK_protected;
+ case t_public : return TK_public;
+ case t_register : return TK_register;
+ case t_return : return TK_return;
+ case t_short : return TK_short;
+ case t_sizeof : return TK_sizeof;
+ case t_static : return TK_static;
+ case t_static_cast : return TK_static_cast;
+ case t_signed : return TK_signed;
+ case t_struct : return TK_struct;
+ case t_switch : return TK_switch;
+ case t_template : return TK_template;
+ case t_this : return TK_this;
+ case t_throw : return TK_throw;
+ case t_true : return TK_true;
+ case t_try : return TK_try;
+ case t_typedef : return TK_typedef;
+ case t_typeid : return TK_typeid;
+ case t_typename : return TK_typename;
+ case t_union : return TK_union;
+ case t_unsigned : return TK_unsigned;
+ case t_using : return TK_using;
+ case t_virtual : return TK_virtual;
+ case t_void : return TK_void;
+ case t_volatile : return TK_volatile;
+ case t_wchar_t : return TK_wchar_t;
+ case t_while : return TK_while;
+
+ case tFLOATINGPT : return TK_floating;
+ case tSTRING : return TK_stringlit;
+ case tLSTRING : return TK_stringlit;
+ case tCHAR : return TK_charconst;
+ case tLCHAR : return TK_charconst;
+ case tCOMPLETION : return TK_Completion;
+ case tEOC : return TK_EndOfCompletion;
+ case tEND_OF_INPUT : return TK_EOF_TOKEN;
+
+ default:
+ assert false : "token not recognized by the ISO CPP parser: " + kind; //$NON-NLS-1$
+ return TK_Invalid;
+ }
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/ISOCPPLanguage.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/ISOCPPLanguage.java
new file mode 100644
index 00000000000..03eff1a60ce
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/ISOCPPLanguage.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.cpp;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.dom.lrparser.BaseExtensibleLanguage;
+import org.eclipse.cdt.core.dom.lrparser.IParser;
+import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
+import org.eclipse.cdt.core.dom.lrparser.action.c99.C99ASTNodeFactory;
+import org.eclipse.cdt.core.model.IContributedModelBuilder;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParser;
+
+/**
+ * ILanguage implementation for the C++ parser.
+ *
+ * @author Mike Kucera
+ */
+public class ISOCPPLanguage extends BaseExtensibleLanguage {
+
+ public static final String PLUGIN_ID = "org.eclipse.cdt.core.lrparser"; //$NON-NLS-1$
+ public static final String ID = PLUGIN_ID + ".isocpp"; //$NON-NLS-1$
+
+ private static final ITokenMap TOKEN_MAP = DOMToISOCPPTokenMap.DEFAULT_MAP;
+ private static GPPLanguage GPP_LANGUAGE = GPPLanguage.getDefault();
+
+
+ private static ISOCPPLanguage DEFAULT = new ISOCPPLanguage();
+
+
+ public static ISOCPPLanguage getDefault() {
+ return DEFAULT;
+ }
+
+ @Override
+ protected IParser getParser() {
+ return new CPPParser();
+ }
+
+ @Override
+ protected ITokenMap getTokenMap() {
+ return TOKEN_MAP;
+ }
+
+ public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
+ return null;
+ }
+
+ public String getId() {
+ return ID;
+ }
+
+ public int getLinkageID() {
+ return ILinkage.CPP_LINKAGE_ID;
+ }
+
+ public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
+ return GPP_LANGUAGE.getSelectedNames(ast, start, length);
+ }
+
+ public String[] getBuiltinTypes() {
+ return GPP_LANGUAGE.getBuiltinTypes();
+ }
+
+ public String[] getKeywords() {
+ return GPP_LANGUAGE.getKeywords();
+ }
+
+ public String[] getPreprocessorKeywords() {
+ return GPP_LANGUAGE.getPreprocessorKeywords();
+ }
+
+ @Override
+ protected IASTTranslationUnit createASTTranslationUnit() {
+ return C99ASTNodeFactory.DEFAULT_INSTANCE.newTranslationUnit();
+ }
+
+ @Override
+ protected ParserLanguage getParserLanguageForPreprocessor() {
+ return ParserLanguage.CPP;
+ }
+
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/AbstractTrialUndoActionProvider.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/AbstractTrialUndoActionProvider.java
new file mode 100644
index 00000000000..b3ea0ae0796
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/AbstractTrialUndoActionProvider.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.lpgextensions;
+
+import java.util.Collections;
+import java.util.List;
+
+import lpg.lpgjavaruntime.IToken;
+import lpg.lpgjavaruntime.LexStream;
+import lpg.lpgjavaruntime.PrsStream;
+
+/**
+ * Base class for parser action classes which support trial, undo and
+ * final actions.
+ */
+public abstract class AbstractTrialUndoActionProvider<ACT, RULE_DATA> extends PrsStream implements ITrialUndoActionProvider<RULE_DATA> {
+ /**
+ * An action that does nothing.
+ */
+ public static final Action<Object, Object> EMPTY_ACTION = new Action<Object, Object>();
+
+ /**
+ * The parser table interpreter.
+ */
+ protected TrialUndoParser btParser;
+
+
+
+ public AbstractTrialUndoActionProvider() {
+ super();
+ }
+
+
+ public AbstractTrialUndoActionProvider(LexStream lexStream) {
+ super(lexStream);
+ }
+
+ /**
+ * Actions for reduction rules.
+ */
+ protected Action<ACT, RULE_DATA>[] ruleAction;
+
+ protected ACT parserAction;
+
+ public void setParserAction(ACT parserAction) {
+ this.parserAction = parserAction;
+ }
+
+ /**
+ * The reduction rule which is currently being processed.
+ */
+ protected Rule<RULE_DATA> activeRule;
+
+ /**
+ * Returns the number of tokens in the rule being reduced.
+ */
+ public int getRuleTokenCount() {
+ return activeRule.getEndTokenOffset() - activeRule.getStartTokenOffset() + 1;
+ }
+
+ /**
+ * Returns the tokens in the rule being reduced.
+ */
+ @SuppressWarnings("unchecked")
+ public List<IToken> getRuleTokens() {
+ return Collections.unmodifiableList(getTokens().subList(getFirstRealToken(activeRule.getStartTokenOffset()), activeRule.getEndTokenOffset() + 1));
+ }
+
+ public void backtrack() {
+ btParser.backtrack();
+ }
+
+ public void setActiveRule(Rule<RULE_DATA> rule) {
+ activeRule = rule;
+ }
+
+ public Rule<RULE_DATA> getActiveRule() {
+ return activeRule;
+ }
+
+ public final boolean trialAction(int rule_number) {
+ return ruleAction[rule_number].doTrial(this, parserAction);
+ }
+
+ public final void undoAction(int rule_number) {
+ ruleAction[rule_number].doUndo(this, parserAction);
+ }
+
+ public final void finalAction(int rule_number) {
+ System.out.println("finalAction: " + rule_number);
+ ruleAction[rule_number].doFinal(this, parserAction);
+ }
+
+ public TrialUndoParser getParser() {
+ return btParser;
+ }
+
+ /**
+ * Returns the offset of the leftmost token of the
+ * rule being reduced.
+ */
+ private int getLeftSpan() {
+ return getFirstRealToken(activeRule.getStartTokenOffset());
+ }
+
+ /**
+ * Returns the leftmost token of the rule being reduced.
+ */
+ public IToken getLeftIToken() {
+ return super.getIToken(getLeftSpan());
+ }
+
+ /**
+ * Returns the offset of the rightmost token of the
+ * rule being reduced.
+ */
+ private int getRightSpan() {
+ return activeRule.getEndTokenOffset();
+ }
+
+ /**
+ * Returns the rightmost token of the rule being reduced.
+ */
+ public IToken getRightIToken() {
+ return super.getIToken(getRightSpan());
+ }
+
+ public static <ACT, RULE_DATA> Action<ACT, RULE_DATA> emptyAction() {
+ return new Action<ACT, RULE_DATA>();
+ }
+
+ @SuppressWarnings("unused")
+ public static class Action<ACT, RULE_DATA> {
+
+ public void doFinal(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
+ // convenience method, can be overridden
+
+ }
+
+ public boolean doTrial(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
+ //System.out.println(provider.getActiveRule());
+ //System.out.println(Rules.lookup(provider.getActiveRule().getRuleNumber()));
+ return false;
+ }
+
+ public void doUndo(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
+ //System.out.println(provider.getActiveRule() + " - undo");
+ // convenience method, can be overridden
+ }
+ }
+
+
+ public static class DeclaredAction<ACT, RULE_DATA> extends Action<ACT, RULE_DATA> {
+ protected boolean hasUndo = false;
+ @Override
+ public boolean doTrial(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
+ return true;
+ }
+ }
+
+
+ /**
+ * Action for a null rule
+ */
+ static final class NullAction<ACT, RULE_DATA> extends Action<ACT, RULE_DATA> {
+ @Override
+ public void doFinal(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
+ // do nothing
+ }
+ }
+
+
+ static final class BadAction<ACT, RULE_DATA> extends Action<ACT, RULE_DATA> {
+ @Override
+ public void doFinal(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
+ throw new Error(new BadActionException());
+ }
+
+ @Override
+ public boolean doTrial(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
+ throw new Error(new BadActionException());
+ }
+
+ @Override
+ public void doUndo(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
+ throw new Error(new BadActionException());
+ }
+ }
+
+
+ static public class BadActionException extends Exception {
+ private static final long serialVersionUID = 1L;
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/ITrialUndoActionProvider.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/ITrialUndoActionProvider.java
new file mode 100644
index 00000000000..17fb79ea28b
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/ITrialUndoActionProvider.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *********************************************************************************/
+
+package org.eclipse.cdt.core.dom.lrparser.lpgextensions;
+
+/**
+ * Provides trial, undo, and final actions for the
+ * TrialUndoBacktrackingParser.
+ */
+public interface ITrialUndoActionProvider<RULE_DATA> {
+ /**
+ * Invokes the trial action that corresponds to the given rule number.
+ */
+ boolean trialAction(int ruleNumber);
+
+ /**
+ * Invokes the undo action that corresponds to the given rule number.
+ */
+ void undoAction(int ruleNumber);
+
+ /**
+ * Invokes the final action that corresponds to the given rule number.
+ */
+ void finalAction(int ruleNumber);
+
+ /**
+ * Sets the given Rule as the active rule for this provider.
+ */
+ void setActiveRule(Rule<RULE_DATA> rule);
+
+ /**
+ * Returns the active rule for this provider.
+ */
+ Rule<RULE_DATA> getActiveRule();
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/ParserState.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/ParserState.java
new file mode 100644
index 00000000000..6760d157454
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/ParserState.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.lpgextensions;
+
+import java.util.LinkedList;
+
+import lpg.lpgjavaruntime.ConfigurationStack;
+import lpg.lpgjavaruntime.IntTuple;
+import lpg.lpgjavaruntime.TokenStream;
+
+class ParserState {
+ private static final int STACK_INCREMENT = 1024;
+
+ public int lastToken;
+ public int currentAction;
+ public IntTuple tokens;
+ public int actionStack[];
+ public int stateStackTop;
+ public int[] stateStack;
+ public int actionCount;
+ public int totalCommits;
+
+ public int[] parserLocationStack;
+ public int[] undoStack;
+
+ // Error recovery
+ public int[] locationStack;
+ public int repair_token;
+
+ /**
+ * The number of trial actions that have been executed since the last backtrackable point was encountered.
+ */
+ public int trialActionCount;
+
+ /**
+ * A stack that contains the number of trial actions that were executed at different backtrackable points.
+ */
+ public LinkedList<Integer> trialActionStack;
+
+ /**
+ * Trial actions that have been executed but not yet committed.
+ */
+ public LinkedList pendingCommits;
+
+ public ConfigurationStack configurationStack;
+
+ public int act;
+
+ public int curtok;
+
+ public ParserState(int startState, TokenStream tokStream) {
+ reallocateStateStack();
+ stateStackTop = 0;
+ stateStack[0] = startState;
+
+ //
+ // The tuple tokens will eventually contain the sequence
+ // of tokens that resulted in a successful parse. We leave
+ // it up to the "Stream" implementer to define the predecessor
+ // of the first token as he sees fit.
+ //
+ tokStream.reset(); // Position at first token.
+ tokens = new IntTuple(tokStream.getStreamLength());
+ tokens.add(tokStream.getPrevious(tokStream.peek()));
+ }
+
+ public void allocateOtherStacks() {
+ locationStack = new int[stateStack.length];
+ }
+
+ public void reallocateStateStack() {
+ int old_stack_length = (stateStack == null ? 0 : stateStack.length), stack_length = old_stack_length + STACK_INCREMENT;
+ if (stateStack == null)
+ stateStack = new int[stack_length];
+ else
+ System.arraycopy(stateStack, 0, stateStack = new int[stack_length], 0, old_stack_length);
+ return;
+ }
+
+ //
+ // Allocate or reallocate all the stacks. Their sizes should always be the
+ // same.
+ //
+ public void reallocateOtherStacks(int start_token_index) {
+ // assert(stateStack != null);
+ if (this.actionStack == null) {
+ this.actionStack = new int[stateStack.length];
+ locationStack = new int[stateStack.length];
+
+ actionStack[0] = 0;
+ undoStack = new int[stateStack.length];
+
+ locationStack[0] = start_token_index;
+
+ parserLocationStack = new int[stateStack.length];
+ parserLocationStack[0] = start_token_index;
+
+
+ } else if (this.actionStack.length < stateStack.length) {
+ int old_length = this.actionStack.length;
+
+ System.arraycopy(this.actionStack, 0, this.actionStack = new int[stateStack.length], 0, old_length);
+ System.arraycopy(this.undoStack, 0, this.undoStack = new int[stateStack.length], 0, old_length);
+ System.arraycopy(locationStack, 0, locationStack = new int[stateStack.length], 0, old_length);
+ }
+ return;
+ }
+
+
+ @SuppressWarnings("nls")
+ public void dumpState() {
+ System.out.print(curtok);
+ System.out.print("\t");
+ System.out.print(act);
+ System.out.print("\t");
+ dump(stateStack, stateStackTop);
+ System.out.print("\t");
+ dump(parserLocationStack, stateStackTop);
+ System.out.println();
+ }
+
+ @SuppressWarnings("nls")
+ private void dump(int[] array, int limit) {
+ System.out.print("[");
+ for (int i = 0; i < limit; i++) {
+ if (i > 0) {
+ System.out.print(", ");
+ }
+ System.out.print(array[i]);
+ }
+ System.out.print("]");
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/Rule.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/Rule.java
new file mode 100644
index 00000000000..a5add9a7032
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/Rule.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *********************************************************************************/
+
+package org.eclipse.cdt.core.dom.lrparser.lpgextensions;
+
+/**
+ * Provides information about a reduction rule that a parser has
+ * encountered.
+ */
+class Rule<RULE_DATA> {
+ private int ruleNumber;
+ private int startTokenOffset;
+ private int endTokenOffset;
+ private RULE_DATA data;
+
+ public Rule(int ruleNumber, int startTokenOffset, int endTokenOffset) {
+ this.ruleNumber = ruleNumber;
+ this.startTokenOffset = startTokenOffset;
+ this.endTokenOffset = endTokenOffset;
+ }
+
+ public int getRuleNumber() {
+ return ruleNumber;
+ }
+
+ public int getStartTokenOffset() {
+ return startTokenOffset;
+ }
+
+ public int getEndTokenOffset() {
+ return endTokenOffset;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(ruleNumber);
+ }
+
+ public RULE_DATA getData() {
+ return data;
+ }
+
+ public void setData(RULE_DATA data) {
+ this.data = data;
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/TrialUndoParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/TrialUndoParser.java
new file mode 100644
index 00000000000..eb27bb2c3a7
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/TrialUndoParser.java
@@ -0,0 +1,652 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.lpgextensions;
+
+import java.util.LinkedList;
+
+import lpg.lpgjavaruntime.BadParseException;
+import lpg.lpgjavaruntime.BadParseSymFileException;
+import lpg.lpgjavaruntime.ConfigurationElement;
+import lpg.lpgjavaruntime.ConfigurationStack;
+import lpg.lpgjavaruntime.Monitor;
+import lpg.lpgjavaruntime.NotBacktrackParseTableException;
+import lpg.lpgjavaruntime.ParseTable;
+import lpg.lpgjavaruntime.TokenStream;
+
+public class TrialUndoParser {
+ private Monitor monitor = null;
+ private int START_STATE, NUM_RULES, LA_STATE_OFFSET, EOFT_SYMBOL, ERROR_SYMBOL, ACCEPT_ACTION, ERROR_ACTION;
+
+ private TokenStream tokStream;
+ private ParseTable prs;
+ private ITrialUndoActionProvider actionProvider;
+ private boolean skipTokens = false; // true if error productions are used to
+ // skip tokens
+
+ private ParserState state;
+
+ /**
+ * Signals that a backtrack was requested by a trial action.
+ */
+ private boolean backtrackRequested;
+
+ //
+ // Override the getToken function in Stacks.
+ //
+ public final int getToken(int i) {
+ return state.tokens.get(state.parserLocationStack[state.stateStackTop + (i - 1)]);
+ }
+
+ public int getTokenOffset() {
+ return state.parserLocationStack[state.stateStackTop];
+ }
+
+ public final int getCurrentRule() {
+ return state.currentAction;
+ }
+
+ public final int getFirstToken() {
+ return tokStream.getFirstErrorToken(getToken(1));
+ }
+
+ public final int getFirstToken(int i) {
+ return tokStream.getFirstErrorToken(getToken(i));
+ }
+
+ public final int getLastToken() {
+ return tokStream.getLastErrorToken(state.lastToken);
+ }
+
+ public final int getLastToken(int i) {
+ int l = (i >= prs.rhs(state.currentAction) ? state.lastToken : state.tokens.get(state.locationStack[state.stateStackTop + i] - 1));
+ return tokStream.getLastErrorToken(l);
+ }
+
+ public TrialUndoParser(TokenStream tokStream, ParseTable prs, ITrialUndoActionProvider ra) throws BadParseSymFileException, NotBacktrackParseTableException {
+ this.tokStream = tokStream;
+ this.prs = prs;
+ this.actionProvider = ra;
+
+ START_STATE = prs.getStartState();
+ NUM_RULES = prs.getNumRules();
+ LA_STATE_OFFSET = prs.getLaStateOffset();
+ EOFT_SYMBOL = prs.getEoftSymbol();
+ ERROR_SYMBOL = prs.getErrorSymbol();
+ ACCEPT_ACTION = prs.getAcceptAction();
+ ERROR_ACTION = prs.getErrorAction();
+
+ if (!prs.isValidForParser())
+ throw new BadParseSymFileException();
+ if (!prs.getBacktrack())
+ throw new NotBacktrackParseTableException();
+ }
+
+ public TrialUndoParser(Monitor monitor, TokenStream tokStream, ParseTable prs, ITrialUndoActionProvider ra) throws BadParseSymFileException, NotBacktrackParseTableException {
+ this(tokStream, prs, ra);
+ this.monitor = monitor;
+ }
+
+ //
+ // Parse without attempting any Error token recovery
+ //
+ public Object parse() throws BadParseException {
+ // without an argument parse() will ignore error productions
+ return parse(0);
+ }
+
+ //
+ // Parse input allowing up to max_error_count Error token recoveries.
+ // When max_error_count is 0, no Error token recoveries occur.
+ // When max_error is > 0, it limits the number of Error token recoveries.
+ // When max_error is < 0, the number of error token recoveries is unlimited.
+ // Also, such recoveries only require one token to be parsed beyond the
+ // recovery point.
+ // (normally two tokens beyond the recovery point must be parsed)
+ // Thus, a negative max_error_count should be used when error productions
+ // are used to
+ // skip tokens.
+ //
+ public Object parse(int max_error_count) throws BadParseException {
+ state = new ParserState(START_STATE, tokStream);
+ skipTokens = max_error_count < 0;
+
+ state.pendingCommits = new LinkedList();
+ backtrackRequested = false;
+ state.trialActionCount = 0;
+
+ // Next "start" token
+ state.repair_token = 0;
+
+ int start_token_index = tokStream.peek();
+ int start_action_index = 0;
+
+ // Last commit point
+ int[] temp_stack = new int[1];
+ temp_stack[0] = START_STATE;
+
+ state.reallocateOtherStacks(start_token_index);
+
+ int initial_error_token = backtrackParse(state.repair_token);
+ for (int error_token = initial_error_token, count = 0; error_token != 0; error_token = backtrackParse(state.repair_token), count++) {
+ if (count == max_error_count)
+ throw new BadParseException(initial_error_token);
+ state.actionCount = start_action_index;
+ tokStream.reset(start_token_index);
+ state.stateStackTop = temp_stack.length - 1;
+ System.arraycopy(temp_stack, 0, state.stateStack, 0, temp_stack.length);
+ state.reallocateOtherStacks(start_token_index);
+
+ backtrackParseUpToError(state.repair_token, error_token);
+
+ for (state.stateStackTop = findRecoveryStateIndex(state.stateStackTop); state.stateStackTop >= 0; state.stateStackTop = findRecoveryStateIndex(state.stateStackTop - 1)) {
+ int recovery_token = state.tokens.get(state.locationStack[state.stateStackTop] - 1);
+ state.repair_token = errorRepair((recovery_token >= start_token_index ? recovery_token : error_token), error_token);
+ if (state.repair_token != 0)
+ break;
+ }
+
+ if (state.stateStackTop < 0)
+ throw new BadParseException(initial_error_token);
+
+ temp_stack = new int[state.stateStackTop + 1];
+ System.arraycopy(state.stateStack, 0, temp_stack, 0, temp_stack.length);
+
+ start_action_index = state.actionCount;
+ start_token_index = tokStream.peek();
+ }
+
+ if (state.repair_token != 0)
+ state.tokens.add(state.repair_token);
+ int t;
+ for (t = start_token_index; tokStream.getKind(t) != EOFT_SYMBOL; t = tokStream.getNext(t))
+ state.tokens.add(t);
+ state.tokens.add(t);
+
+ return null;
+ }
+
+ //
+ // Process reductions and continue...
+ //
+ private int process_backtrack_reductions(int act) {
+ do {
+ state.stateStackTop -= (prs.rhs(act) - 1);
+ trialAction(act);
+ if (backtrackRequested) {
+ backtrackRequested = false;
+ return ERROR_ACTION;
+ }
+ act = prs.ntAction(state.stateStack[state.stateStackTop], prs.lhs(act));
+ } while (act <= NUM_RULES);
+ return act;
+ }
+
+ //
+ // Process reductions and continue...
+ //
+ private int process_repair_reductions(int act) {
+ do {
+ System.out.println("process_repair_reductions: " + act);
+ state.stateStackTop -= (prs.rhs(act) - 1);
+ act = prs.ntAction(state.stateStack[state.stateStackTop], prs.lhs(act));
+ } while (act <= NUM_RULES);
+ return act;
+ }
+
+ //
+ // Parse the input until either the parse completes successfully or
+ // an error is encountered. This function returns an integer that
+ // represents the last action that was executed by the parser. If
+ // the parse was succesful, then the tuple "action" contains the
+ // successful sequence of actions that was executed.
+ //
+ private int backtrackParse(int initial_token) {
+ //
+ // Allocate configuration stack.
+ //
+ state.configurationStack = new ConfigurationStack(prs);
+ state.trialActionStack = new LinkedList<Integer>();
+ state.trialActionStack.add(Integer.valueOf(state.trialActionCount));
+
+ //
+ // Keep parsing until we successfully reach the end of file or
+ // an error is encountered. The list of actions executed will
+ // be stored in the "action" tuple.
+ //
+ int error_token = 0;
+ int maxStackTop = state.stateStackTop;
+ int start_token = tokStream.peek();
+ state.curtok = (initial_token > 0 ? initial_token : tokStream.getToken());
+ int current_kind = tokStream.getKind(state.curtok);
+ state.act = tAction(state.stateStack[state.stateStackTop], current_kind);
+
+ //
+ // The main driver loop
+ //
+ for (;;) {
+ //
+ // if the parser needs to stop processing,
+ // it may do so here.
+ //
+ if (monitor != null && monitor.isCancelled())
+ return 0;
+
+ state.parserLocationStack[state.stateStackTop] = state.curtok;
+
+ if (state.act <= NUM_RULES) {
+ state.actionCount++;
+ state.stateStackTop--;
+ state.act = process_backtrack_reductions(state.act);
+ } else if (state.act > ERROR_ACTION) {
+ state.actionCount++;
+ state.lastToken = state.curtok;
+ state.curtok = tokStream.getToken();
+ current_kind = tokStream.getKind(state.curtok);
+ state.act = process_backtrack_reductions(state.act - ERROR_ACTION);
+ } else if (state.act < ACCEPT_ACTION) {
+ state.actionCount++;
+ state.lastToken = state.curtok;
+ state.curtok = tokStream.getToken();
+ current_kind = tokStream.getKind(state.curtok);
+ }
+
+ if (state.act == ERROR_ACTION) {
+ error_token = (error_token > state.curtok ? error_token : state.curtok);
+
+ undoActions();
+ ConfigurationElement configuration = state.configurationStack.pop();
+ if (configuration == null)
+ state.act = ERROR_ACTION;
+ else {
+ state.actionCount = configuration.action_length;
+ state.act = configuration.act;
+ state.curtok = configuration.curtok;
+ current_kind = tokStream.getKind(state.curtok);
+ tokStream.reset(state.curtok == initial_token ? start_token : tokStream.getNext(state.curtok));
+ state.stateStackTop = configuration.stack_top;
+ configuration.retrieveStack(state.stateStack);
+ continue;
+ }
+ break;
+ }
+ if (state.act > ACCEPT_ACTION && state.act != ERROR_ACTION) {
+ if (state.configurationStack.findConfiguration(state.stateStack, state.stateStackTop, state.curtok))
+ state.act = ERROR_ACTION;
+ else {
+ state.configurationStack.push(state.stateStack, state.stateStackTop, state.act + 1, state.curtok, state.actionCount);
+ state.trialActionStack.add(Integer.valueOf(state.trialActionCount));
+ state.act = prs.baseAction(state.act);
+ maxStackTop = state.stateStackTop > maxStackTop ? state.stateStackTop : maxStackTop;
+ }
+ continue;
+ } else if (state.act == ACCEPT_ACTION) {
+ break;
+ }
+ try {
+ state.stateStack[++state.stateStackTop] = state.act;
+ } catch (IndexOutOfBoundsException e) {
+ state.reallocateStateStack();
+ state.stateStack[state.stateStackTop] = state.act;
+ }
+
+ state.act = tAction(state.act, current_kind);
+ }
+
+ // System.out.println("****Number of configurations: " +
+ // configuration_stack.configurationSize());
+ // System.out.println("****Number of elements in stack tree: " +
+ // configuration_stack.numStateElements());
+ // System.out.println("****Number of elements in stacks: " +
+ // configuration_stack.stacksSize());
+ // System.out.println("****Number of actions: " + action.size());
+ // System.out.println("****Max Stack Size = " + maxStackTop);
+ // System.out.flush();
+ return (state.act == ERROR_ACTION ? error_token : 0);
+ }
+
+ private void backtrackParseUpToError(int initial_token, int error_token) {
+ //
+ // Allocate configuration stack.
+ //
+ state.configurationStack = new ConfigurationStack(prs);
+ state.trialActionStack = new LinkedList<Integer>();
+ state.trialActionStack.add(Integer.valueOf(state.trialActionCount));
+
+ //
+ // Keep parsing until we successfully reach the end of file or
+ // an error is encountered. The list of actions executed will
+ // be stored in the "action" tuple.
+ //
+
+ // tokStream.reset(initial_token);
+ int start_token = tokStream.peek();
+ state.curtok = (initial_token > 0 ? initial_token : tokStream.getToken());
+ int current_kind = tokStream.getKind(state.curtok);
+ state.act = tAction(state.stateStack[state.stateStackTop], current_kind);
+
+ state.tokens.add(state.curtok);
+ state.locationStack[state.stateStackTop] = state.tokens.size();
+ state.actionStack[state.stateStackTop] = state.actionCount;
+ state.undoStack[state.stateStackTop] = state.trialActionCount;
+
+ for (;;) {
+ //
+ // if the parser needs to stop processing,
+ // it may do so here.
+ //
+ if (monitor != null && monitor.isCancelled())
+ return;
+
+ state.parserLocationStack[state.stateStackTop] = state.curtok;
+
+ if (state.act <= NUM_RULES) {
+ state.actionCount++;
+ state.stateStackTop--;
+ state.act = process_backtrack_reductions(state.act);
+ } else if (state.act > ERROR_ACTION) {
+ state.actionCount++;
+ state.lastToken = state.curtok;
+ state.curtok = tokStream.getToken();
+ current_kind = tokStream.getKind(state.curtok);
+ state.tokens.add(state.curtok);
+ state.act = process_backtrack_reductions(state.act - ERROR_ACTION);
+ } else if (state.act < ACCEPT_ACTION) {
+ state.actionCount++;
+ state.lastToken = state.curtok;
+ state.curtok = tokStream.getToken();
+ current_kind = tokStream.getKind(state.curtok);
+ state.tokens.add(state.curtok);
+ } else if (state.act == ERROR_ACTION) {
+ if (state.curtok != error_token) {
+ undoActions();
+ ConfigurationElement configuration = state.configurationStack.pop();
+ if (configuration == null)
+ state.act = ERROR_ACTION;
+ else {
+ state.actionCount = configuration.action_length;
+ state.act = configuration.act;
+ int next_token_index = configuration.curtok;
+ state.tokens.reset(next_token_index);
+ state.curtok = state.tokens.get(next_token_index - 1);
+ current_kind = tokStream.getKind(state.curtok);
+ tokStream.reset(state.curtok == initial_token ? start_token : tokStream.getNext(state.curtok));
+ state.stateStackTop = configuration.stack_top;
+ configuration.retrieveStack(state.stateStack);
+ state.locationStack[state.stateStackTop] = state.tokens.size();
+ state.actionStack[state.stateStackTop] = state.actionCount;
+ state.undoStack[state.stateStackTop] = state.trialActionCount;
+ continue;
+ }
+ }
+ break;
+ } else if (state.act > ACCEPT_ACTION) {
+ if (state.configurationStack.findConfiguration(state.stateStack, state.stateStackTop, state.tokens.size()))
+ state.act = ERROR_ACTION;
+ else {
+ state.configurationStack.push(state.stateStack, state.stateStackTop, state.act + 1, state.tokens.size(), state.actionCount);
+ state.trialActionStack.add(Integer.valueOf(state.trialActionCount));
+ state.act = prs.baseAction(state.act);
+ }
+ continue;
+ } else
+ break; // assert(act == ACCEPT_ACTION);
+
+ state.stateStack[++state.stateStackTop] = state.act; // no need
+ // to check
+ // if out of
+ // bounds
+ state.locationStack[state.stateStackTop] = state.tokens.size();
+ state.actionStack[state.stateStackTop] = state.actionCount;
+ state.undoStack[state.stateStackTop] = state.trialActionCount;
+ state.act = tAction(state.act, current_kind);
+ }
+
+ // assert(curtok == error_token);
+
+ return;
+ }
+
+ private boolean repairable(int error_token) {
+ //
+ // Allocate configuration stack.
+ //
+ ConfigurationStack configuration_stack = new ConfigurationStack(prs);
+
+ //
+ // Keep parsing until we successfully reach the end of file or
+ // an error is encountered. The list of actions executed will
+ // be stored in the "action" tuple.
+ //
+ int start_token = tokStream.peek();
+ int final_token = tokStream.getStreamLength(); // unreachable
+ int curtok = 0;
+ int current_kind = ERROR_SYMBOL;
+ int act = tAction(state.stateStack[state.stateStackTop], current_kind);
+
+ for (;;) {
+ if (act <= NUM_RULES) {
+ state.stateStackTop--;
+ act = process_repair_reductions(act);
+ } else if (act > ERROR_ACTION) {
+ curtok = tokStream.getToken();
+ if (curtok > final_token)
+ return true;
+ current_kind = tokStream.getKind(curtok);
+ act = process_repair_reductions(act - ERROR_ACTION);
+ } else if (act < ACCEPT_ACTION) {
+ curtok = tokStream.getToken();
+ if (curtok > final_token)
+ return true;
+ current_kind = tokStream.getKind(curtok);
+ } else if (act == ERROR_ACTION) {
+ ConfigurationElement configuration = configuration_stack.pop();
+ if (configuration == null)
+ act = ERROR_ACTION;
+ else {
+ state.stateStackTop = configuration.stack_top;
+ configuration.retrieveStack(state.stateStack);
+ act = configuration.act;
+ curtok = configuration.curtok;
+ if (curtok == 0) {
+ current_kind = ERROR_SYMBOL;
+ tokStream.reset(start_token);
+ } else {
+ current_kind = tokStream.getKind(curtok);
+ tokStream.reset(tokStream.getNext(curtok));
+ }
+ continue;
+ }
+ break;
+ } else if (act > ACCEPT_ACTION) {
+ if (configuration_stack.findConfiguration(state.stateStack, state.stateStackTop, curtok))
+ act = ERROR_ACTION;
+ else {
+ configuration_stack.push(state.stateStack, state.stateStackTop, act + 1, curtok, 0);
+ act = prs.baseAction(act);
+ }
+ continue;
+ } else
+ break; // assert(act == ACCEPT_ACTION);
+ try {
+ //
+ // We consider a configuration to be acceptable for recovery
+ // if we are able to consume enough symbols in the remaining
+ // tokens to reach another potential recovery point past the
+ // original error token.
+ //
+ if ((curtok > error_token) && (final_token == tokStream.getStreamLength())) {
+ //
+ // If the ERROR_SYMBOL is a valid Action Adjunct in the
+ // state
+ // "act" then we set the terminating token as the successor
+ // of
+ // the current token. I.e., we have to be able to parse at
+ // least
+ // two tokens past the re-synch point before we claim
+ // victory.
+ //
+ if (recoverableState(act))
+ final_token = skipTokens ? curtok : tokStream.getNext(curtok);
+ }
+
+ state.stateStack[++state.stateStackTop] = act;
+ } catch (IndexOutOfBoundsException e) {
+ state.reallocateStateStack();
+ state.stateStack[state.stateStackTop] = act;
+ }
+
+ act = tAction(act, current_kind);
+ }
+
+ //
+ // If we can reach the end of the input successfully, we claim victory.
+ //
+ return (act == ACCEPT_ACTION);
+ }
+
+ private boolean recoverableState(int state) {
+ for (int k = prs.asi(state); prs.asr(k) != 0; k++) {
+ if (prs.asr(k) == ERROR_SYMBOL)
+ return true;
+ }
+ return false;
+ }
+
+ private int findRecoveryStateIndex(int start_index) {
+ int i;
+ for (i = start_index; i >= 0; i--) {
+ //
+ // If the ERROR_SYMBOL is an Action Adjunct in state stateStack[i]
+ // then chose i as the index of the state to recover on.
+ //
+ if (recoverableState(state.stateStack[i]))
+ break;
+ }
+
+ if (i >= 0) // if a recoverable state, remove null reductions, if any.
+ {
+ int k;
+ for (k = i - 1; k >= 0; k--) {
+ if (state.locationStack[k] != state.locationStack[i])
+ break;
+ }
+ i = k + 1;
+ }
+
+ return i;
+ }
+
+ private int errorRepair(int recovery_token, int error_token) {
+ int temp_stack[] = new int[state.stateStackTop + 1];
+ System.arraycopy(state.stateStack, 0, temp_stack, 0, temp_stack.length);
+ for (; tokStream.getKind(recovery_token) != EOFT_SYMBOL; recovery_token = tokStream.getNext(recovery_token)) {
+ System.out.println("recovery token: " + tokStream.getKind(recovery_token)); //$NON-NLS-1$
+ tokStream.reset(recovery_token);
+ if (repairable(error_token))
+ break;
+ state.stateStackTop = temp_stack.length - 1;
+ System.arraycopy(temp_stack, 0, state.stateStack, 0, temp_stack.length);
+ }
+
+ if (tokStream.getKind(recovery_token) == EOFT_SYMBOL) {
+ tokStream.reset(recovery_token);
+ if (!repairable(error_token)) {
+ state.stateStackTop = temp_stack.length - 1;
+ System.arraycopy(temp_stack, 0, state.stateStack, 0, temp_stack.length);
+ return 0;
+ }
+ }
+
+ state.stateStackTop = temp_stack.length - 1;
+ System.arraycopy(temp_stack, 0, state.stateStack, 0, temp_stack.length);
+
+ undoActions(state.undoStack[state.stateStackTop]);
+ tokStream.reset(recovery_token);
+ state.tokens.reset(state.locationStack[state.stateStackTop] - 1);
+ state.actionCount = state.actionStack[state.stateStackTop];
+ state.trialActionCount = state.undoStack[state.stateStackTop];
+
+ return tokStream.makeErrorToken(state.tokens.get(state.locationStack[state.stateStackTop] - 1), tokStream.getPrevious(recovery_token), error_token, ERROR_SYMBOL);
+ }
+
+ private int tAction(int act, int sym) {
+ act = prs.tAction(act, sym);
+ if (act > LA_STATE_OFFSET) {
+ int next_token = tokStream.peek();
+ act = prs.lookAhead(act - LA_STATE_OFFSET, tokStream.getKind(next_token));
+ while (act > LA_STATE_OFFSET) {
+ next_token = tokStream.getNext(next_token);
+ act = prs.lookAhead(act - LA_STATE_OFFSET, tokStream.getKind(next_token));
+ }
+ }
+ return act;
+ }
+
+ private void trialAction(int action) {
+ int start = getTokenOffset();
+ int end = getLastToken();
+ Rule rule = new Rule(action, start, end);
+
+ actionProvider.setActiveRule(rule);
+ boolean saveAction = actionProvider.trialAction(action);
+ if (backtrackRequested) {
+ return;
+ }
+ if (saveAction) {
+ state.trialActionCount++;
+ state.pendingCommits.add(rule);
+ }
+ }
+
+ /**
+ * Performs the undo actions (in reverse order) for the corresponding trial
+ * actions that have been executed since the last backtrackable point.
+ */
+ private void undoActions() {
+ int oldTrialActionCount;
+ if (state.trialActionStack.size() == 0) {
+ oldTrialActionCount = 0;
+ } else {
+ oldTrialActionCount = state.trialActionStack.removeLast();
+ }
+ safeUndoActions(oldTrialActionCount);
+
+ // needs to be a real checked exception if we ever decide to implement commits
+ //assert (state.trialActionCount == 0 && oldTrialActionCount == 0) || oldTrialActionCount != state.trialActionCount : "Went back in time too far";
+ }
+
+ private void safeUndoActions(int total) {
+ assert total >= 0 : "Tried to go back in time but the door was already shut."; //$NON-NLS-1$
+ undoActions(total);
+ }
+
+ private void undoActions(int total) {
+ while (state.trialActionCount > total) {
+ Rule action = ((Rule) state.pendingCommits.removeLast());
+ actionProvider.setActiveRule(action);
+ actionProvider.undoAction(action.getRuleNumber());
+ state.trialActionCount--;
+ }
+ }
+
+ public void backtrack() {
+ backtrackRequested = true;
+ }
+
+ public void commit() {
+ while (state.pendingCommits.size() > 0) {
+ Rule activeRule = (Rule) state.pendingCommits.removeFirst();
+ actionProvider.setActiveRule(activeRule);
+ actionProvider.finalAction(activeRule.getRuleNumber());
+ state.totalCommits++;
+ }
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/TrialUndoParserTemplate.g b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/TrialUndoParserTemplate.g
new file mode 100644
index 00000000000..d2a22e37ba4
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/lpgextensions/TrialUndoParserTemplate.g
@@ -0,0 +1,303 @@
+--------------------------------------------------------------------------------
+-- Copyright (c) 2006, 2007 IBM Corporation and others.
+-- All rights reserved. This program and the accompanying materials
+-- are made available under the terms of the Eclipse Public License v1.0
+-- which accompanies this distribution, and is available at
+-- http://www.eclipse.org/legal/epl-v10.html
+--
+-- Contributors:
+-- IBM Corporation - initial API and implementation
+--------------------------------------------------------------------------------
+
+--
+-- In a parser using this template, the following macro may be redefined:
+--
+-- $additional_interfaces
+-- $ast_class
+--
+-- B E G I N N I N G O F T E M P L A T E TrialUndoParserTemplate
+--
+%Options programming_language=java,margin=8,backtrack
+%Options table,error_maps,scopes
+%options prefix=TK_,
+%options action=("*.java", "/.", "./")
+%options headers=("*.java", "/:", ":/")
+%options ParseTable=lpg.lpgjavaruntime.ParseTable
+
+--
+-- This template requires that the name of the EOF token be set
+-- to EOF_TOKEN to be consistent with LexerTemplateD and LexerTemplateE
+--
+$EOF
+ EOF_TOKEN
+$End
+
+$ERROR
+ ERROR_TOKEN
+$End
+
+$Define
+ $DefaultAllocation
+ /:
+ RULE_ACTIONS[$rule_number] = new Action$rule_number$();:/
+
+ $NoAllocation
+ /:
+ RULE_ACTIONS[$rule_number] = EMPTY_ACTION:/
+
+ $NullAllocation
+ /:
+ RULE_ACTIONS[$rule_number] = new NullAction();:/
+
+ $BadAllocation
+ /:
+ RULE_ACTIONS[$rule_number] = new BadAction();:/
+
+ $Header
+ /.
+ //
+ // Rule $rule_number: $rule_text
+ //./
+
+ $DefaultAction
+ /.$DefaultAllocation $Header
+ static final class Action$rule_number extends Action./
+
+ --
+ -- This macro is used to initialize the ruleAction array
+ -- to the null_action function.
+ --
+ $NullAction
+ /. $NullAllocation $Header
+ //
+ // final class NullAction extends Action
+ //
+ ./
+
+ --
+ -- This macro is used to initialize the ruleAction array
+ -- to the no_action function.
+ --
+ $NoAction
+ /. $NoAllocation $Header
+ //
+ // final class NullAction extends Action
+ //
+ ./
+
+ --
+ -- This macro is used to initialize the ruleAction array
+ -- to the bad_action function.
+ --
+ $BadAction
+ /. $BadAllocation $Header
+ //
+ // final class NullAction extends Action
+ //
+ ./
+
+ --
+ -- This is the header for a ruleAction class
+ --
+ $BeginAction
+ /.$DefaultAllocation $Header
+ static final class Action$rule_number extends DeclaredAction<$action_class, $data_class> {
+ ./
+
+ $EndAction
+ /.
+ }./
+
+ $BeginTrial
+ /.
+ public boolean doTrial(ITrialUndoActionProvider<$data_class> provider, $action_class action) {./
+
+ $EndTrial
+ /.
+ return hasUndo;
+ }./
+
+ $BeginUndo
+ /.
+ public Action$rule_number() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider<$data_class> provider, $action_class action) {./
+
+ $EndUndo
+ /.
+ }./
+
+ $BeginFinal
+ /.
+ public void doFinal(ITrialUndoActionProvider<$data_class> provider, $action_class action) {./
+
+ $EndFinal
+ /.
+ }./
+
+ $BeginJava
+ /.$BeginAction
+ $symbol_declarations./
+
+ $EndJava /.$EndAction./
+
+ $SplitActions /../
+
+ --
+ -- Macros that may be needed in a parser using this template
+ --
+ $additional_interfaces /../
+ $ast_class /.$ast_type./
+ $action_class /.Object./
+
+ $Trial /.$BeginTrial./
+ $Undo /.$BeginUndo./
+ $Final /.$BeginFinal./
+ $Action /.$BeginAction./
+
+$End
+
+$Globals
+ /.
+import lpg.lpgjavaruntime.*;
+import org.eclipse.cdt.core.dom.lrparser.lpgextensions.ITrialUndoActionProvider;
+import org.eclipse.cdt.core.dom.lrparser.lpgextensions.AbstractTrialUndoActionProvider;
+import org.eclipse.cdt.core.dom.lrparser.lpgextensions.TrialUndoParser;
+./
+$End
+
+$Headers
+ /.
+public class $action_type extends AbstractTrialUndoActionProvider<$action_class, $data_class> implements IParserActionTokenProvider, IParser $additional_interfaces {
+ private static ParseTable prs = new $prs_type();
+ protected static final Action<$action_class, $data_class>[] RULE_ACTIONS;
+
+ {
+ ruleAction = RULE_ACTIONS;
+ }
+
+ public $action_type(LexStream lexStream) {
+ super(lexStream);
+
+ try {
+ super.remapTerminalSymbols(orderedTerminalSymbols(), $prs_type.EOFT_SYMBOL);
+ } catch (NullExportedSymbolsException e) {
+ } catch (NullTerminalSymbolsException e) {
+ } catch (UnimplementedTerminalsException e) {
+ java.util.ArrayList unimplemented_symbols = e.getSymbols();
+ System.out.println("The Lexer will not scan the following token(s):");
+ for (int i = 0; i < unimplemented_symbols.size(); i++) {
+ Integer id = (Integer) unimplemented_symbols.get(i);
+ System.out.println(" " + $sym_type.orderedTerminalSymbols[id.intValue()]);
+ }
+ System.out.println();
+ } catch (UndefinedEofSymbolException e) {
+ throw new Error(new UndefinedEofSymbolException("The Lexer does not implement the Eof symbol " + $sym_type.orderedTerminalSymbols[$prs_type.EOFT_SYMBOL]));
+ }
+ }
+
+
+ public $action_type() { // constructor
+ // this(new $lexer_class());
+ }
+
+ public String[] orderedTerminalSymbols() {
+ return $sym_type.orderedTerminalSymbols;
+ }
+
+ public String getTokenKindName(int kind) {
+ return $sym_type.orderedTerminalSymbols[kind];
+ }
+
+ public int getEOFTokenKind() {
+ return $prs_type.EOFT_SYMBOL;
+ }
+
+ public PrsStream getParseStream() {
+ return (PrsStream) this;
+ }
+
+ //
+ // Report error message for given error_token.
+ //
+ public final void reportErrorTokenMessage(int error_token, String msg) {
+ int firsttok = super.getFirstRealToken(error_token), lasttok = super.getLastRealToken(error_token);
+ String location = super.getFileName() + ':' +
+ (firsttok > lasttok
+ ? (super.getEndLine(lasttok) + ":" + super.getEndColumn(lasttok))
+ : (super.getLine(error_token) + ":" +
+ super.getColumn(error_token) + ":" +
+ super.getEndLine(error_token) + ":" +
+ super.getEndColumn(error_token))) + ": ";
+ super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
+ }
+
+ public $ast_class parser() {
+ return parser(null, 0);
+ }
+
+ public $ast_class parser(Monitor monitor) {
+ return parser(monitor, 0);
+ }
+
+ public $ast_class parser(int error_repair_count) {
+ return parser(null, error_repair_count);
+ }
+
+ public $ast_class parser(Monitor monitor, int error_repair_count) {
+ try {
+ btParser = new TrialUndoParser((TokenStream) this, prs, (ITrialUndoActionProvider<$data_class>) this);
+ } catch (NotBacktrackParseTableException e) {
+ throw new Error(new NotBacktrackParseTableException("Regenerate $prs_type.java with -BACKTRACK option"));
+ } catch (BadParseSymFileException e) {
+ throw new Error(new BadParseSymFileException("Bad Parser Symbol File -- $sym_type.java"));
+ }
+
+ try {
+ Object result = (Object) btParser.parse(error_repair_count);
+ btParser.commit();
+ return result;
+ } catch (BadParseException e) {
+ reset(e.error_token); // point to error token
+
+ //DiagnoseParser diagnoseParser = new DiagnoseParser((TokenStream) this, prs);
+ //diagnoseParser.diagnose(e.error_token);
+ }
+
+ return null;
+ }
+
+ ./
+
+ /:
+
+ //
+ // Initialize ruleAction array.
+ //
+ static {
+ RULE_ACTIONS = new Action[$NUM_RULES + 1];
+ RULE_ACTIONS[0] = null;
+ :/
+$End
+
+$Trailers
+ /.
+ }
+ ./
+
+ /:
+
+
+ //
+ // Make sure that all elements of ruleAction are properly initialized
+ //
+ for (int i = 0; i < RULE_ACTIONS.length; i++) {
+ if (RULE_ACTIONS[i] == null) {
+ RULE_ACTIONS[i] = emptyAction();
+ }
+ }
+ }
+ :/
+$End
+--
+-- E N D O F T E M P L A T E
+--
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/ASTPrinter.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/ASTPrinter.java
new file mode 100644
index 00000000000..ff186ff5f4c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/ASTPrinter.java
@@ -0,0 +1,472 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.util;
+
+import java.io.PrintStream;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
+import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
+import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
+import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
+import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
+import org.eclipse.cdt.core.dom.ast.c.ICPointerType;
+import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+
+
+/**
+ * A utility that prints an AST to the console, useful for debugging purposes.
+ *
+ * @author Mike Kucera
+ */
+@SuppressWarnings("restriction")
+class ASTPrinter {
+
+ /**
+ * Prints the AST to the given PrintStream.
+ */
+ public static void printAST(IASTTranslationUnit root, PrintStream stream) {
+ PrintStream out = stream == null ? System.out : stream;
+ if(root == null) {
+ out.println("null"); //$NON-NLS-1$
+ return;
+ }
+
+ PrintVisitor visitor = new PrintVisitor(out);
+
+ IASTPreprocessorStatement[] preStats = root.getAllPreprocessorStatements();
+ if(preStats != null) {
+ for(int i = 0; i < preStats.length; i++) {
+ print(out, 0, preStats[i]);
+ }
+ }
+
+ root.accept(visitor);
+
+ IASTProblem[] problems = root.getPreprocessorProblems();
+ if(problems != null) {
+ for(int i = 0; i < problems.length; i++) {
+ print(out, 0, problems[i]);
+ }
+ }
+
+ IASTComment[] comments = root.getComments();
+ if(comments != null) {
+ for(int i = 0; i < comments.length; i++) {
+ print(out, 0, comments[i]);
+ }
+ }
+ }
+
+
+
+ /**
+ * Prints the AST to stdout.
+ */
+ public static void printAST(IASTTranslationUnit root) {
+ printAST(root, null);
+ }
+
+
+ public static void printProblems(IASTTranslationUnit root, PrintStream stream) {
+ PrintStream out = stream == null ? System.out : stream;
+ if(root == null) {
+ out.println("null");//$NON-NLS-1$
+ return;
+ }
+
+ ProblemVisitor visitor = new ProblemVisitor(out);
+ root.accept(visitor);
+
+ IASTProblem[] problems = root.getPreprocessorProblems();
+ if(problems != null) {
+ for(int i = 0; i < problems.length; i++) {
+ print(out, 0, problems[i]);
+ }
+ }
+ }
+
+ public static void printProblems(IASTTranslationUnit root) {
+ printProblems(root, System.out);
+ }
+
+
+ private static void print(PrintStream out, int indentLevel, Object n) {
+ for(int i = 0; i < indentLevel; i++)
+ out.print(" "); //$NON-NLS-1$
+
+ if(n == null) {
+ out.println("NULL"); //$NON-NLS-1$
+ return;
+ }
+
+ String classname = n.getClass().getName();
+ out.print(classname);
+
+ if(n instanceof ASTNode) {
+ ASTNode node = (ASTNode) n;
+ out.print(" (" + node.getOffset() + "," + node.getLength() + ") "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if(node.getParent() == null && !(node instanceof IASTTranslationUnit)) {
+ out.print("PARENT IS NULL ");//$NON-NLS-1$
+ }
+ //out.print(node.getPropertyInParent());
+ }
+
+ if(n instanceof ICArrayType) {
+ ICArrayType at = (ICArrayType)n;
+ try {
+ if(at.isRestrict()) {
+ out.print(" restrict"); //$NON-NLS-1$
+ }
+ } catch (DOMException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if(n instanceof IASTName) {
+ out.print(" " + ((IASTName)n).toString()); //$NON-NLS-1$
+ }
+ else if(n instanceof ICASTPointer) {
+ ICASTPointer pointer = (ICASTPointer) n;
+ if(pointer.isConst())
+ out.print(" const"); //$NON-NLS-1$
+ if(pointer.isVolatile())
+ out.print(" volatile"); //$NON-NLS-1$
+ if(pointer.isRestrict())
+ out.print(" restrict");//$NON-NLS-1$
+ }
+ else if(n instanceof ICPointerType) {
+ ICPointerType pointer = (ICPointerType)n;
+ try {
+ if(pointer.isConst())
+ out.print(" const"); //$NON-NLS-1$
+ if(pointer.isVolatile())
+ out.print(" volatile"); //$NON-NLS-1$
+ if(pointer.isRestrict())
+ out.print(" restrict");//$NON-NLS-1$
+ } catch (DOMException e) {
+ e.printStackTrace();
+ }
+ out.println();
+ try {
+ print(out, indentLevel, ((ITypeContainer)n).getType());
+ } catch(Exception e) {}
+ }
+ else if(n instanceof ICASTArrayModifier) {
+ if(((ICASTArrayModifier)n).isRestrict()) {
+ out.print(" restrict"); //$NON-NLS-1$
+ }
+ }
+ else if(n instanceof IASTComment) {
+ out.print("'" + new String(((IASTComment)n).getComment()) + "'");
+ }
+// else if(n instanceof ICompositeType) {
+// try {
+// IField[] fields = ((ICompositeType)n).getFields();
+// if(fields == null || fields.length == 0) {
+// out.print(" no fields");
+// }
+// for(IField field : fields) {
+// out.println();
+// print(out, indentLevel + 1, field);
+// }
+// } catch (DOMException e) {
+// e.printStackTrace();
+// }
+// }
+ else if(n instanceof ITypeContainer) {
+ out.println();
+ try {
+ print(out, indentLevel, ((ITypeContainer)n).getType());
+ } catch(Exception e) {}
+ }
+ else if(n instanceof IVariable) {
+ IVariable var = (IVariable) n;
+ IType t;
+ try {
+ t = var.getType();
+ out.println();
+ print(out, indentLevel, t);
+ } catch (DOMException e) {
+ //e.printStackTrace();
+ }
+
+ }
+
+
+ out.println();
+ }
+
+
+ private static class ProblemVisitor extends CASTVisitor {
+ private PrintStream out;
+
+ ProblemVisitor(PrintStream out) {
+ this.out = out;
+ shouldVisitProblems = true;
+ shouldVisitDeclarations = true;
+ shouldVisitStatements = true;
+ shouldVisitExpressions = true;
+ }
+
+ public int visit(IASTProblem problem) {
+ print(out, 1, problem);
+ return PROCESS_CONTINUE;
+ }
+
+ public int visit(IASTDeclaration declaration) {
+ if(declaration instanceof IASTProblemDeclaration)
+ print(out, 0, declaration);
+ return PROCESS_CONTINUE;
+ }
+
+ public int visit(IASTExpression expression) {
+ if(expression instanceof IASTProblemExpression)
+ print(out, 0, expression);
+ return PROCESS_CONTINUE;
+ }
+
+ public int visit(IASTStatement statement) {
+ if(statement instanceof IASTProblemStatement)
+ print(out, 0, statement);
+ return PROCESS_CONTINUE;
+ }
+ }
+
+
+ private static class PrintVisitor extends CASTVisitor {
+
+
+ private PrintStream out;
+ private int indentLevel = 0;
+
+ PrintVisitor(PrintStream out) {
+ this.out = out;
+ shouldVisitDesignators = true;
+ shouldVisitNames = true;
+ shouldVisitDeclarations = true;
+ shouldVisitInitializers = true;
+ shouldVisitParameterDeclarations = true;
+ shouldVisitDeclarators = true;
+ shouldVisitDeclSpecifiers = true;
+ shouldVisitExpressions = true;
+ shouldVisitStatements = true;
+ shouldVisitTypeIds = true;
+ shouldVisitEnumerators = true;
+ shouldVisitTranslationUnit = true;
+ shouldVisitProblems = true;
+ }
+
+ private void print(IASTNode node) {
+ ASTPrinter.print(out, indentLevel, node);
+ }
+
+ private void print(IBinding binding) {
+ ASTPrinter.print(out, indentLevel, binding);
+ }
+
+
+ public int visit(IASTComment comment) {
+ print(comment);
+ indentLevel++;
+ return super.visit(comment);
+ }
+
+ public int visit(ICASTDesignator designator) {
+ print(designator);
+ indentLevel++;
+ return super.visit(designator);
+ }
+
+ public int visit(IASTDeclaration declaration) {
+ print(declaration);
+ indentLevel++;
+ return super.visit(declaration);
+ }
+
+ public int visit(IASTDeclarator declarator) {
+ print(declarator);
+ indentLevel++;
+ IASTPointerOperator[] pointers = declarator.getPointerOperators();
+ for(int i = 0; i < pointers.length; i++) {
+ print(pointers[i]);
+ }
+ if(declarator instanceof IASTArrayDeclarator) {
+ IASTArrayDeclarator decl = (IASTArrayDeclarator)declarator;
+ org.eclipse.cdt.core.dom.ast.IASTArrayModifier[] modifiers = decl.getArrayModifiers();
+ for(int i = 0; i < modifiers.length; i++) {
+ print((IASTNode)modifiers[i]);
+ }
+ }
+ return super.visit(declarator);
+ }
+
+ public int visit(IASTDeclSpecifier declSpec) {
+ print(declSpec);
+ indentLevel++;
+ return super.visit(declSpec);
+ }
+
+ public int visit(IASTEnumerator enumerator) {
+ print(enumerator);
+ indentLevel++;
+ return super.visit(enumerator);
+ }
+
+ public int visit(IASTExpression expression) {
+ print(expression);
+ indentLevel++;
+ return super.visit(expression);
+ }
+
+ public int visit(IASTInitializer initializer) {
+ print(initializer);
+ indentLevel++;
+ return super.visit(initializer);
+ }
+
+ public int visit(IASTName name) {
+ print(name);
+ IBinding binding = name.resolveBinding();
+ print(binding);
+ indentLevel++;
+ return super.visit(name);
+ }
+
+ public int visit(IASTParameterDeclaration parameterDeclaration) {
+ print(parameterDeclaration);
+ indentLevel++;
+ return super.visit(parameterDeclaration);
+ }
+
+ public int visit(IASTProblem problem) {
+ print(problem);
+ indentLevel++;
+ return super.visit(problem);
+ }
+
+ public int visit(IASTStatement statement) {
+ print(statement);
+ indentLevel++;
+ return super.visit(statement);
+ }
+
+ public int visit(IASTTranslationUnit tu) {
+ print(tu);
+ indentLevel++;
+ return super.visit(tu);
+ }
+
+ public int visit(IASTTypeId typeId) {
+ print(typeId);
+ indentLevel++;
+ return super.visit(typeId);
+ }
+
+ public int leave(IASTComment comment) {
+ indentLevel--;
+ return super.leave(comment);
+ }
+
+ public int leave(ICASTDesignator designator) {
+ indentLevel--;
+ return super.leave(designator);
+ }
+
+ public int leave(IASTDeclaration declaration) {
+ indentLevel--;
+ return super.leave(declaration);
+ }
+
+ public int leave(IASTDeclarator declarator) {
+ indentLevel--;
+ return super.leave(declarator);
+ }
+
+ public int leave(IASTDeclSpecifier declSpec) {
+ indentLevel--;
+ return super.leave(declSpec);
+ }
+
+ public int leave(IASTEnumerator enumerator) {
+ indentLevel--;
+ return super.leave(enumerator);
+ }
+
+ public int leave(IASTExpression expression) {
+ indentLevel--;
+ return super.leave(expression);
+ }
+
+ public int leave(IASTInitializer initializer) {
+ indentLevel--;
+ return super.leave(initializer);
+ }
+
+ public int leave(IASTName name) {
+ indentLevel--;
+ return super.leave(name);
+ }
+
+ public int leave(IASTParameterDeclaration parameterDeclaration) {
+ indentLevel--;
+ return super.leave(parameterDeclaration);
+ }
+
+ public int leave(IASTProblem problem) {
+ indentLevel--;
+ return super.leave(problem);
+ }
+
+ public int leave(IASTStatement statement) {
+ indentLevel--;
+ return super.leave(statement);
+ }
+
+ public int leave(IASTTranslationUnit tu) {
+ indentLevel--;
+ return super.leave(tu);
+ }
+
+ public int leave(IASTTypeId typeId) {
+ indentLevel--;
+ return super.leave(typeId);
+ }
+
+ };
+
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/BindingCheckVisitor.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/BindingCheckVisitor.java
new file mode 100644
index 00000000000..b744c653bbd
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/BindingCheckVisitor.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.util;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
+
+
+/**
+ * An AST visitor that asserts that all bindings have been resolved.
+ *
+ * @author Mike Kucera
+ */
+class BindingCheckVisitor extends CASTVisitor {
+
+ public static ASTVisitor VISITOR = new BindingCheckVisitor();
+
+ private BindingCheckVisitor() {
+ shouldVisitNames = true;
+ shouldVisitDeclarations = true;
+ shouldVisitInitializers = true;
+ shouldVisitParameterDeclarations = true;
+ shouldVisitDeclarators = true;
+ shouldVisitDeclSpecifiers = true;
+ shouldVisitExpressions = true;
+ shouldVisitStatements = true;
+ shouldVisitTypeIds = true;
+ shouldVisitEnumerators = true;
+ shouldVisitTranslationUnit = true;
+ shouldVisitProblems = false;
+ shouldVisitComments = false;
+ shouldVisitDesignators = true;
+ }
+
+ public int visit(IASTName name) {
+ if(name.getBinding() == null)
+ throw new AssertionError("Binding did not get pre-resolved: '" + name + "'");
+ return PROCESS_CONTINUE;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/CollectionUtils.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/CollectionUtils.java
new file mode 100644
index 00000000000..9f748f6084b
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/CollectionUtils.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.util;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import lpg.lpgjavaruntime.IToken;
+
+
+/**
+ * Useful utility methods for dealing with Collections.
+ *
+ * @author Mike Kucera
+ */
+public final class CollectionUtils {
+
+ private CollectionUtils() {
+ // this class has just static utility methods
+ }
+
+
+ /**
+ * Returns an iterator that iterates backwards over the given list.
+ * The remove() method is not implemented and will throw UnsupportedOperationException.
+ * @throws NullPointerException if list is null
+ */
+ public static <T> Iterator<T> reverseIterator(final List<T> list) {
+ return new Iterator<T>() {
+ ListIterator<T> iterator = list.listIterator(list.size());
+
+ public boolean hasNext() {
+ return iterator.hasPrevious();
+ }
+ public T next() {
+ return iterator.previous();
+ }
+ public void remove() {
+ throw new UnsupportedOperationException("remove() not supported"); //$NON-NLS-1$
+ }
+ };
+ }
+
+
+ /**
+ * Allows a foreach loop to iterate backwards over a list
+ * from the end to the start.
+ * @throws NullPointerException if list is null
+ */
+ public static <T> Iterable<T> reverseIterable(final List<T> list) {
+ return iterable(reverseIterator(list));
+ }
+
+
+ /**
+ * Creates an Iterable instance that just returns
+ * the given Iterator from its iterator() method.
+ *
+ * This is useful for using an iterator in a foreach loop directly.
+ *
+ * ex)
+ *
+ * foreach(Object o : iterable(list.listIterator())) {
+ * // do something
+ * }
+ *
+ * @throws NullPointerException if list is null
+ */
+ public static <T> Iterable<T> iterable(final Iterator<T> iter) {
+ if(iter == null)
+ throw new NullPointerException("iter parameter is null"); //$NON-NLS-1$
+
+ return new Iterable<T>() {
+ public Iterator<T> iterator() {
+ return iter;
+ }
+ };
+ }
+
+
+ /**
+ * Allows simple pattern match testing of lists of tokens.
+ *
+ * @throws NullPointerException if source or pattern is null
+ */
+ public static boolean matchTokens(List<IToken> source, Integer ... pattern) {
+ if(source.size() != pattern.length) // throws NPE if either param is null
+ return false;
+
+ for(int i = 0, n = pattern.length; i < n; i++) {
+ if(source.get(i).getKind() != pattern[i].intValue())
+ return false;
+ }
+ return true;
+ }
+
+
+ /**
+ * Finds the first object in the heterogeneous list that is an instance of
+ * the given class, removes it from the list, and returns it.
+ *
+ * @throws NullPointerException if list or clazz is null
+ * @throws UnsupportedOperationException if the list's Iterator does not support the remove() method
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T findFirstAndRemove(List<Object> list, Class<T> clazz) {
+ // There's a name somewhere on the stack, find it
+ for(Iterator<Object> iter = list.iterator(); iter.hasNext();) {
+ Object o = iter.next();
+ if(clazz.isInstance(o)) {
+ iter.remove();
+ return (T) o;
+ }
+ }
+ return null;
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/DebugUtil.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/DebugUtil.java
new file mode 100644
index 00000000000..773d4ba59bf
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/util/DebugUtil.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.lrparser.util;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+/**
+ * This class contains several convenience methods
+ * mainly for debugging purposes.
+ *
+ * @author Mike Kucera
+ *
+ */
+public class DebugUtil {
+
+ private DebugUtil() { // class just contains static methods
+ }
+
+
+ /**
+ * Prints a trace message to stdout that gives info
+ * about the method that calls this method.
+ */
+ public static void printMethodTrace() {
+ StackTraceElement[] trace = Thread.currentThread().getStackTrace();
+ printMethodTrace(trace, null);
+ }
+
+ /**
+ * Prints a trace message to stdout that gives info
+ * about the method that calls this method.
+ */
+ public static void printMethodTrace(String extraMessage) {
+ StackTraceElement[] trace = Thread.currentThread().getStackTrace();
+ printMethodTrace(trace, extraMessage);
+ }
+
+ private static void printMethodTrace(StackTraceElement[] trace, String extraMessage) {
+ StackTraceElement caller = trace[3];
+
+ String className = caller.getClassName();
+ className = className.substring(className.lastIndexOf(".") + 1);//$NON-NLS-1$
+
+ String message = String.format("%s.%s(%s:%d)", //$NON-NLS-1$
+ className, caller.getMethodName(), caller.getFileName(), caller.getLineNumber());
+
+ if(extraMessage != null)
+ message += ": " + extraMessage;//$NON-NLS-1$
+
+ System.out.println(message);
+ }
+
+
+ /**
+ * Prints a textual representation of the AST to stdout.
+ */
+ public static void printAST(IASTTranslationUnit tu) {
+ ASTPrinter.printAST(tu);
+ }
+
+ /**
+ * Throws an AssertionError if any of the bindings in
+ * the given AST cannot be resolved.
+ */
+ public static void assertBindings(IASTTranslationUnit tu) throws AssertionError {
+ tu.accept(BindingCheckVisitor.VISITOR);
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99OldParser.g b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99OldParser.g
new file mode 100644
index 00000000000..855397df32d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99OldParser.g
@@ -0,0 +1,1056 @@
+-----------------------------------------------------------------------------------
+-- Copyright (c) 2006, 2007 IBM Corporation and others.
+-- All rights reserved. This program and the accompanying materials
+-- are made available under the terms of the Eclipse Public License v1.0
+-- which accompanies this distribution, and is available at
+-- http://www.eclipse.org/legal/epl-v10.html
+--
+-- Contributors:
+-- IBM Corporation - initial API and implementation
+-----------------------------------------------------------------------------------
+
+%options la=2
+%options package=org.eclipse.cdt.internal.core.dom.parser.c99
+%options template=btParserTemplateD.g
+%options import_terminals=C99Lexer.g
+
+-----------------------------------------------------------------------------------
+--
+-- This is the old parser from before the trial/undo parsing strategy was
+-- adopted.
+--
+-- This parser is deprecated.
+--
+-----------------------------------------------------------------------------------
+
+$Notice
+/./*******************************************************************************
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *********************************************************************************/
+
+ // This file was generated by LPG
+./
+$End
+
+$Terminals
+
+ -- Most terminals are defined in the lexer and imported from there.
+ -- This section lists terminals that are not defined in the lexer such as keywords.
+
+
+ -- The scanner does not recognize keywords, it will return them as identifier tokens.
+ -- An IKeywordMap is used to convert these identifiers to keyword tokens.
+
+ auto break case char
+ const continue default do
+ double else enum extern
+ float for goto if
+ inline int long register
+ restrict return short signed
+ sizeof static struct switch
+ typedef union unsigned void
+ volatile while
+ _Bool _Complex _Imaginary
+
+
+ -- These are aliases for lexer tokens.
+
+
+ LeftBracket ::= '['
+ LeftParen ::= '('
+ LeftBrace ::= '{'
+ Dot ::= '.'
+ Arrow ::= '->'
+ PlusPlus ::= '++'
+ MinusMinus ::= '--'
+ And ::= '&'
+ Star ::= '*'
+ Plus ::= '+'
+ Minus ::= '-'
+ Tilde ::= '~'
+ Bang ::= '!'
+ Slash ::= '/'
+ Percent ::= '%'
+ RightShift ::= '>>'
+ LeftShift ::= '<<'
+ LT ::= '<'
+ GT ::= '>'
+ LE ::= '<='
+ GE ::= '>='
+ EQ ::= '=='
+ NE ::= '!='
+ Caret ::= '^'
+ Or ::= '|'
+ AndAnd ::= '&&'
+ OrOr ::= '||'
+ Question ::= '?'
+ Colon ::= ':'
+ DotDotDot ::= '...'
+ Assign ::= '='
+ StarAssign ::= '*='
+ SlashAssign ::= '/='
+ PercentAssign ::= '%='
+ PlusAssign ::= '+='
+ MinusAssign ::= '-='
+ RightShiftAssign ::= '>>='
+ LeftShiftAssign ::= '<<='
+ AndAssign ::= '&='
+ CaretAssign ::= '^='
+ OrAssign ::= '|='
+ Comma ::= ','
+ Hash ::= '#'
+ HashHash ::= '##'
+ NewLine ::= 'nl'
+
+
+$End
+
+
+$Globals
+/.
+ import java.util.*;
+
+ import org.eclipse.cdt.core.dom.ast.*;
+ import org.eclipse.cdt.core.dom.c99.IParserActionTokenProvider;
+ import org.eclipse.cdt.core.dom.c99.IParser;
+ import org.eclipse.cdt.core.dom.c99.IParseResult;
+ import org.eclipse.cdt.core.dom.parser.c99.C99ParseResult;
+ import org.eclipse.cdt.core.dom.parser.c99.C99ParserAction;
+ import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+ import org.eclipse.cdt.core.dom.c99.IKeywordMap;
+ import org.eclipse.cdt.core.dom.parser.c99.C99KeywordMap;
+ import org.eclipse.cdt.core.dom.c99.IPreprocessorTokenCollector;
+./
+$End
+
+$Define
+
+ -- These macros allow the header code to be customized by an extending parser.
+
+ $ast_class /.Object./
+ $ba /.$BeginAction action.beforeConsume(); action. ./
+ $ea /.$EndAction./
+ $additional_interfaces /. , IParserActionTokenProvider, IParser, IPreprocessorTokenCollector<IToken> ./
+
+ $action_class /. C99ParserAction ./
+ $keyword_map_class /. C99KeywordMap ./
+ $lexer_class /. C99Lexer ./
+$End
+
+
+$Headers
+/.
+ private $action_class action = new $action_class(this);
+ private List commentTokens = new ArrayList();
+ private IKeywordMap keywordMap = new $keyword_map_class();
+
+ public $action_type() { // constructor
+ this(new $lexer_class());
+ }
+
+ public void addToken(IToken token) {
+ int newKind = mapKind(token.getKind());
+ if(newKind == $prs_type.TK_identifier) {
+ Integer keywordKind = keywordMap.getKeywordKind(token.toString());
+ if(keywordKind != null) {
+ newKind = keywordKind.intValue();
+ }
+ }
+ token.setKind(newKind);
+ super.addToken(token);
+ }
+
+ public void addCommentToken(IToken token) {
+ commentTokens.add(token);
+ }
+
+ public List getCommentTokens() {
+ return commentTokens;
+ }
+
+ public void resetTokenStream() {
+ super.resetTokenStream();
+ action = new $action_class(this);
+ commentTokens = new ArrayList();
+ }
+
+
+ public IParseResult parse() {
+ // this has to be done, or... kaboom!
+ setStreamLength(getSize());
+
+ final int errorRepairCount = -1; // -1 means full error handling
+
+ if(btParser == null) {
+ parser(null, errorRepairCount);
+ }
+ else {
+ try
+ {
+ // reuse the same btParser object for speed
+ // (creating an new instance for every translation unit is dirt slow)
+ btParser.parse(errorRepairCount);
+ }
+ catch (BadParseException e)
+ {
+ reset(e.error_token); // point to error token
+ DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
+ diagnoseParser.diagnose(e.error_token);
+ }
+ }
+
+ IASTTranslationUnit tu = action.getAST();
+ boolean encounteredError = action.encounteredError();
+ IASTCompletionNode compNode = action.getASTCompletionNode();
+
+ resetTokenStream(); // important, allows memory to be reclaimed
+ return new C99ParseResult(tu, compNode, encounteredError);
+ }
+
+
+ // implements IParserActionTokenProvider.getEOFToken()
+ public IToken getEOFToken() {
+ List tokens = getTokens();
+ IToken eof = (IToken) tokens.get(tokens.size() - 1);
+ return eof;
+ }
+
+
+ // implements IParserActionTokenProvider.getRuleTokenCount()
+ public int getRuleTokenCount() {
+ return (getRightSpan() - getLeftSpan()) + 1;
+ }
+
+ public List getRuleTokens() {
+ return Collections.unmodifiableList(getTokens().subList(getLeftSpan(), getRightSpan() + 1));
+ }
+
+./
+$End
+
+
+$Start -- the start symbol
+ translation_unit
+$End
+
+
+
+$Rules
+
+-------------------------------------------------------------------------------------------
+-- AST Scoping
+--
+-- Special empty rule used to trigger the opening of a new AST scope
+-------------------------------------------------------------------------------------------
+
+
+<openscope> ::= $empty /.$ba openASTScope(); $ea./
+
+
+-------------------------------------------------------------------------------------------
+-- Content assist
+-------------------------------------------------------------------------------------------
+
+
+identifier_or_completion
+ ::= 'identifier'
+ | 'Completion'
+
+']' ::=? 'RightBracket'
+ | 'EndOfCompletion'
+
+')' ::=? 'RightParen'
+ | 'EndOfCompletion'
+
+'}' ::=? 'RightBrace'
+ | 'EndOfCompletion'
+
+';' ::=? 'SemiColon'
+ | 'EndOfCompletion'
+
+
+-------------------------------------------------------------------------------------------
+-- Expressions
+-------------------------------------------------------------------------------------------
+
+
+constant
+ ::= 'integer'
+ /.$ba consumeExpressionConstant(IASTLiteralExpression.lk_integer_constant); $ea./
+ | 'floating'
+ /.$ba consumeExpressionConstant(IASTLiteralExpression.lk_float_constant); $ea./
+ | 'charconst'
+ /.$ba consumeExpressionConstant(IASTLiteralExpression.lk_char_constant); $ea./
+ | 'stringlit'
+ /.$ba consumeExpressionConstant(IASTLiteralExpression.lk_string_literal); $ea./
+
+primary_expression
+ ::= constant
+ | identifier_or_completion
+ /.$ba consumeExpressionID(); $ea./
+ | '(' expression ')'
+ /.$ba consumeExpressionBracketed(); $ea./
+
+postfix_expression
+ ::= primary_expression
+ | postfix_expression '[' expression ']'
+ /.$ba consumeExpressionArraySubscript(); $ea./
+ | postfix_expression '(' ')'
+ /.$ba consumeExpressionFunctionCall(false); $ea./
+ | postfix_expression '(' argument_expression_list ')'
+ /.$ba consumeExpressionFunctionCall(true); $ea./
+ | postfix_expression '.' member_name
+ /.$ba consumeExpressionFieldReference(false); $ea./
+ | postfix_expression '->' member_name
+ /.$ba consumeExpressionFieldReference(true); $ea./
+ | postfix_expression '++'
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixIncr); $ea./
+ | postfix_expression '--'
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixDecr); $ea./
+ | '(' type_name ')' '{' <openscope> initializer_list '}'
+ /.$ba consumeExpressionTypeIdInitializer(); $ea./
+ | '(' type_name ')' '{' <openscope> initializer_list ',' '}'
+ /.$ba consumeExpressionTypeIdInitializer(); $ea./
+
+
+member_name
+ ::= identifier_or_completion
+
+
+argument_expression_list
+ ::= assignment_expression
+ /.$ba consumeExpressionList(true); $ea./
+ | argument_expression_list ',' assignment_expression
+ /.$ba consumeExpressionList(false); $ea./
+
+unary_expression
+ ::= postfix_expression
+ | '++' unary_expression
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixIncr); $ea./
+ | '--' unary_expression
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixDecr); $ea./
+ | '&' cast_expression
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_amper); $ea./
+ | '*' cast_expression
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_star); $ea./
+ | '+' cast_expression
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_plus); $ea./
+ | '-' cast_expression
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_minus); $ea./
+ | '~' cast_expression
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_tilde); $ea./
+ | '!' cast_expression
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_not); $ea./
+ | 'sizeof' unary_expression
+ /.$ba consumeExpressionUnaryOperator(IASTUnaryExpression.op_sizeof); $ea./
+ | 'sizeof' '(' type_name ')'
+ /.$ba consumeExpressionUnarySizeofTypeName(); $ea./
+
+ -- ambiguity here because type_name can be an identifier and unary_expression can be an identifier in brackets
+ -- TODO: will need a way of disambiguation, (parse both ways)
+
+cast_expression
+ ::= unary_expression
+ | '(' type_name ')' cast_expression
+ /.$ba consumeExpressionCast(); $ea./
+
+
+multiplicative_expression
+ ::= cast_expression
+ | multiplicative_expression '*' cast_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiply); $ea./
+ | multiplicative_expression '/' cast_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_divide); $ea./
+ | multiplicative_expression '%' cast_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_modulo); $ea./
+
+additive_expression
+ ::= multiplicative_expression
+ | additive_expression '+' multiplicative_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_plus); $ea./
+ | additive_expression '-' multiplicative_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_minus); $ea./
+
+shift_expression
+ ::= additive_expression
+ | shift_expression '<<' additive_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeft); $ea./
+ | shift_expression '>>' additive_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRight); $ea./
+
+relational_expression
+ ::= shift_expression
+ | relational_expression '<' shift_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessThan); $ea./
+ | relational_expression '>' shift_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterThan); $ea./
+ | relational_expression '<=' shift_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessEqual); $ea./
+ | relational_expression '>=' shift_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterEqual); $ea./
+
+equality_expression
+ ::= relational_expression
+ | equality_expression '==' relational_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_equals); $ea./
+ | equality_expression '!=' relational_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_notequals); $ea./
+
+AND_expression
+ ::= equality_expression
+ | AND_expression '&' equality_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAnd); $ea./
+
+exclusive_OR_expression
+ ::= AND_expression
+ | exclusive_OR_expression '^' AND_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXor); $ea./
+
+inclusive_OR_expression
+ ::= exclusive_OR_expression
+ | inclusive_OR_expression '|' exclusive_OR_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOr); $ea./
+
+logical_AND_expression
+ ::= inclusive_OR_expression
+ | logical_AND_expression '&&' inclusive_OR_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalAnd); $ea./
+
+logical_OR_expression
+ ::= logical_AND_expression
+ | logical_OR_expression '||' logical_AND_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalOr); $ea./
+
+conditional_expression
+ ::= logical_OR_expression
+ | logical_OR_expression '?' expression ':' conditional_expression
+ /.$ba consumeExpressionConditional(); $ea./
+
+assignment_expression
+ ::= conditional_expression
+ | unary_expression '=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_assign); $ea./
+ | unary_expression '*=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiplyAssign); $ea./
+ | unary_expression '/=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_divideAssign); $ea./
+ | unary_expression '%=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_moduloAssign); $ea./
+ | unary_expression '+=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_plusAssign); $ea./
+ | unary_expression '-=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_minusAssign); $ea./
+ | unary_expression '<<=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeftAssign); $ea./
+ | unary_expression '>>=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRightAssign); $ea./
+ | unary_expression '&=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAndAssign); $ea./
+ | unary_expression '^=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXorAssign); $ea./
+ | unary_expression '|=' assignment_expression
+ /.$ba consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOrAssign); $ea./
+
+
+-- special rule to avoid confict between problem statments and problem expressions
+expression_in_statement
+ ::= expression_list
+ /.$ba consumeExpression(); $ea./
+
+expression
+ ::= expression_list
+ /.$ba consumeExpression(); $ea./
+ --| ERROR_TOKEN
+ -- /.$ba consumeExpressionProblem(); $ea./
+
+expression_list
+ ::= assignment_expression
+ /.$ba consumeExpressionList(true); $ea./
+ | expression_list ',' assignment_expression
+ /.$ba consumeExpressionList(false); $ea./
+
+constant_expression
+ ::= conditional_expression
+ --| ERROR_TOKEN
+ -- /.$ba consumeExpressionProblem(); $ea./
+ -- I think expressions will have to go at the bottom of the grammar for this to work
+
+
+-------------------------------------------------------------------------------------------
+-- Statements
+-------------------------------------------------------------------------------------------
+
+statement
+ ::= labeled_statement
+ | compound_statement
+ | expression_statement
+ | selection_statement
+ | iteration_statement
+ | jump_statement
+ | ERROR_TOKEN
+ /.$ba consumeStatementProblem(); $ea./
+
+
+labeled_statement
+ ::= label_identifier ':' statement
+ /.$ba consumeStatementLabeled(); $ea./
+ | 'case' constant_expression ':'
+ /.$ba consumeStatementCase(); $ea./
+ | 'default' ':'
+ /.$ba consumeStatementDefault(); $ea./
+
+
+label_identifier
+ ::= 'identifier'
+ /.$ba consumeName(); $ea./
+
+
+compound_statement
+ ::= '{' '}'
+ /.$ba consumeStatementEmptyCompoundStatement(); $ea./
+ | '{' <openscope> block_item_list '}'
+ /.$ba consumeStatementCompoundStatement(); $ea./
+
+
+block_item_list
+ ::= block_item
+ | block_item_list block_item
+
+
+block_item
+ ::= statement
+ | declaration
+ /.$ba consumeStatementDeclaration(); $ea./
+
+
+expression_statement
+ ::= ';'
+ /.$ba consumeStatementNull(); $ea./
+ | expression_in_statement ';'
+ /.$ba consumeStatementExpression(); $ea./
+
+
+selection_statement
+ ::= 'if' '(' expression ')' statement
+ /.$ba consumeStatementIfThen(); $ea./
+ | 'if' '(' expression ')' statement 'else' statement
+ /.$ba consumeStatementIfThenElse(); $ea./
+ | 'switch' '(' expression ')' statement
+ /.$ba consumeStatementSwitch(); $ea./
+
+
+iteration_statement
+ ::= 'do' statement 'while' '(' expression ')' ';'
+ /.$ba consumeStatementDoLoop(); $ea./
+ | 'while' '(' expression ')' statement
+ /.$ba consumeStatementWhileLoop(); $ea./
+ | 'for' '(' expression ';' expression ';' expression ')' statement
+ /.$ba consumeStatementForLoop(true, true, true); $ea./
+ | 'for' '(' expression ';' expression ';' ')' statement
+ /.$ba consumeStatementForLoop(true, true, false); $ea./
+ | 'for' '(' expression ';' ';' expression ')' statement
+ /.$ba consumeStatementForLoop(true, false, true); $ea./
+ | 'for' '(' expression ';' ';' ')' statement
+ /.$ba consumeStatementForLoop(true, false, false); $ea./
+ | 'for' '(' ';' expression ';' expression ')' statement
+ /.$ba consumeStatementForLoop(false, true, true); $ea./
+ | 'for' '(' ';' expression ';' ')' statement
+ /.$ba consumeStatementForLoop(false, true, false); $ea./
+ | 'for' '(' ';' ';' expression ')' statement
+ /.$ba consumeStatementForLoop(false, false, true); $ea./
+ | 'for' '(' ';' ';' ')' statement
+ /.$ba consumeStatementForLoop(false, false, false); $ea./
+ | 'for' '(' declaration expression ';' expression ')' statement
+ /.$ba consumeStatementForLoop(true, true, true); $ea./
+ | 'for' '(' declaration expression ';' ')' statement
+ /.$ba consumeStatementForLoop(true, true, false); $ea./
+ | 'for' '(' declaration ';' expression ')' statement
+ /.$ba consumeStatementForLoop(true, false, true); $ea./
+ | 'for' '(' declaration ';' ')' statement
+ /.$ba consumeStatementForLoop(true, false, false); $ea./
+
+
+jump_statement
+ ::= 'goto' goto_identifier ';'
+ /.$ba consumeStatementGoto(); $ea./
+ | 'continue' ';'
+ /.$ba consumeStatementContinue(); $ea./
+ | 'break' ';'
+ /.$ba consumeStatementBreak(); $ea./
+ | 'return' ';'
+ /.$ba consumeStatementReturn(false); $ea./
+ | 'return' expression ';'
+ /.$ba consumeStatementReturn(true); $ea./
+
+
+goto_identifier
+ ::= 'identifier'
+ /.$ba consumeName(); $ea./
+
+
+-------------------------------------------------------------------------------------------
+-- Declarations
+-------------------------------------------------------------------------------------------
+
+declaration
+ ::= declaration_specifiers ';'
+ /.$ba consumeDeclaration(false); $ea./
+ | declaration_specifiers <openscope> init_declarator_list ';'
+ /.$ba consumeDeclaration(true); $ea./
+
+
+declaration_specifiers
+ ::= <openscope> simple_declaration_specifiers
+ /.$ba consumeDeclarationSpecifiersSimple(); $ea./
+ | <openscope> struct_or_union_declaration_specifiers
+ /.$ba consumeDeclarationSpecifiersStructUnionEnum(); $ea./
+ | <openscope> enum_declaration_specifiers
+ /.$ba consumeDeclarationSpecifiersStructUnionEnum(); $ea./
+ | <openscope> typdef_name_declaration_specifiers
+ /.$ba consumeDeclarationSpecifiersTypedefName(); $ea./
+
+
+no_type_declaration_specifier
+ ::= storage_class_specifier
+ | type_qualifier
+ | function_specifier
+
+
+no_type_declaration_specifiers
+ ::= no_type_declaration_specifier
+ | no_type_declaration_specifiers no_type_declaration_specifier
+
+
+simple_declaration_specifiers
+ ::= type_specifier
+ | no_type_declaration_specifiers type_specifier
+ | simple_declaration_specifiers type_specifier
+ | simple_declaration_specifiers no_type_declaration_specifier
+
+
+struct_or_union_declaration_specifiers
+ ::= struct_or_union_specifier
+ | no_type_declaration_specifiers struct_or_union_specifier
+ | struct_or_union_declaration_specifiers no_type_declaration_specifier
+
+
+enum_declaration_specifiers
+ ::= enum_specifier
+ | no_type_declaration_specifiers enum_specifier
+ | enum_declaration_specifiers no_type_declaration_specifier
+
+
+typdef_name_declaration_specifiers
+ ::= typedef_name
+ | no_type_declaration_specifiers typedef_name
+ | typdef_name_declaration_specifiers no_type_declaration_specifier
+
+
+init_declarator_list
+ ::= init_declarator
+ | init_declarator_list ',' init_declarator
+
+init_declarator
+ ::= declarator
+ | declarator '=' initializer
+ /.$ba consumeDeclaratorWithInitializer(); $ea./
+
+
+-- at most one storage_class_specifier is allowed in the declaration specifiers
+storage_class_specifier
+ ::= 'typedef' /.$ba consumeToken(); $ea./
+ | 'extern' /.$ba consumeToken(); $ea./
+ | 'static' /.$ba consumeToken(); $ea./
+ | 'auto' /.$ba consumeToken(); $ea./
+ | 'register' /.$ba consumeToken(); $ea./
+
+
+type_specifier
+ ::= 'void' /.$ba consumeToken(); $ea./
+ | 'char' /.$ba consumeToken(); $ea./
+ | 'short' /.$ba consumeToken(); $ea./
+ | 'int' /.$ba consumeToken(); $ea./
+ | 'long' /.$ba consumeToken(); $ea./
+ | 'float' /.$ba consumeToken(); $ea./
+ | 'double' /.$ba consumeToken(); $ea./
+ | 'signed' /.$ba consumeToken(); $ea./
+ | 'unsigned' /.$ba consumeToken(); $ea./
+ | '_Bool' /.$ba consumeToken(); $ea./
+ | '_Complex' /.$ba consumeToken(); $ea./
+ | '_Imaginary' /.$ba consumeToken(); $ea./
+
+
+
+typedef_name
+ ::= identifier_or_completion /.$ba consumeToken(); $ea./
+
+
+struct_or_union_specifier
+ ::= 'struct' '{' <openscope> struct_declaration_list_opt '}'
+ /.$ba consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_struct); $ea./
+
+ | 'union' '{' <openscope> struct_declaration_list_opt '}'
+ /.$ba consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_union); $ea./
+
+ | 'struct' struct_or_union_identifier '{' <openscope> struct_declaration_list_opt '}'
+ /.$ba consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_struct); $ea./
+
+ | 'union' struct_or_union_identifier '{' <openscope> struct_declaration_list_opt '}'
+ /.$ba consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_union); $ea./
+
+ | 'struct' struct_or_union_identifier
+ /.$ba consumeTypeSpecifierElaborated(IASTElaboratedTypeSpecifier.k_struct); $ea./
+
+ | 'union' struct_or_union_identifier
+ /.$ba consumeTypeSpecifierElaborated(IASTElaboratedTypeSpecifier.k_union); $ea./
+
+
+struct_or_union_identifier
+ ::= 'identifier'
+ /.$ba consumeName(); $ea./
+
+struct_declaration_list_opt
+ ::= struct_declaration_list
+ | $empty
+
+struct_declaration_list
+ ::= struct_declaration
+ | struct_declaration_list struct_declaration
+
+
+struct_declaration
+ ::= specifier_qualifier_list <openscope> struct_declarator_list ';' -- regular declarators plus bit fields
+ /.$ba consumeStructDeclaration(true); $ea./ -- TODO is it okay to reuse consumeDeclaration() ?
+ | specifier_qualifier_list ';'
+ /.$ba consumeStructDeclaration(false); $ea./
+
+
+-- just reuse declaration_specifiers, makes grammar a bit more lenient but thats ok
+specifier_qualifier_list
+ ::= declaration_specifiers
+
+
+struct_declarator_list
+ ::= struct_declarator
+ | struct_declarator_list ',' struct_declarator
+
+struct_declarator
+ ::= declarator
+ | ':' constant_expression
+ /.$ba consumeStructBitField(false); $ea./
+ | declarator ':' constant_expression
+ /.$ba consumeStructBitField(true); $ea./
+
+
+enum_identifier
+ ::= 'identifier' /.$ba consumeName(); $ea./
+
+
+enum_specifier
+ ::= 'enum' '{' <openscope> enumerator_list_opt '}'
+ /.$ba consumeTypeSpecifierEnumeration(false); $ea./
+
+ | 'enum' enum_identifier '{' <openscope> enumerator_list_opt '}'
+ /.$ba consumeTypeSpecifierEnumeration(true); $ea./
+
+ | 'enum' '{' <openscope> enumerator_list_opt ',' '}'
+ /.$ba consumeTypeSpecifierEnumeration(false); $ea./
+
+ | 'enum' enum_identifier '{' <openscope> enumerator_list_opt ',' '}'
+ /.$ba consumeTypeSpecifierEnumeration(true); $ea./
+
+ | 'enum' enum_identifier
+ /.$ba consumeTypeSpecifierElaborated(IASTElaboratedTypeSpecifier.k_enum); $ea./
+
+
+enumerator_list_opt
+ ::= enumerator_list
+ | $empty
+
+enumerator_list
+ ::= enumerator
+ | enumerator_list ',' enumerator
+
+
+enumerator
+ ::= enum_identifier
+ /.$ba consumeEnumerator(false); $ea./
+ | enum_identifier '=' constant_expression
+ /.$ba consumeEnumerator(true); $ea./
+
+
+type_qualifier
+ ::= 'const' /.$ba consumeToken(); $ea./
+ | 'restrict' /.$ba consumeToken(); $ea./
+ | 'volatile' /.$ba consumeToken(); $ea./
+
+function_specifier
+ ::= 'inline' /.$ba consumeToken(); $ea./
+
+
+declarator
+ ::= direct_declarator
+ | <openscope> pointer direct_declarator
+ /.$ba consumeDeclaratorWithPointer(true); $ea./
+
+
+direct_declarator
+ ::= 'identifier'
+ /.$ba consumeDirectDeclaratorIdentifier(); $ea./
+
+ | '(' declarator ')'
+ /.$ba consumeDirectDeclaratorBracketed(); $ea./
+
+ | array_direct_declarator
+
+ | function_direct_declarator
+
+
+
+array_direct_declarator
+ ::= direct_declarator array_modifier
+ /.$ba consumeDirectDeclaratorArrayDeclarator(); $ea./
+
+
+
+function_direct_declarator
+ ::= direct_declarator '(' <openscope> parameter_type_list ')'
+ /.$ba consumeDirectDeclaratorFunctionDeclarator(true); $ea./
+
+ | direct_declarator '(' ')'
+ /.$ba consumeDirectDeclaratorFunctionDeclarator(false); $ea./
+
+
+function_declarator
+ ::= function_direct_declarator
+ | <openscope> pointer function_direct_declarator
+ /.$ba consumeDeclaratorWithPointer(true); $ea./
+
+
+-- This is a hack because the parser cannot tell the difference between
+-- plain identifiers and types. Because of this an identifier_list would
+-- always be parsed as a parameter_type_list instead. In a KnR funciton
+-- definition we can use the extra list of declarators to disambiguate.
+-- This rule should be merged back into direct_declarator if type info is
+-- added to the parser.
+knr_direct_declarator
+ ::= direct_declarator '(' <openscope> identifier_list ')'
+ /.$ba consumeDirectDeclaratorFunctionDeclaratorKnR(); $ea./
+
+
+knr_function_declarator
+ ::= knr_direct_declarator
+ | <openscope> pointer knr_direct_declarator
+ /.$ba consumeDeclaratorWithPointer(true); $ea./
+
+
+array_modifier
+ ::= '[' ']'
+ /.$ba consumeDirectDeclaratorArrayModifier(false); $ea./
+
+ | '[' <openscope> type_qualifier_list ']'
+ /.$ba consumeDirectDeclaratorModifiedArrayModifier(false, false, true, false); $ea./
+
+ | '[' assignment_expression ']'
+ /.$ba consumeDirectDeclaratorArrayModifier(true ); $ea./
+
+ | '[' <openscope> type_qualifier_list assignment_expression ']'
+ /.$ba consumeDirectDeclaratorModifiedArrayModifier(false, false, true, true ); $ea./
+
+ | '[' 'static' assignment_expression ']'
+ /.$ba consumeDirectDeclaratorModifiedArrayModifier(true, false, false, true ); $ea./
+
+ | '[' 'static' <openscope> type_qualifier_list assignment_expression ']'
+ /.$ba consumeDirectDeclaratorModifiedArrayModifier(true, false, true, true ); $ea./
+
+ | '[' <openscope> type_qualifier_list 'static' assignment_expression ']'
+ /.$ba consumeDirectDeclaratorModifiedArrayModifier(true, false, true, true ); $ea./
+
+ | '[' '*' ']'
+ /.$ba consumeDirectDeclaratorModifiedArrayModifier(false, true, false, false); $ea./
+
+ | '[' <openscope> type_qualifier_list '*' ']'
+ /.$ba consumeDirectDeclaratorModifiedArrayModifier(false, true, true, false); $ea./
+
+
+pointer
+ ::= '*'
+ /.$ba consumePointer(); $ea./
+ | pointer '*'
+ /.$ba consumePointer(); $ea./
+ | '*' <openscope> type_qualifier_list
+ /.$ba consumePointerTypeQualifierList(); $ea./
+ | pointer '*' <openscope> type_qualifier_list
+ /.$ba consumePointerTypeQualifierList(); $ea./
+
+type_qualifier_list
+ ::= type_qualifier
+ | type_qualifier_list type_qualifier
+
+parameter_type_list
+ ::= parameter_list
+ | parameter_list ',' '...'
+ | '...' -- not spec
+
+parameter_list
+ ::= parameter_declaration
+ | parameter_list ',' parameter_declaration
+
+parameter_declaration
+ ::= declaration_specifiers init_declarator
+ /.$ba consumeParameterDeclaration(true); $ea./
+ | declaration_specifiers
+ /.$ba consumeParameterDeclaration(false); $ea./
+ | declaration_specifiers abstract_declarator
+ /.$ba consumeParameterDeclaration(true); $ea./
+
+
+identifier_list
+ ::= 'identifier'
+ /.$ba consumeName(); $ea./
+ | identifier_list ',' 'identifier'
+ /.$ba consumeName(); $ea./
+
+type_name
+ ::= specifier_qualifier_list
+ /.$ba consumeTypeId(false); $ea./
+ | specifier_qualifier_list abstract_declarator
+ /.$ba consumeTypeId(true); $ea./
+
+
+abstract_declarator -- a declarator that does not include an identifier
+ ::= <openscope> pointer
+ /.$ba consumeDeclaratorWithPointer(false); $ea./
+ | direct_abstract_declarator
+ | <openscope> pointer direct_abstract_declarator
+ /.$ba consumeDeclaratorWithPointer(true); $ea./
+
+
+-- rewritten to use the more general array_modifier rule
+direct_abstract_declarator
+ ::= '(' abstract_declarator ')'
+ /.$ba consumeDirectDeclaratorBracketed(); $ea./
+
+ | array_modifier
+ /.$ba consumeAbstractDeclaratorArrayModifier(false); $ea./
+
+ | direct_abstract_declarator array_modifier
+ /.$ba consumeAbstractDeclaratorArrayModifier(true); $ea./
+
+ | '(' ')'
+ /.$ba consumeAbstractDeclaratorFunctionDeclarator(false, false); $ea./
+
+ | direct_abstract_declarator '(' ')'
+ /.$ba consumeAbstractDeclaratorFunctionDeclarator(true, false); $ea./
+
+ | '(' <openscope> parameter_type_list ')'
+ /.$ba consumeAbstractDeclaratorFunctionDeclarator(false, true); $ea./
+
+ | direct_abstract_declarator '(' <openscope> parameter_type_list ')'
+ /.$ba consumeAbstractDeclaratorFunctionDeclarator(true, true); $ea./
+
+
+initializer
+ ::= assignment_expression
+ /.$ba consumeInitializer(); $ea./
+ | '{' <openscope> initializer_list '}'
+ /.$ba consumeInitializerList(); $ea./
+ | '{' <openscope> initializer_list ',' '}'
+ /.$ba consumeInitializerList(); $ea./
+
+
+initializer_list
+ ::= initializer
+ | designated_initializer
+ | initializer_list ',' initializer
+ | initializer_list ',' designated_initializer
+
+
+
+designated_initializer
+ ::= <openscope> designation initializer
+ /.$ba consumeInitializerDesignated(); $ea./
+
+designation
+ ::= designator_list '='
+
+designator_list
+ ::= designator
+ | designator_list designator
+
+designator
+ ::= '[' constant_expression ']'
+ /.$ba consumeDesignatorArrayDesignator(); $ea./
+ | '.' 'identifier'
+ /.$ba consumeDesignatorFieldDesignator(); $ea./
+
+
+
+
+
+
+
+
+-------------------------------------------------------------------------------------------
+-- External Definitions
+-------------------------------------------------------------------------------------------
+
+translation_unit
+ ::= external_declaration_list
+ /.$ba consumeTranslationUnit(); $ea./
+ | $empty
+ /.$ba consumeTranslationUnit(); $ea./
+
+external_declaration_list
+ ::= external_declaration
+ | external_declaration_list external_declaration
+
+external_declaration
+ ::= function_definition
+ | declaration
+ | ';'
+ /.$ba consumeDeclarationEmpty(); $ea./
+ | ERROR_TOKEN
+ /.$ba consumeDeclarationProblem(); $ea./
+
+-- The extra <openscope> nonterminal before declarator in this rule is only there
+-- to avoid a shift/reduce error with the rule for declaration.
+function_definition
+ ::= declaration_specifiers <openscope> function_declarator compound_statement
+ /.$ba consumeFunctionDefinition(true); $ea./
+ | declaration_specifiers <openscope> knr_function_declarator <openscope> declaration_list compound_statement
+ /.$ba consumeFunctionDefinitionKnR(); $ea./
+
+ -- this rule is here as a special case just to support implicit int in function definitions
+ | function_declarator compound_statement
+ /.$ba consumeFunctionDefinition(false); $ea./
+
+
+declaration_list
+ ::= declaration
+ | declaration_list declaration
+
+$End
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.g b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.g
new file mode 100644
index 00000000000..b7eebfde636
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.g
@@ -0,0 +1,1218 @@
+-----------------------------------------------------------------------------------
+-- Copyright (c) 2006, 2008 IBM Corporation and others.
+-- All rights reserved. This program and the accompanying materials
+-- are made available under the terms of the Eclipse Public License v1.0
+-- which accompanies this distribution, and is available at
+-- http://www.eclipse.org/legal/epl-v10.html
+--
+-- Contributors:
+-- IBM Corporation - initial API and implementation
+-----------------------------------------------------------------------------------
+
+%options la=2
+%options package=org.eclipse.cdt.internal.core.dom.lrparser.c99
+%options template=TrialUndoParserTemplate.g
+
+
+$Notice
+-- Copied into all files generated by LPG
+/./*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *********************************************************************************/
+
+ // This file was generated by LPG
+./
+$End
+
+
+
+$Terminals
+
+ -- Keywords
+
+ auto break case char const continue default do
+ double else enum extern float for goto if
+ inline int long register restrict return short signed
+ sizeof static struct switch typedef union unsigned void
+ volatile while _Bool _Complex _Imaginary
+
+ -- Literals
+
+ integer floating charconst stringlit
+
+ -- identifiers
+ -- Special token that represents identifiers that have been declared as typedefs (lexer feedback hack)
+
+ identifier
+ TypedefName
+
+ -- Special tokens used in content assist
+
+ Completion
+ EndOfCompletion
+
+ -- Unrecognized token
+
+ Invalid
+
+ -- Punctuation (with aliases to make grammar more readable)
+
+ LeftBracket ::= '['
+ LeftParen ::= '('
+ LeftBrace ::= '{'
+ Dot ::= '.'
+ Arrow ::= '->'
+ PlusPlus ::= '++'
+ MinusMinus ::= '--'
+ And ::= '&'
+ Star ::= '*'
+ Plus ::= '+'
+ Minus ::= '-'
+ Tilde ::= '~'
+ Bang ::= '!'
+ Slash ::= '/'
+ Percent ::= '%'
+ RightShift ::= '>>'
+ LeftShift ::= '<<'
+ LT ::= '<'
+ GT ::= '>'
+ LE ::= '<='
+ GE ::= '>='
+ EQ ::= '=='
+ NE ::= '!='
+ Caret ::= '^'
+ Or ::= '|'
+ AndAnd ::= '&&'
+ OrOr ::= '||'
+ Question ::= '?'
+ Colon ::= ':'
+ DotDotDot ::= '...'
+ Assign ::= '='
+ StarAssign ::= '*='
+ SlashAssign ::= '/='
+ PercentAssign ::= '%='
+ PlusAssign ::= '+='
+ MinusAssign ::= '-='
+ RightShiftAssign ::= '>>='
+ LeftShiftAssign ::= '<<='
+ AndAssign ::= '&='
+ CaretAssign ::= '^='
+ OrAssign ::= '|='
+ Comma ::= ','
+
+ RightBracket -- these four have special rules for content assist
+ RightParen
+ RightBrace
+ SemiColon
+
+
+$End
+
+
+$Globals
+/.
+ import java.util.*;
+
+ import org.eclipse.cdt.core.dom.ast.*;
+ import org.eclipse.cdt.core.dom.lrparser.IParser;
+ import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+ import org.eclipse.cdt.core.dom.lrparser.action.c99.C99ASTNodeFactory;
+ import org.eclipse.cdt.core.dom.lrparser.action.c99.C99BuildASTParserAction;
+ import org.eclipse.cdt.core.dom.lrparser.action.c99.C99TypedefTrackerParserAction;
+ import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+./
+$End
+
+$Define
+ -- These macros allow the template and header code to be customized by an extending parser.
+ $ast_class /.Object./
+ $additional_interfaces /. ./
+
+ $build_action_class /. C99BuildASTParserAction ./
+ $resolve_action_class /. C99TypedefTrackerParserAction ./
+ $node_factory_create_expression /. C99ASTNodeFactory.DEFAULT_INSTANCE ./
+
+
+ $lexer_class /. C99Lexer ./
+ $action_class /. C99ParserAction ./
+ $data_class /. Object ./ -- allow anything to be passed between actions
+
+ $UndoResolver /.$Undo action.resolver.undo(); $EndUndo./
+
+ $Resolve /. $BeginTrial $resolve.
+ ./
+ $EndResolve /. $EndTrial
+ $UndoResolver
+ ./ -- undo actions are automatically generated for binding resolution actions
+
+ $Builder /. $BeginFinal $builder.
+ ./
+ $EndBuilder /. /*$builder.getASTStack().print();*/ $EndFinal ./
+
+ $Build /. $Action $Builder ./
+ $EndBuild /. $EndBuilder $EndAction ./
+
+ $resolve /. action.resolver./
+ $builder /. action.builder./
+
+$End
+
+
+$Headers
+/.
+ private $action_class action;
+
+ private void initActions(IASTTranslationUnit tu) {
+ // binding resolution actions need access to IASTName nodes, temporary
+ action = new $action_class();
+ action.resolver = new $resolve_action_class(this);
+ action.builder = new $build_action_class($node_factory_create_expression, this, tu);
+ action.builder.setTokenMap(C99Parsersym.orderedTerminalSymbols);
+ setParserAction(action);
+ }
+
+
+ public void addToken(IToken token) {
+ token.setKind(mapKind(token.getKind()));
+ super.addToken(token);
+ }
+
+
+ public IASTCompletionNode parse(IASTTranslationUnit tu) {
+ // this has to be done, or... kaboom!
+ setStreamLength(getSize());
+ initActions(tu);
+
+ final int errorRepairCount = -1; // -1 means full error handling
+ parser(null, errorRepairCount); // do the actual parse
+ super.resetTokenStream(); // allow tokens to be garbage collected
+
+ // the completion node may be null
+ IASTCompletionNode compNode = action.builder.getASTCompletionNode();
+
+ action = null;
+ parserAction = null;
+ return compNode;
+ }
+
+
+ public int getKind(int i) {
+ int kind = super.getKind(i);
+ // lexer feedback hack!
+ if(kind == C99Parsersym.TK_identifier && action.resolver.isTypedef(getTokenText(i))) {
+ kind = C99Parsersym.TK_TypedefName;
+ }
+ return kind;
+ }
+
+./
+$End
+
+
+$Start
+ translation_unit
+$End
+
+
+
+$Rules
+
+-------------------------------------------------------------------------------------------
+-- AST and Symbol Table Scoping
+-------------------------------------------------------------------------------------------
+
+
+<openscope-ast>
+ ::= $empty
+ /.$Action $Builder openASTScope(); $EndBuilder $EndAction./
+
+<openscope-symbol>
+ ::= $empty
+ /.$Action $Resolve openSymbolScope(); $EndResolve $EndAction./
+
+<openscope-declaration>
+ ::= $empty
+ /.$Action $Resolve openDeclarationScope(); $EndResolve $EndAction./
+
+-------------------------------------------------------------------------------------------
+-- Content assist
+-------------------------------------------------------------------------------------------
+
+-- The EndOfCompletion token is a special token that matches some punctuation.
+-- These tokens allow the parse to complete successfully after a Completion token
+-- is encountered.
+
+
+']' ::=? 'RightBracket'
+ | 'EndOfCompletion'
+
+')' ::=? 'RightParen'
+ | 'EndOfCompletion'
+
+'}' ::=? 'RightBrace'
+ | 'EndOfCompletion'
+
+';' ::=? 'SemiColon'
+ | 'EndOfCompletion'
+
+
+
+-------------------------------------------------------------------------------------------
+-- Expressions
+-------------------------------------------------------------------------------------------
+
+
+literal
+ ::= 'integer'
+ /. $Build consumeExpressionLiteral(IASTLiteralExpression.lk_integer_constant); $EndBuild ./
+ | 'floating'
+ /. $Build consumeExpressionLiteral(IASTLiteralExpression.lk_float_constant); $EndBuild ./
+ | 'charconst'
+ /. $Build consumeExpressionLiteral(IASTLiteralExpression.lk_char_constant); $EndBuild ./
+ | 'stringlit'
+ /. $Build consumeExpressionLiteral(IASTLiteralExpression.lk_string_literal); $EndBuild ./
+
+
+primary_expression
+ ::= literal
+ | primary_expression_id
+ /. $Build consumeExpressionID(); $EndBuild ./
+ | '(' expression ')'
+ /. $Build consumeExpressionBracketed(); $EndBuild ./
+
+
+primary_expression_id -- Typedefname not allowed as a variable name.
+ ::= 'identifier'
+ | 'Completion'
+
+
+postfix_expression
+ ::= primary_expression
+ | postfix_expression '[' expression ']'
+ /. $Build consumeExpressionArraySubscript(); $EndBuild ./
+ | postfix_expression '(' expression_list_opt ')'
+ /. $Build consumeExpressionFunctionCall(); $EndBuild ./
+ | postfix_expression '.' member_name
+ /. $Build consumeExpressionFieldReference(false); $EndBuild ./
+ | postfix_expression '->' member_name
+ /. $Build consumeExpressionFieldReference(true); $EndBuild ./
+ | postfix_expression '++'
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixIncr); $EndBuild ./
+ | postfix_expression '--'
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixDecr); $EndBuild ./
+ | '(' type_name ')' '{' <openscope-ast> initializer_list comma_opt '}'
+ /. $Build consumeExpressionTypeIdInitializer(); $EndBuild ./
+
+
+comma_opt
+ ::= ',' | $empty
+
+
+member_name
+ ::= 'identifier'
+ | 'TypedefName'
+ | 'Completion'
+
+
+unary_expression
+ ::= postfix_expression
+ | '++' unary_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixIncr); $EndBuild ./
+ | '--' unary_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixDecr); $EndBuild ./
+ | '&' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_amper); $EndBuild ./
+ | '*' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_star); $EndBuild ./
+ | '+' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_plus); $EndBuild ./
+ | '-' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_minus); $EndBuild ./
+ | '~' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_tilde); $EndBuild ./
+ | '!' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_not); $EndBuild ./
+ | 'sizeof' unary_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_sizeof); $EndBuild ./
+ | 'sizeof' '(' type_name ')'
+ /. $Build consumeExpressionTypeId(IASTTypeIdExpression.op_sizeof); $EndBuild ./
+
+
+cast_expression
+ ::= unary_expression
+ | '(' type_name ')' cast_expression
+ /. $Build consumeExpressionCast(IASTCastExpression.op_cast); $EndBuild ./
+
+
+multiplicative_expression
+ ::= cast_expression
+ | multiplicative_expression '*' cast_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiply); $EndBuild ./
+ | multiplicative_expression '/' cast_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_divide); $EndBuild ./
+ | multiplicative_expression '%' cast_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_modulo); $EndBuild ./
+
+
+additive_expression
+ ::= multiplicative_expression
+ | additive_expression '+' multiplicative_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_plus); $EndBuild ./
+ | additive_expression '-' multiplicative_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_minus); $EndBuild ./
+
+
+shift_expression
+ ::= additive_expression
+ | shift_expression '<<' additive_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeft); $EndBuild ./
+ | shift_expression '>>' additive_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRight); $EndBuild ./
+
+
+relational_expression
+ ::= shift_expression
+ | relational_expression '<' shift_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessThan); $EndBuild ./
+ | relational_expression '>' shift_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterThan); $EndBuild ./
+ | relational_expression '<=' shift_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessEqual); $EndBuild ./
+ | relational_expression '>=' shift_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterEqual); $EndBuild ./
+
+
+equality_expression
+ ::= relational_expression
+ | equality_expression '==' relational_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_equals); $EndBuild ./
+ | equality_expression '!=' relational_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_notequals); $EndBuild ./
+
+
+AND_expression
+ ::= equality_expression
+ | AND_expression '&' equality_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAnd); $EndBuild ./
+
+
+exclusive_OR_expression
+ ::= AND_expression
+ | exclusive_OR_expression '^' AND_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXor); $EndBuild ./
+
+
+inclusive_OR_expression
+ ::= exclusive_OR_expression
+ | inclusive_OR_expression '|' exclusive_OR_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOr); $EndBuild ./
+
+
+logical_AND_expression
+ ::= inclusive_OR_expression
+ | logical_AND_expression '&&' inclusive_OR_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalAnd); $EndBuild ./
+
+
+logical_OR_expression
+ ::= logical_AND_expression
+ | logical_OR_expression '||' logical_AND_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalOr); $EndBuild ./
+
+
+conditional_expression
+ ::= logical_OR_expression
+ | logical_OR_expression '?' expression ':' conditional_expression
+ /. $Build consumeExpressionConditional(); $EndBuild ./
+
+
+assignment_expression
+ ::= conditional_expression
+ | unary_expression '=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_assign); $EndBuild ./
+ | unary_expression '*=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiplyAssign); $EndBuild ./
+ | unary_expression '/=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_divideAssign); $EndBuild ./
+ | unary_expression '%=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_moduloAssign); $EndBuild ./
+ | unary_expression '+=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_plusAssign); $EndBuild ./
+ | unary_expression '-=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_minusAssign); $EndBuild ./
+ | unary_expression '<<=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeftAssign); $EndBuild ./
+ | unary_expression '>>=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRightAssign); $EndBuild ./
+ | unary_expression '&=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAndAssign); $EndBuild ./
+ | unary_expression '^=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXorAssign); $EndBuild ./
+ | unary_expression '|=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOrAssign); $EndBuild ./
+
+
+-- special rule to avoid conflict between problem statements and problem expressions
+expression_in_statement
+ ::= expression_list
+
+
+expression
+ ::= expression_list
+
+
+expression_list
+ ::= <openscope-ast> expression_list_actual
+ /. $Build consumeExpressionList(); $EndBuild ./
+
+
+expression_list_opt
+ ::= expression_list
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+expression_list_actual
+ ::= assignment_expression
+ | expression_list_actual ',' assignment_expression
+
+
+constant_expression
+ ::= conditional_expression
+
+
+-------------------------------------------------------------------------------------------
+-- Statements
+-------------------------------------------------------------------------------------------
+
+
+
+statement
+ ::= labeled_statement
+ | compound_statement
+ | expression_statement
+ | selection_statement
+ | iteration_statement
+ | jump_statement
+ | ERROR_TOKEN
+ /. $Build consumeStatementProblem(); $EndBuild ./
+
+
+labeled_statement
+ ::= identifier_or_typedefname ':' statement
+ /. $Build consumeStatementLabeled(); $EndBuild ./
+ | 'case' constant_expression ':'
+ /. $Build consumeStatementCase(); $EndBuild ./
+ | 'default' ':'
+ /. $Build consumeStatementDefault(); $EndBuild ./
+
+
+compound_statement
+ ::= <openscope-symbol> '{' '}'
+ /.
+ $Action
+ $Resolve closeSymbolScope(); $EndResolve
+ $Builder consumeStatementCompoundStatement(false); $EndBuilder
+ $EndAction
+ ./
+ | <openscope-symbol> '{' <openscope-ast> block_item_list '}'
+ /.
+ $Action
+ $Resolve closeSymbolScope(); $EndResolve
+ $Builder consumeStatementCompoundStatement(true); $EndBuilder
+ $EndAction
+ ./
+
+
+block_item_list
+ ::= block_item
+ | block_item_list block_item
+
+
+block_item
+ ::= statement
+ | declaration
+ /. $Build consumeStatementDeclaration(); $EndBuild ./
+
+
+expression_statement
+ ::= ';'
+ /. $Build consumeStatementNull(); $EndBuild ./
+ | expression_in_statement ';'
+ /. $Build consumeStatementExpression(); $EndBuild ./
+
+
+selection_statement
+ ::= 'if' '(' expression ')' statement
+ /. $Build consumeStatementIf(false); $EndBuild ./
+ | 'if' '(' expression ')' statement 'else' statement
+ /. $Build consumeStatementIf(true); $EndBuild ./
+ | 'switch' '(' expression ')' statement
+ /. $Build consumeStatementSwitch(); $EndBuild ./
+
+
+expression_opt
+ ::= expression
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+iteration_statement
+ ::= 'do' statement 'while' '(' expression ')' ';'
+ /. $Build consumeStatementDoLoop(); $EndBuild ./
+ | 'while' '(' expression ')' statement
+ /. $Build consumeStatementWhileLoop(); $EndBuild ./
+ | <openscope-symbol> 'for' '(' expression_opt ';' expression_opt ';' expression_opt ')' statement
+ /.
+ $Action
+ $Resolve closeSymbolScope(); $EndResolve
+ $Builder consumeStatementForLoop(); $EndBuilder
+ $EndAction
+ ./
+ | <openscope-symbol> 'for' '(' declaration expression_opt ';' expression_opt ')' statement
+ /.
+ $Action
+ $Resolve closeSymbolScope(); $EndResolve
+ $Builder consumeStatementForLoop(); $EndBuilder
+ $EndAction
+ ./
+
+
+jump_statement
+ ::= 'goto' identifier_or_typedefname ';'
+ /. $Build consumeStatementGoto(); $EndBuild ./
+ | 'continue' ';'
+ /. $Build consumeStatementContinue(); $EndBuild ./
+ | 'break' ';'
+ /. $Build consumeStatementBreak(); $EndBuild ./
+ | 'return' ';'
+ /. $Build consumeStatementReturn(false); $EndBuild ./
+ | 'return' expression ';'
+ /. $Build consumeStatementReturn(true); $EndBuild ./
+
+
+
+-------------------------------------------------------------------------------------------
+-- Declarations
+-------------------------------------------------------------------------------------------
+
+
+
+declaration
+ ::= declaration_specifiers ';'
+ /.
+ $Action
+ $Resolve closeDeclarationScope(); $EndResolve
+ $Builder consumeDeclarationSimple(false); $EndBuilder
+ $EndAction
+ ./
+ | declaration_specifiers <openscope-ast> init_declarator_list ';'
+ /.
+ $Action
+ $Resolve closeDeclarationScope(); $EndResolve
+ $Builder consumeDeclarationSimple(true); $EndBuilder
+ $EndAction
+ ./
+
+
+declaration_specifiers
+ ::= <openscope-declaration> <openscope-ast> simple_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersSimple(); $EndBuild ./
+ | <openscope-declaration> <openscope-ast> struct_or_union_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersStructUnionEnum(); $EndBuild ./
+ | <openscope-declaration> <openscope-ast> elaborated_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersStructUnionEnum(); $EndBuild ./
+ | <openscope-declaration> <openscope-ast> enum_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersStructUnionEnum(); $EndBuild ./
+ | <openscope-declaration> <openscope-ast> typdef_name_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersTypedefName(); $EndBuild ./
+
+
+no_type_declaration_specifier
+ ::= storage_class_specifier
+ | type_qualifier
+ | function_specifier
+
+
+no_type_declaration_specifiers
+ ::= no_type_declaration_specifier
+ | no_type_declaration_specifiers no_type_declaration_specifier
+
+
+simple_declaration_specifiers
+ ::= simple_type_specifier
+ | no_type_declaration_specifiers simple_type_specifier
+ | simple_declaration_specifiers simple_type_specifier
+ | simple_declaration_specifiers no_type_declaration_specifier
+
+
+struct_or_union_declaration_specifiers
+ ::= struct_or_union_specifier
+ | no_type_declaration_specifiers struct_or_union_specifier
+ | struct_or_union_declaration_specifiers no_type_declaration_specifier
+
+
+elaborated_declaration_specifiers
+ ::= elaborated_specifier
+ | no_type_declaration_specifiers elaborated_specifier
+ | elaborated_declaration_specifiers no_type_declaration_specifier
+
+
+enum_declaration_specifiers
+ ::= enum_specifier
+ | no_type_declaration_specifiers enum_specifier
+ | enum_declaration_specifiers no_type_declaration_specifier
+
+
+typdef_name_declaration_specifiers
+ ::= typedef_name_in_declspec
+ | no_type_declaration_specifiers typedef_name_in_declspec
+ | typdef_name_declaration_specifiers no_type_declaration_specifier
+
+
+init_declarator_list
+ ::= init_declarator
+ | init_declarator_list ',' init_declarator
+
+
+init_declarator
+ ::= complete_declarator
+ | complete_declarator '=' initializer
+ /. $Build consumeDeclaratorWithInitializer(); $EndBuild ./
+
+
+complete_declarator
+ ::= declarator
+ /.
+ $Action
+ $Resolve consumeDeclaratorComplete(); $EndResolve
+ $EndAction
+ ./
+
+
+storage_class_specifier
+ ::= storage_class_specifier_token
+ /.
+ $Action
+ $Resolve consumeDeclSpecToken(); $EndResolve
+ $Builder consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+
+storage_class_specifier_token
+ ::= 'typedef'
+ | 'extern'
+ | 'static'
+ | 'auto'
+ | 'register'
+
+
+simple_type_specifier
+ ::= simple_type_specifier_token
+ /.
+ $Action
+ $Resolve consumeDeclSpecToken(); $EndResolve
+ $Builder consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+simple_type_specifier_token
+ ::= 'void'
+ | 'char'
+ | 'short'
+ | 'int'
+ | 'long'
+ | 'float'
+ | 'double'
+ | 'signed'
+ | 'unsigned'
+ | '_Bool'
+ | '_Complex'
+ | '_Imaginary'
+
+
+typedef_name_in_declspec
+ ::= 'TypedefName'
+ /.
+ $Action
+ $Resolve consumeDeclSpecToken(); $EndResolve
+ $Builder consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+ | 'Completion'
+ /.
+ $Action
+ $Resolve consumeDeclSpecToken(); $EndResolve
+ $Builder consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+
+identifier_or_typedefname
+ ::= 'identifier'
+ | 'TypedefName'
+ | 'Completion'
+
+
+struct_or_union_specifier
+ ::= 'struct' '{' <openscope-ast> struct_declaration_list_opt '}'
+ /. $Build consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_struct); $EndBuild ./
+ | 'union' '{' <openscope-ast> struct_declaration_list_opt '}'
+ /. $Build consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_union); $EndBuild ./
+ | 'struct' identifier_or_typedefname '{' <openscope-ast> struct_declaration_list_opt '}'
+ /. $Build consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_struct); $EndBuild ./
+ | 'union' identifier_or_typedefname '{' <openscope-ast> struct_declaration_list_opt '}'
+ /. $Build consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_union); $EndBuild ./
+
+
+elaborated_specifier
+ ::= 'struct' identifier_or_typedefname
+ /. $Build consumeTypeSpecifierElaborated(IASTCompositeTypeSpecifier.k_struct); $EndBuild ./
+ | 'union' identifier_or_typedefname
+ /. $Build consumeTypeSpecifierElaborated(IASTCompositeTypeSpecifier.k_union); $EndBuild ./
+ | 'enum' identifier_or_typedefname
+ /. $Build consumeTypeSpecifierElaborated(IASTElaboratedTypeSpecifier.k_enum); $EndBuild ./
+
+
+struct_declaration_list_opt
+ ::= struct_declaration_list
+ | $empty
+
+struct_declaration_list
+ ::= struct_declaration
+ | struct_declaration_list struct_declaration
+
+
+struct_declaration
+ ::= specifier_qualifier_list <openscope-ast> struct_declarator_list ';' -- regular declarators plus bit fields
+ /.
+ $Action
+ $Resolve closeDeclarationScope(); $EndResolve
+ $Builder consumeStructDeclaration(true); $EndBuilder
+ $EndAction
+ ./
+ | specifier_qualifier_list ';'
+ /.
+ $Action
+ $Resolve closeDeclarationScope(); $EndResolve
+ $Builder consumeStructDeclaration(false); $EndBuilder
+ $EndAction
+ ./
+
+
+-- just reuse declaration_specifiers, makes grammar a bit more lenient but thats OK
+specifier_qualifier_list
+ ::= declaration_specifiers
+
+
+struct_declarator_list
+ ::= complete_struct_declarator
+ | struct_declarator_list ',' complete_struct_declarator
+
+
+complete_struct_declarator
+ ::= struct_declarator
+ /.
+ $Action
+ $Resolve consumeDeclaratorCompleteField(); $EndResolve
+ $EndAction
+ ./
+
+
+struct_declarator
+ ::= declarator
+ | ':' constant_expression
+ /. $Build consumeStructBitField(false); $EndBuild ./
+ | declarator ':' constant_expression
+ /. $Build consumeStructBitField(true); $EndBuild ./
+
+
+enum_specifier
+ ::= 'enum' '{' <openscope-ast> enumerator_list_opt comma_opt '}'
+ /. $Build consumeTypeSpecifierEnumeration(false); $EndBuild ./
+ | 'enum' identifier_or_typedefname '{' <openscope-ast> enumerator_list_opt comma_opt '}'
+ /. $Build consumeTypeSpecifierEnumeration(true); $EndBuild ./
+
+
+enumerator_list_opt
+ ::= enumerator_list
+ | $empty
+
+
+enumerator_list
+ ::= enumerator
+ | enumerator_list ',' enumerator
+
+
+enumerator
+ ::= identifier_or_typedefname
+ /. $Build consumeEnumerator(false); $EndBuild ./
+ | identifier_or_typedefname '=' constant_expression
+ /. $Build consumeEnumerator(true); $EndBuild ./
+
+
+type_qualifier
+ ::= type_qualifier_token
+ /.
+ $Action
+ $Resolve consumeDeclSpecToken(); $EndResolve
+ $Builder consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+
+type_qualifier_token
+ ::= 'const'
+ | 'restrict'
+ | 'volatile'
+
+
+function_specifier
+ ::= 'inline'
+ /.$Action
+ $Resolve consumeDeclSpecToken(); $EndResolve
+ $Builder consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+
+declarator
+ ::= direct_declarator
+ | <openscope-ast> pointer direct_declarator
+ /. $Build consumeDeclaratorWithPointer(true); $EndBuild ./
+
+
+direct_declarator
+ ::= array_direct_declarator
+ | function_prototype_direct_declarator
+ | basic_direct_declarator
+ | knr_direct_declarator
+
+
+basic_direct_declarator
+ ::= declarator_id_name
+ /.
+ $Action
+ $Resolve consumeDirectDeclaratorIdentifier(); $EndResolve
+ $Builder consumeDirectDeclaratorIdentifier(); $EndBuilder
+ $EndAction
+ ./
+ | '(' declarator ')'
+ /. $Build consumeDirectDeclaratorBracketed(); $EndBuild ./
+
+
+declarator_id_name
+ ::= 'identifier'
+ /. $Build consumeIdentifierName(); $EndBuild ./
+
+
+array_direct_declarator
+ ::= basic_direct_declarator array_modifier
+ /. $Build consumeDirectDeclaratorArrayDeclarator(); $EndBuild ./
+ | array_direct_declarator array_modifier
+ /. $Build consumeDirectDeclaratorArrayDeclarator(); $EndBuild ./
+
+
+function_prototype_direct_declarator
+ ::= function_direct_declarator
+ /.$Action $Resolve closeSymbolScope(); $EndResolve $EndAction./
+
+
+function_direct_declarator
+ ::= basic_direct_declarator '(' <openscope-symbol> <openscope-ast> parameter_type_list ')'
+ /. $Build consumeDirectDeclaratorFunctionDeclarator(true); $EndBuild ./
+ | basic_direct_declarator '(' <openscope-symbol> ')'
+ /. $Build consumeDirectDeclaratorFunctionDeclarator(false); $EndBuild ./
+
+
+function_declarator
+ ::= function_direct_declarator
+ | <openscope-ast> pointer function_direct_declarator
+ /. $Build consumeDeclaratorWithPointer(true); $EndBuild ./
+
+
+-- This is a hack because the parser cannot tell the difference between
+-- plain identifiers and types. Because of this an identifier_list would
+-- always be parsed as a parameter_type_list instead. In a KnR funciton
+-- definition we can use the extra list of declarators to disambiguate.
+-- This rule should be merged back into direct_declarator if type info is
+-- added to the parser.
+
+knr_direct_declarator
+ ::= basic_direct_declarator '(' <openscope-symbol> <openscope-ast> identifier_list ')'
+ /. $Build consumeDirectDeclaratorFunctionDeclaratorKnR(); $EndBuild ./
+
+
+knr_function_declarator
+ ::= knr_direct_declarator
+ | <openscope-ast> pointer knr_direct_declarator
+ /. $Build consumeDeclaratorWithPointer(true); $EndBuild ./
+
+
+identifier_list
+ ::= 'identifier'
+ /. $Build consumeIdentifierKnR(); $EndBuild ./
+ | identifier_list ',' 'identifier'
+ /. $Build consumeIdentifierKnR(); $EndBuild ./
+
+
+array_modifier
+ ::= '[' ']'
+ /. $Build consumeDirectDeclaratorArrayModifier(false); $EndBuild ./
+ | '[' <openscope-ast> array_modifier_type_qualifiers ']'
+ /. $Build consumeDirectDeclaratorModifiedArrayModifier(false, false, true, false); $EndBuild ./
+ | '[' assignment_expression ']'
+ /. $Build consumeDirectDeclaratorArrayModifier(true); $EndBuild ./
+ | '[' <openscope-ast> array_modifier_type_qualifiers assignment_expression ']'
+ /. $Build consumeDirectDeclaratorModifiedArrayModifier(false, false, true, true); $EndBuild ./
+ | '[' 'static' assignment_expression ']'
+ /. $Build consumeDirectDeclaratorModifiedArrayModifier(true, false, false, true); $EndBuild ./
+ | '[' 'static' <openscope-ast> array_modifier_type_qualifiers assignment_expression ']'
+ /. $Build consumeDirectDeclaratorModifiedArrayModifier(true, false, true, true); $EndBuild ./
+ | '[' <openscope-ast> array_modifier_type_qualifiers 'static' assignment_expression ']'
+ /. $Build consumeDirectDeclaratorModifiedArrayModifier(true, false, true, true); $EndBuild ./
+ | '[' '*' ']'
+ /. $Build consumeDirectDeclaratorModifiedArrayModifier(false, true, false, false); $EndBuild ./
+ | '[' <openscope-ast> array_modifier_type_qualifiers '*' ']'
+ /. $Build consumeDirectDeclaratorModifiedArrayModifier(false, true, true, false); $EndBuild ./
+
+
+array_modifier_type_qualifiers
+ ::= type_qualifier_list
+
+
+pointer
+ ::= '*'
+ /. $Build consumePointer(); $EndBuild ./
+ | pointer '*'
+ /. $Build consumePointer(); $EndBuild ./
+ | '*' <openscope-ast> type_qualifier_list
+ /. $Build consumePointerTypeQualifierList(); $EndBuild ./
+ | pointer '*' <openscope-ast> type_qualifier_list
+ /. $Build consumePointerTypeQualifierList(); $EndBuild ./
+
+
+type_qualifier_list
+ ::= type_qualifier
+ | type_qualifier_list type_qualifier
+
+
+parameter_type_list
+ ::= parameter_list
+ /. $Build consumeEmpty(); $EndBuild ./
+ | parameter_list ',' '...'
+ /. $Build consumePlaceHolder(); $EndBuild ./
+ | '...' -- not spec
+ /. $Build consumePlaceHolder(); $EndBuild ./
+
+
+parameter_list
+ ::= parameter_declaration
+ | parameter_list ',' parameter_declaration
+
+
+parameter_declaration
+ ::= declaration_specifiers complete_parameter_declarator
+ /. $Build consumeParameterDeclaration(); $EndBuild ./
+ | declaration_specifiers
+ /.
+ $Action
+ $Resolve consumeParameterDeclarationWithoutDeclarator(); $EndResolve
+ $Builder consumeParameterDeclarationWithoutDeclarator(); $EndBuilder
+ $EndAction
+ ./
+
+
+complete_parameter_declarator
+ ::= declarator
+ /.
+ $Action
+ $Resolve consumeDeclaratorCompleteParameter(); $EndResolve
+ $EndAction
+ ./
+ | abstract_declarator
+ /.
+ $Action
+ $Resolve consumeDeclaratorCompleteParameter(); $EndResolve
+ $EndAction
+ ./
+
+
+-- only used in expressions, eg) sizeof, casts etc...
+type_name
+ ::= specifier_qualifier_list
+ /.
+ $Action
+ $Resolve consumeTypeId(); $EndResolve
+ $Builder consumeTypeId(false); $EndBuilder
+ $EndAction
+ ./
+ | specifier_qualifier_list abstract_declarator
+ /.
+ $Action
+ $Resolve consumeTypeId(); $EndResolve
+ $Builder consumeTypeId(true); $EndBuilder
+ $EndAction
+ ./
+
+
+abstract_declarator -- a declarator that does not include an identifier
+ ::= direct_abstract_declarator
+ | <openscope-ast> pointer
+ /. $Build consumeDeclaratorWithPointer(false); $EndBuild ./
+ | <openscope-ast> pointer direct_abstract_declarator
+ /. $Build consumeDeclaratorWithPointer(true); $EndBuild ./
+
+
+-- rewritten to use the more general array_modifier rule
+direct_abstract_declarator
+ ::= '(' abstract_declarator ')'
+ /. $Build consumeDirectDeclaratorBracketed(); $EndBuild ./
+ | array_modifier
+ /. $Build consumeAbstractDeclaratorArrayModifier(false); $EndBuild ./
+ | direct_abstract_declarator array_modifier
+ /. $Build consumeAbstractDeclaratorArrayModifier(true); $EndBuild ./
+ | '(' ')'
+ /. $Build consumeAbstractDeclaratorFunctionDeclarator(false, false); $EndBuild ./
+ | direct_abstract_declarator '(' ')'
+ /. $Build consumeAbstractDeclaratorFunctionDeclarator(true, false); $EndBuild ./
+ | '(' <openscope-ast> parameter_type_list ')'
+ /. $Build consumeAbstractDeclaratorFunctionDeclarator(false, true); $EndBuild ./
+ | direct_abstract_declarator '(' <openscope-ast> parameter_type_list ')'
+ /. $Build consumeAbstractDeclaratorFunctionDeclarator(true, true); $EndBuild ./
+
+
+
+initializer
+ ::= assignment_expression
+ /. $Build consumeInitializer(); $EndBuild ./
+ | '{' <openscope-ast> initializer_list comma_opt '}'
+ /. $Build consumeInitializerList(); $EndBuild ./
+
+initializer_list
+ ::= initializer
+ | designated_initializer
+ | initializer_list ',' initializer
+ | initializer_list ',' designated_initializer
+
+
+designated_initializer
+ ::= <openscope-ast> designation '=' initializer
+ /. $Build consumeInitializerDesignated(); $EndBuild ./
+
+
+designation
+ ::= designator_list
+
+
+designator_list
+ ::= designator_base
+ | designator_list designator
+
+
+designator_base
+ ::= '[' constant_expression ']'
+ /. $Build consumeDesignatorArray(); $EndBuild ./
+ | '.' identifier_or_typedefname
+ /. $Build consumeDesignatorField(); $EndBuild ./
+
+designator
+ ::= '[' constant_expression ']'
+ /. $Build consumeDesignatorArray(); $EndBuild ./
+ | '.' identifier_or_typedefname
+ /. $Build consumeDesignatorField(); $EndBuild ./
+
+
+-------------------------------------------------------------------------------------------
+-- External Definitions
+-------------------------------------------------------------------------------------------
+
+translation_unit
+ ::= external_declaration_list
+ /. $Build consumeTranslationUnit(); $EndBuild ./
+ | $empty
+ /. $Build consumeTranslationUnit(); $EndBuild ./
+
+
+external_declaration_list
+ ::= external_declaration
+ | external_declaration_list external_declaration
+
+
+external_declaration
+ ::= function_definition
+ | declaration
+ | ';'
+ /. $Build consumeDeclarationEmpty(); $EndBuild ./
+ | ERROR_TOKEN
+ /. $Build consumeDeclarationProblem(); $EndBuild ./
+
+
+-- Used by KnR
+declaration_list
+ ::= declaration
+ | declaration_list declaration
+
+
+-- The extra <openscope-ast> nonterminal before declarator in this rule is only there
+-- to avoid a shift/reduce error with the rule for declaration.
+-- The symbol table scoped is opened in the rule for function_direct_declarator
+function_definition
+ ::= declaration_specifiers <openscope-ast> function_declarator function_body
+ /.
+ $Action
+ $Resolve consumeFunctionDefinition(); $EndResolve
+ $Builder consumeFunctionDefinition(true); $EndBuilder
+ $EndAction
+ ./
+
+ -- this rule is here as a special case (its not C99 spec) just to support implicit int in function definitions
+ | <openscope-declaration> <openscope-ast> function_declarator function_body
+ /.
+ $Action
+ $Resolve consumeFunctionDefinition(); $EndResolve
+ $Builder consumeFunctionDefinition(false); $EndBuilder
+ $EndAction
+ ./
+
+ | declaration_specifiers <openscope-ast> knr_function_declarator <openscope-ast> declaration_list compound_statement
+ /.
+ $Action
+ $Resolve consumeFunctionDefinition(); $EndResolve
+ $Builder consumeFunctionDefinitionKnR(); $EndBuilder
+ $EndAction
+ ./
+
+
+-- same syntax as compound_statement but a symbol table scope isn't opened
+function_body
+ ::= '{' '}'
+ /. $Build consumeStatementCompoundStatement(false); $EndBuild ./
+ | '{' <openscope-ast> block_item_list '}'
+ /. $Build consumeStatementCompoundStatement(true); $EndBuild ./
+
+$End
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.java
new file mode 100644
index 00000000000..8ad4d7b4527
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.java
@@ -0,0 +1,2429 @@
+/*******************************************************************************
+* Copyright (c) 2006, 2008 IBM Corporation and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* IBM Corporation - initial API and implementation
+*********************************************************************************/
+
+// This file was generated by LPG
+
+package org.eclipse.cdt.internal.core.dom.lrparser.c99;
+
+
+import lpg.lpgjavaruntime.*;
+import org.eclipse.cdt.core.dom.lrparser.lpgextensions.ITrialUndoActionProvider;
+import org.eclipse.cdt.core.dom.lrparser.lpgextensions.AbstractTrialUndoActionProvider;
+import org.eclipse.cdt.core.dom.lrparser.lpgextensions.TrialUndoParser;
+
+import java.util.*;
+
+import org.eclipse.cdt.core.dom.ast.*;
+import org.eclipse.cdt.core.dom.lrparser.IParser;
+import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+import org.eclipse.cdt.core.dom.lrparser.action.c99.C99ASTNodeFactory;
+import org.eclipse.cdt.core.dom.lrparser.action.c99.C99BuildASTParserAction;
+import org.eclipse.cdt.core.dom.lrparser.action.c99.C99TypedefTrackerParserAction;
+import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.IC99Scope;
+import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+
+public class C99Parser extends AbstractTrialUndoActionProvider< C99ParserAction , Object > implements IParserActionTokenProvider, IParser {
+ private static ParseTable prs = new C99Parserprs();
+ protected static final Action< C99ParserAction , Object >[] RULE_ACTIONS;
+
+ {
+ ruleAction = RULE_ACTIONS;
+ }
+
+ public C99Parser(LexStream lexStream) {
+ super(lexStream);
+
+ try {
+ super.remapTerminalSymbols(orderedTerminalSymbols(), C99Parserprs.EOFT_SYMBOL);
+ } catch (NullExportedSymbolsException e) {
+ } catch (NullTerminalSymbolsException e) {
+ } catch (UnimplementedTerminalsException e) {
+ java.util.ArrayList unimplemented_symbols = e.getSymbols();
+ System.out.println("The Lexer will not scan the following token(s):");
+ for (int i = 0; i < unimplemented_symbols.size(); i++) {
+ Integer id = (Integer) unimplemented_symbols.get(i);
+ System.out.println(" " + C99Parsersym.orderedTerminalSymbols[id.intValue()]);
+ }
+ System.out.println();
+ } catch (UndefinedEofSymbolException e) {
+ throw new Error(new UndefinedEofSymbolException("The Lexer does not implement the Eof symbol " + C99Parsersym.orderedTerminalSymbols[C99Parserprs.EOFT_SYMBOL]));
+ }
+ }
+
+
+ public C99Parser() { // constructor
+ // this(new C99Lexer ());
+ }
+
+ public String[] orderedTerminalSymbols() {
+ return C99Parsersym.orderedTerminalSymbols;
+ }
+
+ public String getTokenKindName(int kind) {
+ return C99Parsersym.orderedTerminalSymbols[kind];
+ }
+
+ public int getEOFTokenKind() {
+ return C99Parserprs.EOFT_SYMBOL;
+ }
+
+ public PrsStream getParseStream() {
+ return (PrsStream) this;
+ }
+
+ //
+ // Report error message for given error_token.
+ //
+ public final void reportErrorTokenMessage(int error_token, String msg) {
+ int firsttok = super.getFirstRealToken(error_token), lasttok = super.getLastRealToken(error_token);
+ String location = super.getFileName() + ':' +
+ (firsttok > lasttok
+ ? (super.getEndLine(lasttok) + ":" + super.getEndColumn(lasttok))
+ : (super.getLine(error_token) + ":" +
+ super.getColumn(error_token) + ":" +
+ super.getEndLine(error_token) + ":" +
+ super.getEndColumn(error_token))) + ": ";
+ super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
+ }
+
+ public Object parser() {
+ return parser(null, 0);
+ }
+
+ public Object parser(Monitor monitor) {
+ return parser(monitor, 0);
+ }
+
+ public Object parser(int error_repair_count) {
+ return parser(null, error_repair_count);
+ }
+
+ public Object parser(Monitor monitor, int error_repair_count) {
+ try {
+ btParser = new TrialUndoParser((TokenStream) this, prs, (ITrialUndoActionProvider< Object >) this);
+ } catch (NotBacktrackParseTableException e) {
+ throw new Error(new NotBacktrackParseTableException("Regenerate C99Parserprs.java with -BACKTRACK option"));
+ } catch (BadParseSymFileException e) {
+ throw new Error(new BadParseSymFileException("Bad Parser Symbol File -- C99Parsersym.java"));
+ }
+
+ try {
+ Object result = (Object) btParser.parse(error_repair_count);
+ btParser.commit();
+ return result;
+ } catch (BadParseException e) {
+ reset(e.error_token); // point to error token
+
+ //DiagnoseParser diagnoseParser = new DiagnoseParser((TokenStream) this, prs);
+ //diagnoseParser.diagnose(e.error_token);
+ }
+
+ return null;
+ }
+
+
+private C99ParserAction action;
+
+private void initActions(IASTTranslationUnit tu) {
+ // binding resolution actions need access to IASTName nodes, temporary
+ action = new C99ParserAction ();
+ action.resolver = new C99TypedefTrackerParserAction (this);
+ action.builder = new C99BuildASTParserAction ( C99ASTNodeFactory.DEFAULT_INSTANCE , this, tu);
+ action.builder.setTokenMap(C99Parsersym.orderedTerminalSymbols);
+ setParserAction(action);
+}
+
+
+public void addToken(IToken token) {
+ token.setKind(mapKind(token.getKind()));
+ super.addToken(token);
+}
+
+
+public IASTCompletionNode parse(IASTTranslationUnit tu) {
+ // this has to be done, or... kaboom!
+ setStreamLength(getSize());
+ initActions(tu);
+
+ final int errorRepairCount = -1; // -1 means full error handling
+ parser(null, errorRepairCount); // do the actual parse
+ super.resetTokenStream(); // allow tokens to be garbage collected
+
+ // the completion node may be null
+ IASTCompletionNode compNode = action.builder.getASTCompletionNode();
+
+ action = null;
+ parserAction = null;
+ return compNode;
+}
+
+
+public int getKind(int i) {
+ int kind = super.getKind(i);
+ // lexer feedback hack!
+ if(kind == C99Parsersym.TK_identifier && action.resolver.isTypedef(getTokenText(i))) {
+ kind = C99Parsersym.TK_TypedefName;
+ }
+ return kind;
+}
+
+
+
+ //
+ // Initialize ruleAction array.
+ //
+ static {
+ RULE_ACTIONS = new Action[305 + 1];
+ RULE_ACTIONS[0] = null;
+
+ RULE_ACTIONS[1] = new Action1();
+ RULE_ACTIONS[2] = new Action2();
+ RULE_ACTIONS[3] = new Action3();
+ RULE_ACTIONS[12] = new Action12();
+ RULE_ACTIONS[13] = new Action13();
+ RULE_ACTIONS[14] = new Action14();
+ RULE_ACTIONS[15] = new Action15();
+ RULE_ACTIONS[17] = new Action17();
+ RULE_ACTIONS[18] = new Action18();
+ RULE_ACTIONS[22] = new Action22();
+ RULE_ACTIONS[23] = new Action23();
+ RULE_ACTIONS[24] = new Action24();
+ RULE_ACTIONS[25] = new Action25();
+ RULE_ACTIONS[26] = new Action26();
+ RULE_ACTIONS[27] = new Action27();
+ RULE_ACTIONS[28] = new Action28();
+ RULE_ACTIONS[35] = new Action35();
+ RULE_ACTIONS[36] = new Action36();
+ RULE_ACTIONS[37] = new Action37();
+ RULE_ACTIONS[38] = new Action38();
+ RULE_ACTIONS[39] = new Action39();
+ RULE_ACTIONS[40] = new Action40();
+ RULE_ACTIONS[41] = new Action41();
+ RULE_ACTIONS[42] = new Action42();
+ RULE_ACTIONS[43] = new Action43();
+ RULE_ACTIONS[44] = new Action44();
+ RULE_ACTIONS[46] = new Action46();
+ RULE_ACTIONS[48] = new Action48();
+ RULE_ACTIONS[49] = new Action49();
+ RULE_ACTIONS[50] = new Action50();
+ RULE_ACTIONS[52] = new Action52();
+ RULE_ACTIONS[53] = new Action53();
+ RULE_ACTIONS[55] = new Action55();
+ RULE_ACTIONS[56] = new Action56();
+ RULE_ACTIONS[58] = new Action58();
+ RULE_ACTIONS[59] = new Action59();
+ RULE_ACTIONS[60] = new Action60();
+ RULE_ACTIONS[61] = new Action61();
+ RULE_ACTIONS[63] = new Action63();
+ RULE_ACTIONS[64] = new Action64();
+ RULE_ACTIONS[66] = new Action66();
+ RULE_ACTIONS[68] = new Action68();
+ RULE_ACTIONS[70] = new Action70();
+ RULE_ACTIONS[72] = new Action72();
+ RULE_ACTIONS[74] = new Action74();
+ RULE_ACTIONS[76] = new Action76();
+ RULE_ACTIONS[78] = new Action78();
+ RULE_ACTIONS[79] = new Action79();
+ RULE_ACTIONS[80] = new Action80();
+ RULE_ACTIONS[81] = new Action81();
+ RULE_ACTIONS[82] = new Action82();
+ RULE_ACTIONS[83] = new Action83();
+ RULE_ACTIONS[84] = new Action84();
+ RULE_ACTIONS[85] = new Action85();
+ RULE_ACTIONS[86] = new Action86();
+ RULE_ACTIONS[87] = new Action87();
+ RULE_ACTIONS[88] = new Action88();
+ RULE_ACTIONS[91] = new Action91();
+ RULE_ACTIONS[93] = new Action93();
+ RULE_ACTIONS[103] = new Action103();
+ RULE_ACTIONS[104] = new Action104();
+ RULE_ACTIONS[105] = new Action105();
+ RULE_ACTIONS[106] = new Action106();
+ RULE_ACTIONS[107] = new Action107();
+ RULE_ACTIONS[108] = new Action108();
+ RULE_ACTIONS[112] = new Action112();
+ RULE_ACTIONS[113] = new Action113();
+ RULE_ACTIONS[114] = new Action114();
+ RULE_ACTIONS[115] = new Action115();
+ RULE_ACTIONS[116] = new Action116();
+ RULE_ACTIONS[117] = new Action117();
+ RULE_ACTIONS[119] = new Action119();
+ RULE_ACTIONS[120] = new Action120();
+ RULE_ACTIONS[121] = new Action121();
+ RULE_ACTIONS[122] = new Action122();
+ RULE_ACTIONS[123] = new Action123();
+ RULE_ACTIONS[124] = new Action124();
+ RULE_ACTIONS[125] = new Action125();
+ RULE_ACTIONS[126] = new Action126();
+ RULE_ACTIONS[127] = new Action127();
+ RULE_ACTIONS[128] = new Action128();
+ RULE_ACTIONS[129] = new Action129();
+ RULE_ACTIONS[130] = new Action130();
+ RULE_ACTIONS[131] = new Action131();
+ RULE_ACTIONS[132] = new Action132();
+ RULE_ACTIONS[133] = new Action133();
+ RULE_ACTIONS[134] = new Action134();
+ RULE_ACTIONS[135] = new Action135();
+ RULE_ACTIONS[160] = new Action160();
+ RULE_ACTIONS[161] = new Action161();
+ RULE_ACTIONS[162] = new Action162();
+ RULE_ACTIONS[168] = new Action168();
+ RULE_ACTIONS[181] = new Action181();
+ RULE_ACTIONS[182] = new Action182();
+ RULE_ACTIONS[186] = new Action186();
+ RULE_ACTIONS[187] = new Action187();
+ RULE_ACTIONS[188] = new Action188();
+ RULE_ACTIONS[189] = new Action189();
+ RULE_ACTIONS[190] = new Action190();
+ RULE_ACTIONS[191] = new Action191();
+ RULE_ACTIONS[192] = new Action192();
+ RULE_ACTIONS[197] = new Action197();
+ RULE_ACTIONS[198] = new Action198();
+ RULE_ACTIONS[202] = new Action202();
+ RULE_ACTIONS[204] = new Action204();
+ RULE_ACTIONS[205] = new Action205();
+ RULE_ACTIONS[206] = new Action206();
+ RULE_ACTIONS[207] = new Action207();
+ RULE_ACTIONS[212] = new Action212();
+ RULE_ACTIONS[213] = new Action213();
+ RULE_ACTIONS[214] = new Action214();
+ RULE_ACTIONS[218] = new Action218();
+ RULE_ACTIONS[220] = new Action220();
+ RULE_ACTIONS[225] = new Action225();
+ RULE_ACTIONS[226] = new Action226();
+ RULE_ACTIONS[227] = new Action227();
+ RULE_ACTIONS[228] = new Action228();
+ RULE_ACTIONS[229] = new Action229();
+ RULE_ACTIONS[230] = new Action230();
+ RULE_ACTIONS[231] = new Action231();
+ RULE_ACTIONS[232] = new Action232();
+ RULE_ACTIONS[234] = new Action234();
+ RULE_ACTIONS[235] = new Action235();
+ RULE_ACTIONS[237] = new Action237();
+ RULE_ACTIONS[238] = new Action238();
+ RULE_ACTIONS[239] = new Action239();
+ RULE_ACTIONS[240] = new Action240();
+ RULE_ACTIONS[241] = new Action241();
+ RULE_ACTIONS[242] = new Action242();
+ RULE_ACTIONS[243] = new Action243();
+ RULE_ACTIONS[244] = new Action244();
+ RULE_ACTIONS[245] = new Action245();
+ RULE_ACTIONS[246] = new Action246();
+ RULE_ACTIONS[247] = new Action247();
+ RULE_ACTIONS[248] = new Action248();
+ RULE_ACTIONS[250] = new Action250();
+ RULE_ACTIONS[251] = new Action251();
+ RULE_ACTIONS[252] = new Action252();
+ RULE_ACTIONS[253] = new Action253();
+ RULE_ACTIONS[256] = new Action256();
+ RULE_ACTIONS[257] = new Action257();
+ RULE_ACTIONS[258] = new Action258();
+ RULE_ACTIONS[261] = new Action261();
+ RULE_ACTIONS[262] = new Action262();
+ RULE_ACTIONS[263] = new Action263();
+ RULE_ACTIONS[264] = new Action264();
+ RULE_ACTIONS[265] = new Action265();
+ RULE_ACTIONS[266] = new Action266();
+ RULE_ACTIONS[268] = new Action268();
+ RULE_ACTIONS[269] = new Action269();
+ RULE_ACTIONS[270] = new Action270();
+ RULE_ACTIONS[271] = new Action271();
+ RULE_ACTIONS[272] = new Action272();
+ RULE_ACTIONS[273] = new Action273();
+ RULE_ACTIONS[274] = new Action274();
+ RULE_ACTIONS[275] = new Action275();
+ RULE_ACTIONS[276] = new Action276();
+ RULE_ACTIONS[277] = new Action277();
+ RULE_ACTIONS[278] = new Action278();
+ RULE_ACTIONS[283] = new Action283();
+ RULE_ACTIONS[287] = new Action287();
+ RULE_ACTIONS[288] = new Action288();
+ RULE_ACTIONS[289] = new Action289();
+ RULE_ACTIONS[290] = new Action290();
+ RULE_ACTIONS[291] = new Action291();
+ RULE_ACTIONS[292] = new Action292();
+ RULE_ACTIONS[297] = new Action297();
+ RULE_ACTIONS[298] = new Action298();
+ RULE_ACTIONS[301] = new Action301();
+ RULE_ACTIONS[302] = new Action302();
+ RULE_ACTIONS[303] = new Action303();
+ RULE_ACTIONS[304] = new Action304();
+ RULE_ACTIONS[305] = new Action305();
+
+
+ //
+ // Make sure that all elements of ruleAction are properly initialized
+ //
+ for (int i = 0; i < RULE_ACTIONS.length; i++) {
+ if (RULE_ACTIONS[i] == null) {
+ RULE_ACTIONS[i] = emptyAction();
+ }
+ }
+ }
+
+ //
+ // Rule 1: <openscope-ast> ::= $Empty
+ //
+ static final class Action1 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ openASTScope(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 2: <openscope-symbol> ::= $Empty
+ //
+ static final class Action2 extends DeclaredAction< C99ParserAction , Object > {
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ openSymbolScope();
+ return hasUndo;
+ }
+
+ public Action2() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+ }
+
+ //
+ // Rule 3: <openscope-declaration> ::= $Empty
+ //
+ static final class Action3 extends DeclaredAction< C99ParserAction , Object > {
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ openDeclarationScope();
+ return hasUndo;
+ }
+
+ public Action3() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+ }
+
+ //
+ // Rule 12: literal ::= integer
+ //
+ static final class Action12 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionLiteral(IASTLiteralExpression.lk_integer_constant); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 13: literal ::= floating
+ //
+ static final class Action13 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionLiteral(IASTLiteralExpression.lk_float_constant); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 14: literal ::= charconst
+ //
+ static final class Action14 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionLiteral(IASTLiteralExpression.lk_char_constant); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 15: literal ::= stringlit
+ //
+ static final class Action15 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionLiteral(IASTLiteralExpression.lk_string_literal); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 17: primary_expression ::= primary_expression_id
+ //
+ static final class Action17 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionID(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 18: primary_expression ::= ( expression )
+ //
+ static final class Action18 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBracketed(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 22: postfix_expression ::= postfix_expression [ expression ]
+ //
+ static final class Action22 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionArraySubscript(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 23: postfix_expression ::= postfix_expression ( expression_list_opt )
+ //
+ static final class Action23 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionFunctionCall(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 24: postfix_expression ::= postfix_expression . member_name
+ //
+ static final class Action24 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionFieldReference(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 25: postfix_expression ::= postfix_expression -> member_name
+ //
+ static final class Action25 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionFieldReference(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 26: postfix_expression ::= postfix_expression ++
+ //
+ static final class Action26 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixIncr); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 27: postfix_expression ::= postfix_expression --
+ //
+ static final class Action27 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixDecr); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 28: postfix_expression ::= ( type_name ) { <openscope-ast> initializer_list comma_opt }
+ //
+ static final class Action28 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionTypeIdInitializer(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 35: unary_expression ::= ++ unary_expression
+ //
+ static final class Action35 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixIncr); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 36: unary_expression ::= -- unary_expression
+ //
+ static final class Action36 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixDecr); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 37: unary_expression ::= & cast_expression
+ //
+ static final class Action37 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_amper); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 38: unary_expression ::= * cast_expression
+ //
+ static final class Action38 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_star); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 39: unary_expression ::= + cast_expression
+ //
+ static final class Action39 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_plus); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 40: unary_expression ::= - cast_expression
+ //
+ static final class Action40 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_minus); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 41: unary_expression ::= ~ cast_expression
+ //
+ static final class Action41 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_tilde); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 42: unary_expression ::= ! cast_expression
+ //
+ static final class Action42 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_not); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 43: unary_expression ::= sizeof unary_expression
+ //
+ static final class Action43 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_sizeof); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 44: unary_expression ::= sizeof ( type_name )
+ //
+ static final class Action44 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionTypeId(IASTTypeIdExpression.op_sizeof); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 46: cast_expression ::= ( type_name ) cast_expression
+ //
+ static final class Action46 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionCast(IASTCastExpression.op_cast); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 48: multiplicative_expression ::= multiplicative_expression * cast_expression
+ //
+ static final class Action48 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiply); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 49: multiplicative_expression ::= multiplicative_expression / cast_expression
+ //
+ static final class Action49 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_divide); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 50: multiplicative_expression ::= multiplicative_expression % cast_expression
+ //
+ static final class Action50 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_modulo); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 52: additive_expression ::= additive_expression + multiplicative_expression
+ //
+ static final class Action52 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_plus); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 53: additive_expression ::= additive_expression - multiplicative_expression
+ //
+ static final class Action53 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_minus); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 55: shift_expression ::= shift_expression << additive_expression
+ //
+ static final class Action55 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeft); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 56: shift_expression ::= shift_expression >> additive_expression
+ //
+ static final class Action56 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRight); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 58: relational_expression ::= relational_expression < shift_expression
+ //
+ static final class Action58 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessThan); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 59: relational_expression ::= relational_expression > shift_expression
+ //
+ static final class Action59 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterThan); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 60: relational_expression ::= relational_expression <= shift_expression
+ //
+ static final class Action60 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessEqual); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 61: relational_expression ::= relational_expression >= shift_expression
+ //
+ static final class Action61 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterEqual); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 63: equality_expression ::= equality_expression == relational_expression
+ //
+ static final class Action63 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_equals); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 64: equality_expression ::= equality_expression != relational_expression
+ //
+ static final class Action64 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_notequals); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 66: AND_expression ::= AND_expression & equality_expression
+ //
+ static final class Action66 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAnd); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 68: exclusive_OR_expression ::= exclusive_OR_expression ^ AND_expression
+ //
+ static final class Action68 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXor); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 70: inclusive_OR_expression ::= inclusive_OR_expression | exclusive_OR_expression
+ //
+ static final class Action70 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOr); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 72: logical_AND_expression ::= logical_AND_expression && inclusive_OR_expression
+ //
+ static final class Action72 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalAnd); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 74: logical_OR_expression ::= logical_OR_expression || logical_AND_expression
+ //
+ static final class Action74 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalOr); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 76: conditional_expression ::= logical_OR_expression ? expression : conditional_expression
+ //
+ static final class Action76 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionConditional(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 78: assignment_expression ::= unary_expression = assignment_expression
+ //
+ static final class Action78 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_assign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 79: assignment_expression ::= unary_expression *= assignment_expression
+ //
+ static final class Action79 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiplyAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 80: assignment_expression ::= unary_expression /= assignment_expression
+ //
+ static final class Action80 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_divideAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 81: assignment_expression ::= unary_expression %= assignment_expression
+ //
+ static final class Action81 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_moduloAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 82: assignment_expression ::= unary_expression += assignment_expression
+ //
+ static final class Action82 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_plusAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 83: assignment_expression ::= unary_expression -= assignment_expression
+ //
+ static final class Action83 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_minusAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 84: assignment_expression ::= unary_expression <<= assignment_expression
+ //
+ static final class Action84 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeftAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 85: assignment_expression ::= unary_expression >>= assignment_expression
+ //
+ static final class Action85 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRightAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 86: assignment_expression ::= unary_expression &= assignment_expression
+ //
+ static final class Action86 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAndAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 87: assignment_expression ::= unary_expression ^= assignment_expression
+ //
+ static final class Action87 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXorAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 88: assignment_expression ::= unary_expression |= assignment_expression
+ //
+ static final class Action88 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOrAssign); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 91: expression_list ::= <openscope-ast> expression_list_actual
+ //
+ static final class Action91 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeExpressionList(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 93: expression_list_opt ::= $Empty
+ //
+ static final class Action93 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeEmpty(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 103: statement ::= ERROR_TOKEN
+ //
+ static final class Action103 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementProblem(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 104: labeled_statement ::= identifier_or_typedefname : statement
+ //
+ static final class Action104 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementLabeled(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 105: labeled_statement ::= case constant_expression :
+ //
+ static final class Action105 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementCase(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 106: labeled_statement ::= default :
+ //
+ static final class Action106 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementDefault(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+
+ //
+ // Rule 107: compound_statement ::= <openscope-symbol> { }
+ //
+ static final class Action107 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ closeSymbolScope();
+ return hasUndo;
+ }
+
+ public Action107() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementCompoundStatement(false); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 108: compound_statement ::= <openscope-symbol> { <openscope-ast> block_item_list }
+ //
+ static final class Action108 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ closeSymbolScope();
+ return hasUndo;
+ }
+
+ public Action108() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementCompoundStatement(true); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+ //
+ // Rule 112: block_item ::= declaration
+ //
+ static final class Action112 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementDeclaration(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 113: expression_statement ::= ;
+ //
+ static final class Action113 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementNull(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 114: expression_statement ::= expression_in_statement ;
+ //
+ static final class Action114 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementExpression(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 115: selection_statement ::= if ( expression ) statement
+ //
+ static final class Action115 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementIf(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 116: selection_statement ::= if ( expression ) statement else statement
+ //
+ static final class Action116 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementIf(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 117: selection_statement ::= switch ( expression ) statement
+ //
+ static final class Action117 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementSwitch(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 119: expression_opt ::= $Empty
+ //
+ static final class Action119 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeEmpty(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 120: iteration_statement ::= do statement while ( expression ) ;
+ //
+ static final class Action120 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementDoLoop(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 121: iteration_statement ::= while ( expression ) statement
+ //
+ static final class Action121 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementWhileLoop(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+
+ //
+ // Rule 122: iteration_statement ::= <openscope-symbol> for ( expression_opt ; expression_opt ; expression_opt ) statement
+ //
+ static final class Action122 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ closeSymbolScope();
+ return hasUndo;
+ }
+
+ public Action122() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementForLoop(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 123: iteration_statement ::= <openscope-symbol> for ( declaration expression_opt ; expression_opt ) statement
+ //
+ static final class Action123 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ closeSymbolScope();
+ return hasUndo;
+ }
+
+ public Action123() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementForLoop(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+ //
+ // Rule 124: jump_statement ::= goto identifier_or_typedefname ;
+ //
+ static final class Action124 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementGoto(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 125: jump_statement ::= continue ;
+ //
+ static final class Action125 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementContinue(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 126: jump_statement ::= break ;
+ //
+ static final class Action126 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementBreak(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 127: jump_statement ::= return ;
+ //
+ static final class Action127 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementReturn(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 128: jump_statement ::= return expression ;
+ //
+ static final class Action128 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementReturn(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+
+ //
+ // Rule 129: declaration ::= declaration_specifiers ;
+ //
+ static final class Action129 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ closeDeclarationScope();
+ return hasUndo;
+ }
+
+ public Action129() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclarationSimple(false); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 130: declaration ::= declaration_specifiers <openscope-ast> init_declarator_list ;
+ //
+ static final class Action130 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ closeDeclarationScope();
+ return hasUndo;
+ }
+
+ public Action130() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclarationSimple(true); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+ //
+ // Rule 131: declaration_specifiers ::= <openscope-declaration> <openscope-ast> simple_declaration_specifiers
+ //
+ static final class Action131 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclarationSpecifiersSimple(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 132: declaration_specifiers ::= <openscope-declaration> <openscope-ast> struct_or_union_declaration_specifiers
+ //
+ static final class Action132 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclarationSpecifiersStructUnionEnum(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 133: declaration_specifiers ::= <openscope-declaration> <openscope-ast> elaborated_declaration_specifiers
+ //
+ static final class Action133 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclarationSpecifiersStructUnionEnum(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 134: declaration_specifiers ::= <openscope-declaration> <openscope-ast> enum_declaration_specifiers
+ //
+ static final class Action134 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclarationSpecifiersStructUnionEnum(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 135: declaration_specifiers ::= <openscope-declaration> <openscope-ast> typdef_name_declaration_specifiers
+ //
+ static final class Action135 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclarationSpecifiersTypedefName(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 160: init_declarator ::= complete_declarator = initializer
+ //
+ static final class Action160 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclaratorWithInitializer(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+
+ //
+ // Rule 161: complete_declarator ::= declarator
+ //
+ static final class Action161 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclaratorComplete();
+ return hasUndo;
+ }
+
+ public Action161() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ }
+
+
+ //
+ // Rule 162: storage_class_specifier ::= storage_class_specifier_token
+ //
+ static final class Action162 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclSpecToken();
+ return hasUndo;
+ }
+
+ public Action162() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclSpecToken(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 168: simple_type_specifier ::= simple_type_specifier_token
+ //
+ static final class Action168 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclSpecToken();
+ return hasUndo;
+ }
+
+ public Action168() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclSpecToken(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 181: typedef_name_in_declspec ::= TypedefName
+ //
+ static final class Action181 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclSpecToken();
+ return hasUndo;
+ }
+
+ public Action181() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclSpecToken(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 182: typedef_name_in_declspec ::= Completion
+ //
+ static final class Action182 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclSpecToken();
+ return hasUndo;
+ }
+
+ public Action182() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclSpecToken(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+ //
+ // Rule 186: struct_or_union_specifier ::= struct { <openscope-ast> struct_declaration_list_opt }
+ //
+ static final class Action186 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_struct); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 187: struct_or_union_specifier ::= union { <openscope-ast> struct_declaration_list_opt }
+ //
+ static final class Action187 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_union); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 188: struct_or_union_specifier ::= struct identifier_or_typedefname { <openscope-ast> struct_declaration_list_opt }
+ //
+ static final class Action188 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_struct); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 189: struct_or_union_specifier ::= union identifier_or_typedefname { <openscope-ast> struct_declaration_list_opt }
+ //
+ static final class Action189 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_union); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 190: elaborated_specifier ::= struct identifier_or_typedefname
+ //
+ static final class Action190 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeSpecifierElaborated(IASTCompositeTypeSpecifier.k_struct); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 191: elaborated_specifier ::= union identifier_or_typedefname
+ //
+ static final class Action191 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeSpecifierElaborated(IASTCompositeTypeSpecifier.k_union); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 192: elaborated_specifier ::= enum identifier_or_typedefname
+ //
+ static final class Action192 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeSpecifierElaborated(IASTElaboratedTypeSpecifier.k_enum); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+
+ //
+ // Rule 197: struct_declaration ::= specifier_qualifier_list <openscope-ast> struct_declarator_list ;
+ //
+ static final class Action197 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ closeDeclarationScope();
+ return hasUndo;
+ }
+
+ public Action197() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStructDeclaration(true); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 198: struct_declaration ::= specifier_qualifier_list ;
+ //
+ static final class Action198 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ closeDeclarationScope();
+ return hasUndo;
+ }
+
+ public Action198() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStructDeclaration(false); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 202: complete_struct_declarator ::= struct_declarator
+ //
+ static final class Action202 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclaratorCompleteField();
+ return hasUndo;
+ }
+
+ public Action202() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ }
+
+ //
+ // Rule 204: struct_declarator ::= : constant_expression
+ //
+ static final class Action204 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStructBitField(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 205: struct_declarator ::= declarator : constant_expression
+ //
+ static final class Action205 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStructBitField(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 206: enum_specifier ::= enum { <openscope-ast> enumerator_list_opt comma_opt }
+ //
+ static final class Action206 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeSpecifierEnumeration(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 207: enum_specifier ::= enum identifier_or_typedefname { <openscope-ast> enumerator_list_opt comma_opt }
+ //
+ static final class Action207 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeSpecifierEnumeration(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 212: enumerator ::= identifier_or_typedefname
+ //
+ static final class Action212 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeEnumerator(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 213: enumerator ::= identifier_or_typedefname = constant_expression
+ //
+ static final class Action213 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeEnumerator(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+
+ //
+ // Rule 214: type_qualifier ::= type_qualifier_token
+ //
+ static final class Action214 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclSpecToken();
+ return hasUndo;
+ }
+
+ public Action214() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclSpecToken(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+ //
+ // Rule 218: function_specifier ::= inline
+ //
+ static final class Action218 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclSpecToken();
+ return hasUndo;
+ }
+
+ public Action218() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclSpecToken(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+ //
+ // Rule 220: declarator ::= <openscope-ast> pointer direct_declarator
+ //
+ static final class Action220 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclaratorWithPointer(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+
+ //
+ // Rule 225: basic_direct_declarator ::= declarator_id_name
+ //
+ static final class Action225 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDirectDeclaratorIdentifier();
+ return hasUndo;
+ }
+
+ public Action225() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorIdentifier(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+ //
+ // Rule 226: basic_direct_declarator ::= ( declarator )
+ //
+ static final class Action226 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorBracketed(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 227: declarator_id_name ::= identifier
+ //
+ static final class Action227 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeIdentifierName(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 228: array_direct_declarator ::= basic_direct_declarator array_modifier
+ //
+ static final class Action228 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorArrayDeclarator(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 229: array_direct_declarator ::= array_direct_declarator array_modifier
+ //
+ static final class Action229 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorArrayDeclarator(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 230: function_prototype_direct_declarator ::= function_direct_declarator
+ //
+ static final class Action230 extends DeclaredAction< C99ParserAction , Object > {
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ closeSymbolScope();
+ return hasUndo;
+ }
+
+ public Action230() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+ }
+
+ //
+ // Rule 231: function_direct_declarator ::= basic_direct_declarator ( <openscope-symbol> <openscope-ast> parameter_type_list )
+ //
+ static final class Action231 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorFunctionDeclarator(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 232: function_direct_declarator ::= basic_direct_declarator ( <openscope-symbol> )
+ //
+ static final class Action232 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorFunctionDeclarator(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 234: function_declarator ::= <openscope-ast> pointer function_direct_declarator
+ //
+ static final class Action234 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclaratorWithPointer(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 235: knr_direct_declarator ::= basic_direct_declarator ( <openscope-symbol> <openscope-ast> identifier_list )
+ //
+ static final class Action235 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorFunctionDeclaratorKnR(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 237: knr_function_declarator ::= <openscope-ast> pointer knr_direct_declarator
+ //
+ static final class Action237 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclaratorWithPointer(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 238: identifier_list ::= identifier
+ //
+ static final class Action238 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeIdentifierKnR(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 239: identifier_list ::= identifier_list , identifier
+ //
+ static final class Action239 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeIdentifierKnR(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 240: array_modifier ::= [ ]
+ //
+ static final class Action240 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorArrayModifier(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 241: array_modifier ::= [ <openscope-ast> array_modifier_type_qualifiers ]
+ //
+ static final class Action241 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorModifiedArrayModifier(false, false, true, false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 242: array_modifier ::= [ assignment_expression ]
+ //
+ static final class Action242 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorArrayModifier(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 243: array_modifier ::= [ <openscope-ast> array_modifier_type_qualifiers assignment_expression ]
+ //
+ static final class Action243 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorModifiedArrayModifier(false, false, true, true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 244: array_modifier ::= [ static assignment_expression ]
+ //
+ static final class Action244 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorModifiedArrayModifier(true, false, false, true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 245: array_modifier ::= [ static <openscope-ast> array_modifier_type_qualifiers assignment_expression ]
+ //
+ static final class Action245 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorModifiedArrayModifier(true, false, true, true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 246: array_modifier ::= [ <openscope-ast> array_modifier_type_qualifiers static assignment_expression ]
+ //
+ static final class Action246 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorModifiedArrayModifier(true, false, true, true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 247: array_modifier ::= [ * ]
+ //
+ static final class Action247 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorModifiedArrayModifier(false, true, false, false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 248: array_modifier ::= [ <openscope-ast> array_modifier_type_qualifiers * ]
+ //
+ static final class Action248 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorModifiedArrayModifier(false, true, true, false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 250: pointer ::= *
+ //
+ static final class Action250 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumePointer(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 251: pointer ::= pointer *
+ //
+ static final class Action251 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumePointer(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 252: pointer ::= * <openscope-ast> type_qualifier_list
+ //
+ static final class Action252 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumePointerTypeQualifierList(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 253: pointer ::= pointer * <openscope-ast> type_qualifier_list
+ //
+ static final class Action253 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumePointerTypeQualifierList(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 256: parameter_type_list ::= parameter_list
+ //
+ static final class Action256 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeEmpty(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 257: parameter_type_list ::= parameter_list , ...
+ //
+ static final class Action257 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumePlaceHolder(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 258: parameter_type_list ::= ...
+ //
+ static final class Action258 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumePlaceHolder(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 261: parameter_declaration ::= declaration_specifiers complete_parameter_declarator
+ //
+ static final class Action261 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeParameterDeclaration(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+
+ //
+ // Rule 262: parameter_declaration ::= declaration_specifiers
+ //
+ static final class Action262 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeParameterDeclarationWithoutDeclarator();
+ return hasUndo;
+ }
+
+ public Action262() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeParameterDeclarationWithoutDeclarator(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 263: complete_parameter_declarator ::= declarator
+ //
+ static final class Action263 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclaratorCompleteParameter();
+ return hasUndo;
+ }
+
+ public Action263() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ }
+
+
+ //
+ // Rule 264: complete_parameter_declarator ::= abstract_declarator
+ //
+ static final class Action264 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeDeclaratorCompleteParameter();
+ return hasUndo;
+ }
+
+ public Action264() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ }
+
+
+ //
+ // Rule 265: type_name ::= specifier_qualifier_list
+ //
+ static final class Action265 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeTypeId();
+ return hasUndo;
+ }
+
+ public Action265() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeId(false); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 266: type_name ::= specifier_qualifier_list abstract_declarator
+ //
+ static final class Action266 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeTypeId();
+ return hasUndo;
+ }
+
+ public Action266() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTypeId(true); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+ //
+ // Rule 268: abstract_declarator ::= <openscope-ast> pointer
+ //
+ static final class Action268 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclaratorWithPointer(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 269: abstract_declarator ::= <openscope-ast> pointer direct_abstract_declarator
+ //
+ static final class Action269 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclaratorWithPointer(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 270: direct_abstract_declarator ::= ( abstract_declarator )
+ //
+ static final class Action270 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDirectDeclaratorBracketed(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 271: direct_abstract_declarator ::= array_modifier
+ //
+ static final class Action271 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeAbstractDeclaratorArrayModifier(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 272: direct_abstract_declarator ::= direct_abstract_declarator array_modifier
+ //
+ static final class Action272 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeAbstractDeclaratorArrayModifier(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 273: direct_abstract_declarator ::= ( )
+ //
+ static final class Action273 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeAbstractDeclaratorFunctionDeclarator(false, false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 274: direct_abstract_declarator ::= direct_abstract_declarator ( )
+ //
+ static final class Action274 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeAbstractDeclaratorFunctionDeclarator(true, false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 275: direct_abstract_declarator ::= ( <openscope-ast> parameter_type_list )
+ //
+ static final class Action275 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeAbstractDeclaratorFunctionDeclarator(false, true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 276: direct_abstract_declarator ::= direct_abstract_declarator ( <openscope-ast> parameter_type_list )
+ //
+ static final class Action276 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeAbstractDeclaratorFunctionDeclarator(true, true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 277: initializer ::= assignment_expression
+ //
+ static final class Action277 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeInitializer(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 278: initializer ::= { <openscope-ast> initializer_list comma_opt }
+ //
+ static final class Action278 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeInitializerList(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 283: designated_initializer ::= <openscope-ast> designation = initializer
+ //
+ static final class Action283 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeInitializerDesignated(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 287: designator_base ::= [ constant_expression ]
+ //
+ static final class Action287 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDesignatorArray(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 288: designator_base ::= . identifier_or_typedefname
+ //
+ static final class Action288 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDesignatorField(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 289: designator ::= [ constant_expression ]
+ //
+ static final class Action289 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDesignatorArray(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 290: designator ::= . identifier_or_typedefname
+ //
+ static final class Action290 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDesignatorField(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 291: translation_unit ::= external_declaration_list
+ //
+ static final class Action291 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTranslationUnit(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 292: translation_unit ::= $Empty
+ //
+ static final class Action292 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeTranslationUnit(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 297: external_declaration ::= ;
+ //
+ static final class Action297 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclarationEmpty(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 298: external_declaration ::= ERROR_TOKEN
+ //
+ static final class Action298 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeDeclarationProblem(); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+
+ //
+ // Rule 301: function_definition ::= declaration_specifiers <openscope-ast> function_declarator function_body
+ //
+ static final class Action301 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeFunctionDefinition();
+ return hasUndo;
+ }
+
+ public Action301() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeFunctionDefinition(true); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 302: function_definition ::= <openscope-declaration> <openscope-ast> function_declarator function_body
+ //
+ static final class Action302 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeFunctionDefinition();
+ return hasUndo;
+ }
+
+ public Action302() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeFunctionDefinition(false); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+
+ //
+ // Rule 303: function_definition ::= declaration_specifiers <openscope-ast> knr_function_declarator <openscope-ast> declaration_list compound_statement
+ //
+ static final class Action303 extends DeclaredAction< C99ParserAction , Object > {
+
+
+ public boolean doTrial(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.
+ consumeFunctionDefinition();
+ return hasUndo;
+ }
+
+ public Action303() { hasUndo = true; };
+ public void doUndo(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.resolver.undo();
+ }
+
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeFunctionDefinitionKnR(); /* action.builder.getASTStack().print();*/
+ }
+
+ }
+
+ //
+ // Rule 304: function_body ::= { }
+ //
+ static final class Action304 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementCompoundStatement(false); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+ //
+ // Rule 305: function_body ::= { <openscope-ast> block_item_list }
+ //
+ static final class Action305 extends DeclaredAction< C99ParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, C99ParserAction action) { action.builder.
+ consumeStatementCompoundStatement(true); /* action.builder.getASTStack().print();*/
+ }
+ }
+
+}
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ParserAction.java
new file mode 100644
index 00000000000..38abf4096fc
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ParserAction.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99;
+
+import org.eclipse.cdt.core.dom.lrparser.action.c99.C99BuildASTParserAction;
+import org.eclipse.cdt.core.dom.lrparser.action.c99.C99TypedefTrackerParserAction;
+
+class C99ParserAction {
+
+ public C99BuildASTParserAction builder;
+ public C99TypedefTrackerParserAction resolver;
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parserprs.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parserprs.java
new file mode 100644
index 00000000000..3f85d621215
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parserprs.java
@@ -0,0 +1,1378 @@
+/*******************************************************************************
+* Copyright (c) 2006, 2008 IBM Corporation and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* IBM Corporation - initial API and implementation
+*********************************************************************************/
+
+// This file was generated by LPG
+
+package org.eclipse.cdt.internal.core.dom.lrparser.c99;
+
+public class C99Parserprs implements lpg.lpgjavaruntime.ParseTable, C99Parsersym {
+
+ public interface IsKeyword {
+ public final static byte isKeyword[] = {0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0
+ };
+ };
+ public final static byte isKeyword[] = IsKeyword.isKeyword;
+ public final boolean isKeyword(int index) { return isKeyword[index] != 0; }
+
+ public interface BaseCheck {
+ public final static short baseCheck[] = {0,
+ 0,0,0,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,3,1,1,
+ 1,4,4,3,3,2,2,8,1,0,
+ 1,1,1,1,2,2,2,2,2,2,
+ 2,2,2,4,1,4,1,3,3,3,
+ 1,3,3,1,3,3,1,3,3,3,
+ 3,1,3,3,1,3,1,3,1,3,
+ 1,3,1,3,1,5,1,3,3,3,
+ 3,3,3,3,3,3,3,3,1,1,
+ 2,1,0,1,3,1,1,1,1,1,
+ 1,1,1,3,3,2,3,5,1,2,
+ 1,1,1,2,5,7,5,1,0,7,
+ 5,10,9,3,2,2,2,3,2,4,
+ 3,3,3,3,3,1,1,1,1,2,
+ 1,2,2,2,1,2,2,1,2,2,
+ 1,2,2,1,2,2,1,3,1,3,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,5,5,6,6,2,
+ 2,2,1,0,1,2,4,2,1,1,
+ 3,1,1,2,3,6,7,1,0,1,
+ 3,1,3,1,1,1,1,1,1,3,
+ 1,1,1,1,1,3,1,2,2,1,
+ 6,4,1,3,6,1,3,1,3,2,
+ 4,3,5,4,6,6,3,5,1,1,
+ 2,3,4,1,2,1,3,1,1,3,
+ 2,1,1,1,1,2,1,2,3,3,
+ 1,2,2,3,4,5,1,5,1,1,
+ 3,3,4,1,1,2,3,2,3,2,
+ 1,0,1,2,1,1,1,1,1,2,
+ 4,4,6,2,4,-6,0,-167,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-3,0,-2,0,
+ -260,0,-12,0,0,-113,0,0,0,-163,
+ -39,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-58,
+ 0,0,0,0,0,-37,-20,0,-26,-4,
+ 0,0,0,0,0,0,0,-27,0,0,
+ 0,0,0,0,-29,-30,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-264,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-248,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-21,0,-160,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-31,
+ -46,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-33,
+ -13,0,0,0,0,-44,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-161,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-62,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -32,0,-101,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-18,-36,-125,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-177,0,-154,0,0,0,0,0,
+ 0,0,0,0,0,0,-268,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-143,0,0,0,-65,
+ -24,-185,-48,0,-165,-76,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-61,
+ 0,-28,0,-92,0,-77,0,-118,0,0,
+ 0,0,0,0,0,-109,0,0,0,-56,
+ 0,-221,0,0,0,-138,0,-15,0,0,
+ -87,0,-78,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-79,0,0,0,-150,-121,0,
+ 0,0,0,0,0,0,0,-105,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-127,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-156,-40,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-240,0,0,0,
+ 0,0,0,0,0,-72,-80,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-128,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -129,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-34,
+ 0,-130,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -35,0,-131,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-38,0,-132,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-49,0,-133,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-51,0,-134,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-54,0,-135,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-55,0,-136,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-60,0,-137,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-88,0,-184,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-191,-8,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-81,-22,-155,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-82,-186,-83,-192,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-144,-84,-226,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-228,0,-162,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-41,0,0,0,0,0,0,0,
+ 0,-23,-63,-67,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-85,
+ 0,-157,0,0,0,0,0,0,0,0,
+ 0,0,-86,-45,0,-90,0,-91,-230,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-251,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-93,0,-126,
+ -259,0,-158,-187,0,0,0,0,0,0,
+ 0,0,0,-25,0,-97,0,0,-96,0,
+ 0,0,-139,0,0,0,0,0,0,-196,
+ 0,0,0,-117,0,0,0,0,0,0,
+ 0,0,0,0,-94,-99,0,-159,0,0,
+ 0,0,0,0,0,0,0,0,-234,-100,
+ 0,0,0,0,-261,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-271,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-74,0,0,0,0,0,0,-7,
+ 0,-103,-220,0,-19,0,-108,-140,0,-245,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-124,0,
+ 0,0,0,-98,0,0,0,0,-95,-104,
+ -188,0,0,0,0,0,-197,0,0,0,
+ 0,0,0,0,0,-106,0,0,0,0,
+ -179,0,0,0,0,0,0,-53,-5,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-189,0,0,-102,0,0,0,-169,0,
+ 0,0,0,0,0,-112,0,0,0,0,
+ 0,0,0,0,0,-47,-193,0,-199,-114,
+ -233,0,0,0,0,-152,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-115,
+ 0,-120,0,0,0,-168,0,0,0,0,
+ 0,0,0,0,-239,-180,0,-172,0,0,
+ 0,0,0,0,0,0,0,0,-253,0,
+ 0,0,0,-170,-64,0,0,-151,0,0,
+ 0,0,0,0,0,0,0,0,0,-200,
+ 0,0,0,0,0,-255,0,0,0,-145,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-175,0,0,0,0,-182,-110,-183,0,
+ 0,0,-256,0,-75,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-202,
+ 0,0,0,-201,0,-146,0,0,0,-280,
+ 0,0,0,0,-238,0,-176,-250,0,0,
+ 0,0,0,0,0,0,-178,0,0,0,
+ 0,0,0,0,0,0,-286,0,0,0,
+ -116,-17,0,-219,-222,0,0,0,0,0,
+ 0,0,-229,-190,-203,0,0,-224,-204,-205,
+ 0,0,0,-288,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-122,
+ 0,0,0,0,-236,-225,-257,0,0,0,
+ 0,0,0,0,0,-181,0,-232,-252,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -241,-263,0,0,0,0,0,0,0,-43,
+ 0,0,0,0,0,-206,-237,-207,0,0,
+ 0,0,-265,-208,0,0,-209,0,-123,-276,
+ -210,-57,0,0,0,-211,0,0,-164,0,
+ 0,0,0,0,0,0,0,0,0,-1,
+ 0,-9,0,0,0,0,0,0,0,0,
+ -247,0,0,0,0,0,0,0,0,0,
+ 0,-212,0,-59,0,0,0,0,0,0,
+ 0,-269,-213,-267,-272,-214,0,0,0,-66,
+ 0,-215,-258,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-141,0,0,0,0,
+ 0,0,0,-142,0,0,0,0,0,-270,
+ -274,0,-279,-282,0,0,0,-216,0,-10,
+ -217,-218,0,0,0,-223,0,-231,-277,0,
+ 0,0,0,0,0,-243,0,0,-153,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-227,0,-11,-194,0,0,0,
+ 0,0,0,0,-14,-50,-235,0,0,0,
+ 0,-16,0,0,0,0,0,-278,-284,-287,
+ 0,-244,-246,0,0,-249,0,0,0,0,
+ 0,-273,0,0,0,-52,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-283,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-68,0,0,0,0,
+ 0,0,0,0,0,-69,-107,0,0,0,
+ 0,0,0,0,0,0,0,0,-70,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-71,0,0,0,0,
+ 0,0,0,-73,0,0,0,0,0,0,
+ 0,-89,0,0,0,0,0,0,0,-111,
+ 0,0,0,0,0,0,-147,0,0,0,
+ 0,0,0,0,0,0,-166,0,0,0,
+ 0,-148,0,0,0,0,0,0,0,-149,
+ 0,0,0,0,0,0,0,0,-195,0,
+ 0,0,0,0,0,0,-198,0,-242,0,
+ 0,-262,0,0,-42,0,0,0,0,-119,
+ 0,0,-266,0,-275,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-281,0,-285,0,
+ -171,0,-173,0,-174,0,-254,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0
+ };
+ };
+ public final static short baseCheck[] = BaseCheck.baseCheck;
+ public final int baseCheck(int index) { return baseCheck[index]; }
+ public final static short rhs[] = baseCheck;
+ public final int rhs(int index) { return rhs[index]; };
+
+ public interface BaseAction {
+ public final static char baseAction[] = {
+ 100,1,26,21,34,34,24,24,35,35,
+ 19,19,2,2,2,2,3,3,3,4,
+ 4,5,5,5,5,5,5,5,5,64,
+ 64,81,81,81,6,6,6,6,6,6,
+ 6,6,6,6,6,7,7,8,8,8,
+ 8,9,9,9,10,10,10,11,11,11,
+ 11,11,12,12,12,13,13,14,14,15,
+ 15,16,16,17,17,18,18,22,22,22,
+ 22,22,22,22,22,22,22,22,22,36,
+ 27,20,101,101,102,102,56,37,37,37,
+ 37,37,37,37,38,38,38,30,30,83,
+ 83,65,65,39,39,40,40,40,59,59,
+ 41,41,41,41,42,42,42,42,42,48,
+ 48,23,23,23,23,23,49,49,49,90,
+ 90,85,85,85,85,86,86,86,87,87,
+ 87,88,88,88,89,89,89,84,84,77,
+ 77,78,50,53,53,53,53,53,66,67,
+ 67,67,67,67,67,67,67,67,67,67,
+ 67,76,76,25,25,25,73,73,73,73,
+ 74,74,74,68,68,69,69,61,61,54,
+ 103,103,91,92,92,92,75,75,93,93,
+ 94,94,79,79,28,29,29,29,51,52,
+ 52,43,43,43,43,31,31,32,44,44,
+ 45,33,33,95,95,46,105,105,104,104,
+ 47,47,47,47,47,47,47,47,47,96,
+ 55,55,55,55,70,70,62,62,62,63,
+ 63,57,57,106,106,72,72,71,71,71,
+ 58,58,58,58,58,58,58,60,60,82,
+ 82,82,82,80,107,108,108,109,109,110,
+ 110,100,100,111,111,97,97,97,97,112,
+ 112,98,98,98,99,99,772,562,1075,672,
+ 16,21,17,626,620,47,656,704,683,1048,
+ 787,1064,1062,1150,1085,1163,77,104,306,43,
+ 277,751,764,1210,137,214,809,367,225,233,
+ 1170,890,16,21,17,626,45,47,656,704,
+ 683,1048,787,1064,1798,139,136,138,460,162,
+ 1296,2030,1224,225,230,226,310,585,279,844,
+ 1295,1320,141,168,219,621,222,224,625,145,
+ 148,151,154,1808,232,1211,837,623,280,129,
+ 1323,1722,1800,1836,1845,1852,1592,367,225,234,
+ 1529,1030,1075,672,16,21,17,626,620,47,
+ 656,704,683,1048,787,1064,1062,1150,1085,1163,
+ 77,304,201,202,277,987,672,16,21,17,
+ 626,620,47,656,704,683,1048,787,1064,1062,
+ 1150,1085,1163,77,104,2025,1170,277,16,21,
+ 17,626,45,47,656,704,683,1048,787,1753,
+ 628,966,279,16,21,17,626,620,47,656,
+ 704,683,1048,787,1064,1062,1150,1085,1163,77,
+ 667,1220,280,277,1700,281,920,1485,16,21,
+ 17,626,620,47,656,704,683,1048,787,1064,
+ 1062,1150,1085,1163,77,282,480,1170,1133,16,
+ 21,17,626,45,47,656,704,683,1048,1756,
+ 240,160,1113,1699,16,21,17,626,620,47,
+ 656,704,683,1048,787,1064,1062,1150,1085,1163,
+ 77,104,1846,1170,1349,16,21,17,626,620,
+ 47,656,704,683,1048,787,1064,1062,1150,1085,
+ 1163,77,178,899,945,94,16,21,17,626,
+ 620,47,656,704,683,1048,787,1064,1062,1150,
+ 1085,1163,77,837,1105,1170,1427,16,21,17,
+ 626,45,47,656,704,683,1688,966,241,16,
+ 21,17,626,620,47,656,704,683,1048,787,
+ 1064,1062,1150,1085,1163,77,1249,366,107,277,
+ 309,423,1238,184,543,1170,1208,16,21,17,
+ 626,45,47,656,704,683,1048,787,1064,1062,
+ 1150,1802,113,89,987,1522,650,1430,1376,1322,
+ 1295,1630,178,98,1,543,1213,283,1237,1405,
+ 111,97,99,100,101,102,1295,1646,229,129,
+ 1223,112,1279,113,89,987,890,650,1228,1376,
+ 1322,1296,1987,804,98,198,255,214,109,305,
+ 1405,111,97,99,100,101,102,25,254,214,
+ 2009,211,112,563,584,232,654,1426,1170,827,
+ 16,21,17,626,45,47,656,1605,1170,110,
+ 16,21,17,626,45,47,656,704,683,1048,
+ 787,1064,1062,1150,1085,1163,96,137,214,1170,
+ 658,16,21,17,626,620,47,656,704,683,
+ 1048,787,1064,1062,1150,1085,1163,77,139,136,
+ 138,88,162,1170,178,16,21,17,626,45,
+ 47,656,704,1697,1577,141,168,1296,2033,1866,
+ 1649,285,145,148,151,154,1012,298,16,21,
+ 17,626,45,38,1722,1800,1836,1845,1852,1592,
+ 1170,274,16,21,17,626,620,47,656,704,
+ 683,1048,787,1064,1062,1150,1085,1163,77,1702,
+ 247,1170,87,16,21,17,626,620,47,656,
+ 704,683,1048,787,1064,1062,1150,1085,1163,77,
+ 104,1876,1170,86,16,21,17,626,620,47,
+ 656,704,683,1048,787,1064,1062,1150,1085,1163,
+ 77,104,1388,1170,85,16,21,17,626,620,
+ 47,656,704,683,1048,787,1064,1062,1150,1085,
+ 1163,77,985,670,1170,84,16,21,17,626,
+ 620,47,656,704,683,1048,787,1064,1062,1150,
+ 1085,1163,77,104,1917,1170,83,16,21,17,
+ 626,620,47,656,704,683,1048,787,1064,1062,
+ 1150,1085,1163,77,104,1970,1170,82,16,21,
+ 17,626,620,47,656,704,683,1048,787,1064,
+ 1062,1150,1085,1163,77,104,1591,1170,81,16,
+ 21,17,626,620,47,656,704,683,1048,787,
+ 1064,1062,1150,1085,1163,77,1010,1244,1170,80,
+ 16,21,17,626,620,47,656,704,683,1048,
+ 787,1064,1062,1150,1085,1163,77,104,709,1170,
+ 79,16,21,17,626,620,47,656,704,683,
+ 1048,787,1064,1062,1150,1085,1163,77,104,308,
+ 1170,78,16,21,17,626,45,47,656,704,
+ 683,1048,787,1064,1062,1150,1085,1163,96,1170,
+ 583,16,21,17,626,620,47,656,704,683,
+ 1048,787,1064,1062,1150,1085,1163,77,789,583,
+ 1170,1635,16,21,17,626,45,47,656,704,
+ 683,1694,593,809,776,1170,213,16,21,17,
+ 626,620,47,656,704,683,1048,787,1064,1062,
+ 1150,1085,1163,77,1249,239,1170,1687,16,21,
+ 17,626,620,47,656,704,683,1048,787,1064,
+ 1062,1150,1085,1163,77,243,543,1170,95,16,
+ 21,17,626,45,47,656,704,683,1048,787,
+ 1064,1062,1762,165,113,89,987,1648,650,302,
+ 1376,1322,1232,797,1151,98,16,21,17,626,
+ 43,1405,111,97,99,100,101,102,301,360,
+ 338,130,1170,112,16,21,17,626,45,47,
+ 656,704,1701,544,165,24,1221,242,1062,1170,
+ 109,16,21,17,626,45,47,656,704,683,
+ 1048,787,1064,1062,1150,1085,1163,96,1211,1170,
+ 681,16,21,17,626,45,47,656,704,683,
+ 1048,787,1064,1062,1150,1085,1163,96,1295,543,
+ 1242,123,543,1170,1248,16,21,17,626,45,
+ 47,656,704,1706,378,204,709,127,90,1238,
+ 113,89,987,890,650,1409,1376,1322,255,214,
+ 178,98,255,214,1223,1752,108,1405,111,97,
+ 99,100,101,102,1484,1300,813,18,1170,112,
+ 16,21,17,626,45,47,656,704,1742,178,
+ 964,228,254,214,126,1170,110,16,21,17,
+ 626,45,47,656,704,683,1048,787,1064,1062,
+ 1150,1085,1163,96,1170,1465,16,21,17,626,
+ 45,47,656,704,683,1048,787,1064,1062,1150,
+ 1085,1163,96,1189,1214,16,21,17,626,36,
+ 367,652,754,1313,1672,367,764,1116,501,1240,
+ 1170,205,16,21,17,626,45,47,656,704,
+ 683,1048,787,1064,1062,1150,1085,1163,76,797,
+ 1858,1224,225,378,436,543,1224,225,230,1300,
+ 226,890,187,219,621,222,385,421,219,621,
+ 222,224,161,113,89,271,1277,341,125,1376,
+ 1322,478,543,244,98,231,1367,1731,370,361,
+ 1405,1468,97,99,100,101,102,157,369,266,
+ 113,89,315,1269,1132,1300,1376,1322,297,1300,
+ 327,98,370,1430,272,1049,1116,1405,104,97,
+ 99,100,101,102,114,444,310,797,128,890,
+ 845,805,2022,1224,225,230,1170,296,16,21,
+ 17,626,45,47,1610,219,621,222,224,271,
+ 1236,186,1063,1816,263,273,62,1224,225,1168,
+ 1367,243,1224,225,230,546,1116,210,467,220,
+ 621,222,1166,264,219,621,222,224,271,520,
+ 543,336,1450,341,1300,1223,294,295,1170,1367,
+ 16,21,17,626,45,47,656,1609,113,89,
+ 890,189,1671,124,1376,1322,562,543,261,98,
+ 1301,543,271,254,214,1405,121,97,99,100,
+ 101,102,1306,1693,1862,113,89,1116,1135,1116,
+ 92,1376,1322,604,543,1189,98,16,21,17,
+ 626,35,1405,117,97,99,100,101,102,987,
+ 797,199,113,89,890,1210,104,543,1376,1322,
+ 646,543,188,98,206,104,402,1034,1238,1405,
+ 1872,97,99,100,101,102,90,1307,23,113,
+ 89,564,666,1550,22,1376,1322,688,543,196,
+ 98,370,827,288,1253,890,1405,116,97,99,
+ 100,101,102,1285,1309,668,113,89,890,711,
+ 1274,1554,1376,1322,730,543,1430,98,235,1479,
+ 137,214,197,1405,123,97,99,100,101,102,
+ 367,764,1506,113,89,797,890,1290,543,1376,
+ 1322,140,136,138,98,162,751,764,1116,1286,
+ 1405,122,97,99,100,101,102,90,142,168,
+ 1533,1224,225,230,118,146,149,152,155,245,
+ 210,890,458,219,621,222,224,1224,225,230,
+ 367,764,161,207,1063,1450,1280,797,831,219,
+ 621,222,224,507,869,270,1791,1009,1808,1223,
+ 1313,1255,310,1224,225,230,1261,157,369,104,
+ 543,1224,225,230,1132,220,621,222,224,271,
+ 302,246,865,219,621,222,224,254,214,90,
+ 1693,1116,161,1224,225,230,1801,200,202,297,
+ 272,327,1267,370,1060,220,621,222,224,1603,
+ 137,214,797,1065,890,890,466,158,369,286,
+ 1132,543,431,1300,1890,987,278,650,296,1210,
+ 1452,144,136,138,303,162,1132,543,275,1793,
+ 90,987,2035,199,1132,543,287,1233,143,168,
+ 1238,1300,300,1300,1300,1029,90,987,635,199,
+ 313,1312,551,1233,90,987,1038,199,1316,890,
+ 2097,1233,120,2099,1328,290,1064,293,295,1170,
+ 329,16,21,17,626,45,47,1686,137,214,
+ 1328,1389,676,276,1041,543,403,1012,1328,16,
+ 21,17,626,45,38,757,1037,1272,1429,147,
+ 136,138,812,162,90,987,1500,650,797,890,
+ 890,118,1317,759,137,214,1322,987,987,199,
+ 1402,248,377,137,214,2177,1037,2177,2177,2177,
+ 137,214,1637,1587,1614,150,136,138,2177,162,
+ 1116,2177,289,1763,153,136,138,987,162,199,
+ 666,156,136,138,260,162,1170,195,16,21,
+ 17,626,45,42,1327,1528,1170,1037,16,21,
+ 17,626,45,41,2177,28,2177,2177,2177,1170,
+ 666,16,21,17,626,45,40,195,987,2177,
+ 199,2177,2177,2177,1416,1528,1170,2177,16,21,
+ 17,626,45,39,1170,2177,16,21,17,626,
+ 45,37,1170,2177,16,21,17,626,45,38,
+ 1037,666,2177,2177,2177,2177,2177,1170,195,16,
+ 21,17,626,45,50,1466,1528,790,2177,2177,
+ 2177,987,1170,199,16,21,17,626,45,49,
+ 1170,2177,16,21,17,626,45,48,987,1094,
+ 1402,16,21,17,626,45,46,714,2019,56,
+ 2177,2177,56,2177,666,308,2177,2177,2177,2177,
+ 1262,195,2177,1262,2177,1290,543,2177,1527,1528,
+ 987,273,1402,987,259,1402,987,2177,650,1361,
+ 1604,987,2177,1402,987,90,1402,2177,2177,2177,
+ 2177,2177,118,2177,271,2177,2177,2177,2177,2177,
+ 2177,2177,2177,299,1465,1367,259,1672,2177,259,
+ 2177,1754,1604,2177,1754,1604,2177,259,1671,2177,
+ 259,1594,1361,1604,1794,1809,1604,1290,543,1290,
+ 543,104,543,104,543,104,543,104,543,2177,
+ 2177,2177,2177,2177,2177,2177,2177,90,2177,90,
+ 2177,90,2177,90,118,90,118,90,1595,2177,
+ 1608,2177,1636,2177,1755,2177,2177,1744,2177,2177,
+ 2177,2177,2177,2177,2177,2177,2177,2177,2177,2177,
+ 2177,2177,2177,2177,2177,2177,1859,2177,1860,2177,
+ 0,2186,1,0,3,1,2362,0,3,1,
+ 0,9,11,0,115,1560,0
+ };
+ };
+ public final static char baseAction[] = BaseAction.baseAction;
+ public final int baseAction(int index) { return baseAction[index]; }
+ public final static char lhs[] = baseAction;
+ public final int lhs(int index) { return lhs[index]; };
+
+ public interface TermCheck {
+ public final static byte termCheck[] = {0,
+ 0,1,2,3,4,5,6,7,8,9,
+ 10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,
+ 30,31,32,33,34,35,36,37,38,39,
+ 40,41,0,43,44,45,46,47,48,49,
+ 50,51,52,53,54,0,56,57,58,4,
+ 60,0,1,2,3,4,5,6,7,8,
+ 9,10,11,12,13,14,15,16,17,18,
+ 19,20,21,22,23,24,25,26,27,28,
+ 29,30,31,32,33,34,35,36,37,38,
+ 39,40,41,0,43,44,45,46,47,48,
+ 49,50,51,52,53,54,74,56,57,58,
+ 65,60,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,
+ 18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,
+ 38,39,40,41,0,43,44,45,46,47,
+ 48,49,50,51,52,53,54,0,56,57,
+ 58,4,60,0,1,2,3,4,5,6,
+ 7,8,9,10,11,12,13,14,15,16,
+ 17,18,19,20,21,22,23,24,25,26,
+ 27,28,29,30,31,32,33,34,35,36,
+ 37,38,39,40,41,0,43,44,45,46,
+ 47,48,49,50,51,52,53,54,0,56,
+ 57,58,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,
+ 18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,
+ 38,39,40,41,59,43,44,45,46,47,
+ 48,49,50,51,52,53,54,0,56,57,
+ 58,0,1,2,3,4,5,0,0,0,
+ 1,2,0,4,0,1,2,79,4,0,
+ 19,20,21,22,23,24,25,26,27,0,
+ 29,30,31,21,22,23,24,0,26,27,
+ 0,29,30,31,43,44,45,46,47,48,
+ 49,50,51,52,53,54,42,56,57,58,
+ 0,1,2,3,4,5,0,1,2,0,
+ 62,2,75,76,5,74,0,0,1,19,
+ 20,21,22,23,24,25,26,27,19,29,
+ 30,31,84,85,86,87,88,89,90,91,
+ 92,93,0,43,44,45,46,47,48,49,
+ 50,51,52,53,54,78,56,57,58,42,
+ 0,1,0,21,22,23,24,0,26,27,
+ 0,29,30,31,74,0,1,2,3,4,
+ 5,6,7,8,9,10,11,12,13,14,
+ 15,16,17,18,19,20,80,0,1,2,
+ 25,4,42,28,42,0,0,32,33,34,
+ 35,36,37,38,39,40,41,0,1,2,
+ 3,4,5,6,7,8,9,10,11,12,
+ 13,14,15,16,17,18,19,20,32,42,
+ 0,1,25,0,4,28,0,1,78,32,
+ 33,34,35,36,37,38,39,40,41,0,
+ 1,2,3,4,5,6,7,8,9,10,
+ 11,12,13,14,15,16,17,18,19,20,
+ 75,76,42,0,25,0,1,28,42,4,
+ 0,32,33,34,35,36,37,38,39,40,
+ 41,0,1,2,3,4,5,6,7,8,
+ 9,10,11,12,13,14,15,16,17,18,
+ 19,20,0,0,0,1,25,42,6,28,
+ 7,8,0,32,33,34,35,36,37,38,
+ 39,40,41,0,1,2,3,4,5,6,
+ 7,8,9,10,11,12,13,14,15,16,
+ 17,18,19,20,0,82,83,0,25,79,
+ 6,28,0,6,0,32,33,34,35,36,
+ 37,38,39,40,41,0,1,2,3,4,
+ 5,6,7,8,9,10,11,12,13,14,
+ 15,16,17,18,19,20,0,0,0,77,
+ 25,0,6,28,7,8,0,32,33,34,
+ 35,36,37,38,39,40,41,0,1,2,
+ 3,4,5,6,7,8,9,10,11,12,
+ 13,14,15,16,17,18,19,20,0,1,
+ 0,77,25,0,1,28,3,7,8,32,
+ 33,34,35,36,37,38,39,40,41,0,
+ 1,2,3,4,5,6,7,8,9,10,
+ 11,12,13,14,15,16,17,18,19,20,
+ 0,1,2,0,25,42,0,28,0,6,
+ 2,32,33,34,35,36,37,38,39,40,
+ 41,0,1,2,61,0,5,21,22,23,
+ 24,28,26,27,9,29,30,31,0,0,
+ 19,2,21,22,23,24,0,26,27,3,
+ 29,30,31,0,0,1,2,3,0,59,
+ 0,0,0,1,43,44,45,46,47,48,
+ 49,50,51,52,53,54,0,56,57,58,
+ 0,5,21,22,23,24,0,26,27,3,
+ 29,30,31,0,0,19,42,21,22,23,
+ 24,0,26,27,65,29,30,31,70,71,
+ 72,73,66,55,0,61,63,64,0,43,
+ 44,45,46,47,48,49,50,51,52,53,
+ 54,0,56,57,58,21,22,23,24,0,
+ 26,27,3,29,30,31,60,0,0,0,
+ 70,71,72,73,6,62,62,43,44,45,
+ 46,47,48,49,50,51,52,53,54,0,
+ 1,2,3,4,5,0,7,8,9,10,
+ 11,12,13,14,15,16,17,18,70,71,
+ 72,73,0,24,0,1,2,3,4,5,
+ 61,7,8,9,10,11,12,13,14,15,
+ 16,17,18,0,1,0,1,2,24,4,
+ 5,6,7,8,9,10,11,12,13,14,
+ 15,16,17,18,0,66,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,21,22,23,0,0,
+ 66,0,1,2,3,4,5,0,7,8,
+ 9,10,11,12,13,14,15,16,17,18,
+ 21,22,23,0,1,0,0,0,1,3,
+ 0,1,2,3,4,5,60,7,8,9,
+ 10,11,12,13,14,15,16,17,18,0,
+ 20,0,0,0,0,6,0,6,6,6,
+ 0,63,64,9,0,1,2,66,4,5,
+ 6,7,8,9,10,11,12,13,14,15,
+ 16,17,18,0,1,2,60,4,5,6,
+ 7,8,9,10,11,12,13,14,15,16,
+ 17,18,0,1,2,0,4,5,3,7,
+ 8,9,10,11,12,13,14,15,16,17,
+ 18,0,1,2,0,4,5,3,7,8,
+ 9,10,11,12,13,14,15,16,17,18,
+ 0,1,2,0,4,5,0,7,8,9,
+ 10,11,12,13,14,15,16,17,18,0,
+ 1,2,0,4,5,60,7,8,9,10,
+ 11,12,13,14,15,16,17,18,0,1,
+ 2,0,4,5,60,7,8,9,10,11,
+ 12,13,14,15,16,17,18,0,1,0,
+ 0,2,0,3,5,6,4,10,11,0,
+ 0,2,0,3,5,6,0,0,19,2,
+ 20,0,5,6,3,0,0,0,19,2,
+ 20,0,5,21,22,23,19,0,0,42,
+ 2,20,0,5,0,3,19,21,22,23,
+ 0,0,21,22,23,55,0,19,21,22,
+ 23,0,62,0,67,55,0,4,0,0,
+ 68,69,62,4,0,0,55,3,81,0,
+ 55,0,3,2,0,0,5,3,3,0,
+ 0,0,3,3,20,0,0,55,0,20,
+ 19,0,0,61,20,0,0,63,64,20,
+ 42,0,6,63,64,0,65,42,0,63,
+ 64,0,0,0,0,59,65,0,0,55,
+ 0,68,69,0,0,67,0,68,69,0,
+ 61,0,67,0,0,0,61,0,0,0,
+ 55,61,0,55,0,59,0,55,0,0,
+ 59,0,0,0,59,0,0,0,0,0,
+ 0,0,0,62,59,0,0,59,0,0,
+ 59,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0
+ };
+ };
+ public final static byte termCheck[] = TermCheck.termCheck;
+ public final int termCheck(int index) { return termCheck[index]; }
+
+ public interface TermAction {
+ public final static char termAction[] = {0,
+ 2177,1,3811,1456,1,2164,2,1,1,1,
+ 1,1,1,1,1,1,1,1,1,3808,
+ 2187,3,3,3,3,2280,3,3,2,3,
+ 3,3,1226,1255,718,1359,1360,1354,1229,1270,
+ 1208,1256,2177,3,3,3,3,3,3,3,
+ 3,3,3,3,3,3,3,3,3,882,
+ 2185,9,2171,2171,2171,2171,2171,2171,2171,2171,
+ 2171,2171,2171,2171,2171,2171,2171,2171,2171,2171,
+ 2171,2171,2171,2171,2171,2171,2171,2171,2171,2171,
+ 2171,2171,2171,2171,2171,2171,2171,2171,2171,2171,
+ 2171,2171,2171,1,2171,2171,2171,2171,2171,2171,
+ 2171,2171,2171,2171,2171,2171,2160,2171,2171,2171,
+ 2435,2171,2177,1,3811,1456,1,2164,2,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,3808,2187,3,3,3,3,2280,3,3,
+ 2,3,3,3,1226,1255,718,1359,1360,1354,
+ 1229,1270,1208,1256,2,3,3,3,3,3,
+ 3,3,3,3,3,3,3,2177,3,3,
+ 3,882,2185,2177,1,3811,2188,1,2164,2,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,3808,2187,3,3,3,3,2280,3,
+ 3,2,3,3,3,1226,1255,718,1359,1360,
+ 1354,1229,1270,1208,1256,2177,3,3,3,3,
+ 3,3,3,3,3,3,3,3,73,3,
+ 3,3,2177,1,3811,2188,1,2164,2,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,3808,2187,3,3,3,3,2280,3,3,
+ 2,3,3,3,1226,1255,718,1359,1360,1354,
+ 1229,1270,1208,1256,2283,3,3,3,3,3,
+ 3,3,3,3,3,3,3,65,3,3,
+ 3,2177,3,3,2188,3,3,3,45,2177,
+ 1325,2404,132,966,262,1431,2404,1107,1,2177,
+ 3,2187,3,3,3,3,2475,3,3,2177,
+ 3,3,3,2392,2393,2394,2342,71,2343,2341,
+ 2177,2395,2344,2340,3,3,3,3,3,3,
+ 3,3,3,3,3,3,486,3,3,3,
+ 2177,3,3,2188,3,3,1,1325,2404,209,
+ 989,2360,1050,585,2362,292,115,223,1164,3,
+ 2187,3,3,3,3,2475,3,3,2361,3,
+ 3,3,968,947,926,905,884,842,863,821,
+ 800,739,133,3,3,3,3,3,3,3,
+ 3,3,3,3,3,340,3,3,3,486,
+ 267,777,221,2392,2393,2394,2342,2177,2343,2341,
+ 72,2395,2344,2340,291,2177,1,3811,2188,1,
+ 3814,2,1,1,1,1,1,1,1,1,
+ 1,1,1,1,2361,2187,2174,268,1431,2404,
+ 2280,966,486,2,486,66,2177,1226,1255,718,
+ 1359,1360,1354,1229,1270,1208,1256,2177,1,3811,
+ 2188,1,3814,2,1,1,1,1,1,1,
+ 1,1,1,1,1,1,2361,2187,1806,486,
+ 265,2017,2280,2177,1,2,269,777,340,1226,
+ 1255,718,1359,1360,1354,1229,1270,1208,1256,2177,
+ 1,3811,2188,1,3814,2,1,1,1,1,
+ 1,1,1,1,1,1,1,1,2361,2187,
+ 1050,585,486,75,2280,268,2017,2,486,966,
+ 74,1226,1255,718,1359,1360,1354,1229,1270,1208,
+ 1256,2177,1,3811,2188,1,3814,2,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 2361,2187,2177,54,2177,1123,2280,486,386,2,
+ 1819,1436,69,1226,1255,718,1359,1360,1354,1229,
+ 1270,1208,1256,2177,1,3811,2188,1,3814,2,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,2361,2187,230,625,1709,191,2280,1107,
+ 233,2,2177,903,70,1226,1255,718,1359,1360,
+ 1354,1229,1270,1208,1256,2177,1,3811,2188,1,
+ 3814,2,1,1,1,1,1,1,1,1,
+ 1,1,1,1,2361,2187,190,56,2177,446,
+ 2280,2177,924,2,1819,1436,2177,1226,1255,718,
+ 1359,1360,1354,1229,1270,1208,1256,2177,1,3811,
+ 2188,1,3814,2,1,1,1,1,1,1,
+ 1,1,1,1,1,1,2361,2187,2177,2101,
+ 55,446,2280,1,2017,2,2184,1819,1436,1226,
+ 1255,718,1359,1360,1354,1229,1270,1208,1256,2177,
+ 1,3811,2188,1,3814,2,1,1,1,1,
+ 1,1,1,1,1,1,1,1,2361,2187,
+ 1,1325,2404,2177,2280,486,134,2,2177,583,
+ 2416,1226,1255,718,1359,1360,1354,1229,1270,1208,
+ 1256,1,1325,2404,2183,67,2359,2392,2393,2394,
+ 2342,1567,2343,2341,507,2395,2344,2340,62,3,
+ 2358,2415,2392,2393,2394,2342,2177,2343,2341,2182,
+ 2395,2344,2340,57,1,1431,2404,2184,30,1169,
+ 2177,135,2177,2103,2347,2352,2351,2349,2350,2348,
+ 2353,2354,2346,2355,2356,2357,2177,678,481,333,
+ 64,2359,2392,2393,2394,2342,1,2343,2341,2161,
+ 2395,2344,2340,159,212,2358,486,2392,2393,2394,
+ 2342,2177,2343,2341,2435,2395,2344,2340,1258,1213,
+ 1152,763,2181,2206,131,2183,708,1488,63,2347,
+ 2352,2351,2349,2350,2348,2353,2354,2346,2355,2356,
+ 2357,2177,678,481,333,2392,2393,2394,2342,2177,
+ 2343,2341,2184,2395,2344,2340,2185,2177,192,2177,
+ 1258,1213,1152,763,945,461,1010,2347,2352,2351,
+ 2349,2350,2348,2353,2354,2346,2355,2356,2357,1,
+ 1760,2196,2182,786,2197,2177,1946,1929,1954,1535,
+ 1313,1134,2189,2190,2191,2192,1916,1906,1258,1213,
+ 1152,763,2177,522,2177,1760,2196,2182,1837,2197,
+ 2183,1946,1929,1954,1535,1313,1134,2189,2190,2191,
+ 2192,1916,1906,2177,2105,2177,1760,2196,1065,1962,
+ 2197,1008,1946,1929,1954,1535,1313,1134,2189,2190,
+ 2191,2192,1916,1906,250,2181,1,1760,2196,29,
+ 1962,2197,1008,1946,1929,1954,1535,1313,1134,2189,
+ 2190,2191,2192,1916,1906,1,1,1,61,251,
+ 2181,2177,1760,2196,2182,1962,2197,2177,1946,1929,
+ 1954,1535,1313,1134,2189,2190,2191,2192,1916,1906,
+ 1,1,1,2177,1834,2177,3,2177,2107,194,
+ 3,1,1,119,1,2168,29,1,1,1,
+ 1,1,1,1,1,1,1,1,1,3,
+ 119,230,2177,44,68,2,2177,234,583,1565,
+ 2177,708,1488,507,1,1760,2196,2181,1962,2197,
+ 1008,1946,1929,1954,1535,1313,1134,2189,2190,2191,
+ 2192,1916,1906,2177,1760,2196,194,1962,2197,1565,
+ 1946,1929,1954,1535,1313,1134,2189,2190,2191,2192,
+ 1916,1906,1,1760,2196,2177,1962,2197,2186,1946,
+ 1929,1954,1535,1313,1134,2189,2190,2191,2192,1916,
+ 1906,3,1,1,3,1,2168,193,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 2177,1776,2196,2177,1962,2197,2177,1946,1929,1954,
+ 1535,1313,1134,2189,2190,2191,2192,1916,1906,2177,
+ 1760,2196,2177,1962,2197,2185,1946,1929,1954,1535,
+ 1313,1134,2189,2190,2191,2192,1916,1906,2177,1784,
+ 2196,2177,1962,2197,193,1946,1929,1954,1535,1313,
+ 1134,2189,2190,2191,2192,1916,1906,34,1510,2177,
+ 236,2360,51,224,2362,541,2000,2203,2204,2177,
+ 237,2360,2177,224,2362,840,2177,2177,2361,2360,
+ 224,2177,2362,861,2188,208,252,2177,2361,2360,
+ 224,249,2362,2392,2393,2394,2361,253,2177,1556,
+ 2208,2187,2177,2210,60,2184,2361,2392,2393,2394,
+ 59,3,2392,2393,2394,224,58,2209,2392,2393,
+ 2394,3,224,53,1084,224,2177,2000,2177,52,
+ 1992,1977,224,2000,2177,284,1680,2188,616,1,
+ 3774,208,119,622,1,1,622,2188,2184,2177,
+ 1,2177,2188,93,2187,91,2177,1863,256,119,
+ 622,2177,30,2183,2187,203,2177,708,1488,2187,
+ 1189,2177,1565,708,1488,3,2435,1294,1,708,
+ 1488,1,2177,2177,2177,1381,2434,2177,2177,331,
+ 2177,1992,1977,2177,2177,1568,2177,1992,1977,2177,
+ 119,2177,1790,2177,2177,2177,2183,2177,2177,2177,
+ 1086,93,2177,1847,2177,2282,2177,425,2177,2177,
+ 1330,2177,2177,2177,1275,2177,2177,2177,2177,2177,
+ 2177,2177,2177,597,2361,2177,2177,2360,2177,2177,
+ 2362
+ };
+ };
+ public final static char termAction[] = TermAction.termAction;
+ public final int termAction(int index) { return termAction[index]; }
+
+ public interface Asb {
+ public final static char asb[] = {0,
+ 410,1,355,438,410,355,440,501,444,456,
+ 456,3,3,456,3,456,358,569,440,284,
+ 358,501,193,236,235,537,536,569,8,327,
+ 61,124,61,124,197,61,440,464,472,569,
+ 295,358,440,81,204,43,440,328,124,124,
+ 124,124,197,197,464,381,440,295,475,358,
+ 438,104,101,381,159,343,269,269,269,269,
+ 269,85,269,269,269,153,170,175,173,181,
+ 177,184,183,186,185,187,204,41,269,8,
+ 536,327,267,194,194,231,284,253,284,284,
+ 269,194,244,79,269,79,124,150,74,124,
+ 124,150,200,286,200,197,381,464,297,501,
+ 358,440,381,101,84,81,269,269,269,269,
+ 269,269,269,269,269,269,269,472,472,247,
+ 343,343,231,231,387,269,269,269,269,269,
+ 269,269,269,269,269,269,269,269,269,269,
+ 269,269,269,269,269,206,41,325,194,194,
+ 269,385,269,269,190,284,327,79,253,150,
+ 76,150,150,269,231,200,464,472,467,471,
+ 269,269,101,85,43,569,469,292,472,472,
+ 472,101,173,173,170,170,177,177,175,175,
+ 175,175,183,181,185,184,79,186,471,200,
+ 407,472,284,472,472,269,341,328,193,269,
+ 192,150,291,569,297,101,101,41,247,295,
+ 472,542,503,501,269,442,150,39,540,231,
+ 269,406,253,269,253,253,267,194,327,76,
+ 269,542,467,41,469,297,472,43,101,231,
+ 269,472,326,194,267,200,472,101,194,253,
+ 387,194,150,472,387,253,472,253
+ };
+ };
+ public final static char asb[] = Asb.asb;
+ public final int asb(int index) { return asb[index]; }
+
+ public interface Asr {
+ public final static byte asr[] = {0,
+ 74,0,2,19,5,6,0,26,43,21,
+ 44,56,27,45,29,46,47,30,22,48,
+ 49,24,57,31,58,50,51,23,52,53,
+ 54,19,5,3,62,55,20,0,3,60,
+ 42,67,1,13,14,15,16,2,5,10,
+ 11,9,4,7,8,17,18,12,6,0,
+ 26,21,27,29,30,22,24,31,23,42,
+ 55,61,6,20,3,4,2,1,59,0,
+ 21,22,23,24,10,11,9,4,7,8,
+ 17,18,12,1,2,5,13,14,15,16,
+ 66,3,0,21,22,23,10,11,9,4,
+ 7,8,17,18,12,1,2,5,13,14,
+ 15,16,0,26,43,21,44,56,27,45,
+ 29,46,47,30,22,48,49,24,57,31,
+ 58,50,51,23,52,53,54,19,5,60,
+ 3,0,42,1,67,81,10,11,62,84,
+ 85,86,87,88,90,89,91,92,93,4,
+ 68,69,7,8,64,63,70,71,72,73,
+ 75,76,9,77,78,79,60,82,83,66,
+ 61,59,55,20,3,0,2,19,5,3,
+ 60,55,0,3,61,26,43,21,44,56,
+ 27,45,29,46,47,30,22,48,49,24,
+ 57,31,58,50,51,23,52,53,54,65,
+ 2,19,5,0,1,3,59,62,55,61,
+ 20,42,0,6,28,0,3,61,4,1,
+ 42,0,28,6,34,36,19,39,41,37,
+ 32,38,35,33,40,25,20,3,13,14,
+ 15,16,2,5,10,11,9,4,7,8,
+ 17,18,12,1,0,3,55,60,62,0,
+ 2,4,1,42,3,61,26,43,21,44,
+ 56,27,45,29,46,47,30,22,48,49,
+ 24,57,31,58,50,51,23,52,53,54,
+ 19,5,65,0,74,80,60,28,6,34,
+ 36,39,41,37,32,38,35,33,40,25,
+ 20,3,13,14,15,16,12,10,11,9,
+ 7,8,17,18,2,1,4,19,5,56,
+ 57,58,51,43,48,46,47,45,44,49,
+ 50,52,53,54,31,27,24,26,30,29,
+ 21,22,23,0,32,0,3,61,12,13,
+ 14,15,16,2,5,1,10,11,9,4,
+ 7,8,17,18,0,62,42,67,0,74,
+ 26,43,21,44,56,27,45,29,46,47,
+ 30,22,48,49,24,57,31,58,50,51,
+ 23,52,53,54,19,5,25,20,3,4,
+ 1,2,0,51,43,48,46,47,45,44,
+ 49,50,52,53,54,59,20,31,27,24,
+ 26,30,29,21,22,23,4,2,42,1,
+ 55,61,3,0,26,43,21,44,56,27,
+ 45,29,46,47,30,22,48,49,24,57,
+ 31,58,50,51,23,52,53,54,19,5,
+ 6,0,9,4,7,8,68,69,63,64,
+ 70,71,72,73,75,76,77,78,79,82,
+ 83,59,84,85,86,87,88,89,90,91,
+ 92,93,66,61,60,6,3,55,20,62,
+ 0,26,43,21,44,56,27,45,29,46,
+ 47,30,22,48,49,24,57,31,58,50,
+ 51,23,52,53,54,19,5,65,4,0
+ };
+ };
+ public final static byte asr[] = Asr.asr;
+ public final int asr(int index) { return asr[index]; }
+
+ public interface Nasb {
+ public final static char nasb[] = {0,
+ 102,10,121,57,76,1,60,54,97,98,
+ 98,74,74,98,74,98,93,137,66,10,
+ 121,54,58,29,29,10,10,137,10,16,
+ 10,121,10,121,121,10,63,121,14,137,
+ 37,139,66,23,37,21,61,31,121,123,
+ 121,123,74,121,121,50,83,13,106,121,
+ 57,20,25,50,10,112,21,21,21,21,
+ 21,24,21,21,21,10,10,10,10,10,
+ 10,10,10,10,10,10,13,121,21,10,
+ 10,39,56,58,58,74,10,70,10,10,
+ 21,58,10,10,21,10,123,17,57,89,
+ 123,17,11,10,10,74,50,48,45,10,
+ 4,66,50,25,24,48,21,21,21,21,
+ 21,21,21,21,21,21,21,14,14,132,
+ 112,112,27,27,86,114,21,21,21,21,
+ 21,21,21,21,21,21,21,21,21,21,
+ 21,21,21,114,21,127,20,10,58,58,
+ 114,10,114,114,10,10,16,10,70,17,
+ 66,17,17,21,74,11,48,14,81,10,
+ 21,21,25,24,21,137,29,131,14,14,
+ 14,25,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,14,11,
+ 52,14,10,14,14,21,117,31,58,21,
+ 10,17,80,137,45,25,25,121,133,13,
+ 14,135,10,10,21,10,17,19,10,74,
+ 21,100,70,114,70,70,120,58,39,66,
+ 21,135,82,20,29,45,14,21,25,74,
+ 21,14,10,58,120,11,14,25,58,70,
+ 120,58,17,14,120,70,14,70
+ };
+ };
+ public final static char nasb[] = Nasb.nasb;
+ public final int nasb(int index) { return nasb[index]; }
+
+ public interface Nasr {
+ public final static char nasr[] = {0,
+ 31,1,95,90,89,88,87,86,85,0,
+ 64,0,1,24,0,1,35,0,80,1,
+ 5,0,1,5,34,0,81,0,47,0,
+ 21,23,25,36,1,83,26,0,26,1,
+ 36,25,65,35,21,23,0,28,0,70,
+ 0,108,0,99,0,27,1,19,0,1,
+ 44,46,31,33,0,44,31,1,0,26,
+ 36,1,37,25,0,23,21,97,0,24,
+ 1,58,31,44,0,1,101,0,21,54,
+ 61,0,73,74,75,76,66,49,0,110,
+ 0,111,23,21,0,26,21,23,48,30,
+ 0,21,54,1,27,0,21,23,48,59,
+ 1,0,69,21,54,0,104,21,23,0,
+ 24,1,58,0,21,23,55,0,23,21,
+ 112,0
+ };
+ };
+ public final static char nasr[] = Nasr.nasr;
+ public final int nasr(int index) { return nasr[index]; }
+
+ public interface TerminalIndex {
+ public final static char terminalIndex[] = {0,
+ 2,85,88,9,87,3,10,11,8,6,
+ 7,68,81,82,83,84,12,13,86,93,
+ 48,64,76,69,94,44,55,57,60,63,
+ 72,77,45,46,49,50,51,58,59,65,
+ 71,1,47,52,56,61,62,66,67,74,
+ 75,78,79,80,42,54,70,73,29,92,
+ 91,31,16,17,30,90,4,14,15,18,
+ 19,20,21,95,22,23,24,25,26,53,
+ 5,27,28,32,33,34,35,36,37,38,
+ 39,40,41,89
+ };
+ };
+ public final static char terminalIndex[] = TerminalIndex.terminalIndex;
+ public final int terminalIndex(int index) { return terminalIndex[index]; }
+
+ public interface NonterminalIndex {
+ public final static char nonterminalIndex[] = {0,
+ 0,0,0,0,101,105,106,107,108,109,
+ 110,111,112,113,114,115,116,117,99,0,
+ 0,118,128,97,124,0,100,136,0,123,
+ 157,0,160,96,98,119,122,0,0,0,
+ 0,0,154,156,0,158,159,127,135,0,
+ 0,146,0,149,155,121,168,171,0,145,
+ 148,161,167,0,126,138,0,0,147,166,
+ 170,103,139,140,141,142,143,144,153,172,
+ 102,104,125,129,130,131,132,133,134,137,
+ 151,0,0,152,162,165,177,0,179,0,
+ 0,120,150,163,164,169,173,174,0,175,
+ 176,178,0
+ };
+ };
+ public final static char nonterminalIndex[] = NonterminalIndex.nonterminalIndex;
+ public final int nonterminalIndex(int index) { return nonterminalIndex[index]; }
+
+ public interface ScopePrefix {
+ public final static char scopePrefix[] = {
+ 173,84,33,39,69,91,111,117,142,12,
+ 19,49,123,128,151,26,45,101,169,188,
+ 192,156,1,1,30,54,81,196,6,105,
+ 163,133,163,97,57,57,57
+ };
+ };
+ public final static char scopePrefix[] = ScopePrefix.scopePrefix;
+ public final int scopePrefix(int index) { return scopePrefix[index]; }
+
+ public interface ScopeSuffix {
+ public final static char scopeSuffix[] = {
+ 17,17,4,4,24,17,17,17,148,17,
+ 24,4,17,17,17,24,4,99,24,24,
+ 4,160,4,4,24,4,24,24,9,108,
+ 166,136,181,99,65,59,75
+ };
+ };
+ public final static char scopeSuffix[] = ScopeSuffix.scopeSuffix;
+ public final int scopeSuffix(int index) { return scopeSuffix[index]; }
+
+ public interface ScopeLhs {
+ public final static char scopeLhs[] = {
+ 5,75,47,47,33,75,73,73,40,60,
+ 58,47,73,73,30,58,47,61,6,5,
+ 5,18,110,109,58,47,31,3,80,61,
+ 7,41,5,61,33,46,33
+ };
+ };
+ public final static char scopeLhs[] = ScopeLhs.scopeLhs;
+ public final int scopeLhs(int index) { return scopeLhs[index]; }
+
+ public interface ScopeLa {
+ public final static byte scopeLa[] = {
+ 60,60,66,66,61,60,60,60,80,60,
+ 61,66,60,60,60,61,66,20,61,61,
+ 66,59,66,66,61,66,61,61,62,2,
+ 61,32,61,20,1,1,1
+ };
+ };
+ public final static byte scopeLa[] = ScopeLa.scopeLa;
+ public final int scopeLa(int index) { return scopeLa[index]; }
+
+ public interface ScopeStateSet {
+ public final static byte scopeStateSet[] = {
+ 25,111,86,86,97,111,111,111,12,80,
+ 90,86,111,111,11,90,86,5,25,25,
+ 25,55,1,3,90,86,97,25,82,5,
+ 28,12,25,5,97,99,97
+ };
+ };
+ public final static byte scopeStateSet[] = ScopeStateSet.scopeStateSet;
+ public final int scopeStateSet(int index) { return scopeStateSet[index]; }
+
+ public interface ScopeRhs {
+ public final static char scopeRhs[] = {0,
+ 150,42,0,96,0,201,95,0,31,145,
+ 0,158,176,95,6,0,98,0,156,95,
+ 1,152,0,97,0,156,95,1,0,165,
+ 1,0,116,24,190,95,42,0,116,190,
+ 95,24,42,0,116,24,42,0,116,190,
+ 95,42,0,116,42,0,125,0,2,0,
+ 0,163,97,0,2,0,97,0,156,95,
+ 120,1,125,0,2,0,0,161,97,0,
+ 146,1,0,158,187,95,6,119,56,0,
+ 158,187,95,6,56,0,148,0,99,0,
+ 197,95,148,0,95,148,0,150,99,0,
+ 162,95,6,119,58,0,162,95,6,119,
+ 57,0,162,95,6,58,0,162,95,6,
+ 57,0,131,37,0,77,2,100,97,99,
+ 0,131,118,121,1,39,0,53,122,0,
+ 177,95,6,120,0,121,83,111,0,29,
+ 117,0,166,1,0,97,106,0,166,1,
+ 12,0,158,176,95,6,118,166,1,0,
+ 97,3,0,104,0,98,0,195,1,99,
+ 0,121,42,99,0,121,1,0
+ };
+ };
+ public final static char scopeRhs[] = ScopeRhs.scopeRhs;
+ public final int scopeRhs(int index) { return scopeRhs[index]; }
+
+ public interface ScopeState {
+ public final static char scopeState[] = {0,
+ 1649,0,672,0,1970,1528,1917,1876,1846,0,
+ 1744,1614,1587,1560,1211,1533,1506,1479,1105,1381,
+ 1354,654,623,0,1535,1313,1134,2009,1837,625,
+ 340,1107,507,446,1258,1213,1152,763,1050,585,
+ 1819,1436,1488,708,2000,1992,1977,1962,1954,786,
+ 1946,1929,1916,1906,1294,1275,1189,1330,1169,1086,
+ 1065,1029,1010,989,968,947,926,905,884,863,
+ 842,821,800,739,564,718,543,522,486,597,
+ 461,402,425,308,0,1693,1367,1224,621,1672,
+ 1465,1431,2017,1402,1328,0,366,306,1672,331,
+ 1431,1402,1646,1630,1702,1426,1680,1325,1320,0,
+ 709,1592,306,0
+ };
+ };
+ public final static char scopeState[] = ScopeState.scopeState;
+ public final int scopeState(int index) { return scopeState[index]; }
+
+ public interface InSymb {
+ public final static char inSymb[] = {0,
+ 0,194,115,117,205,95,95,189,179,180,
+ 181,58,57,182,56,183,184,95,1,125,
+ 199,189,178,138,125,172,127,95,140,6,
+ 119,6,119,6,6,119,149,4,146,95,
+ 1,95,55,42,1,62,149,95,6,95,
+ 6,95,95,6,4,95,149,120,206,115,
+ 117,24,116,95,100,1,12,18,17,8,
+ 7,4,9,11,10,99,102,104,103,106,
+ 105,108,107,110,109,111,120,6,4,140,
+ 127,177,40,33,35,38,32,37,41,39,
+ 95,130,120,36,34,119,95,162,148,163,
+ 95,162,187,119,188,95,95,164,95,120,
+ 95,95,95,116,190,164,93,92,91,89,
+ 90,88,87,86,85,84,62,166,121,148,
+ 1,1,81,67,1,42,69,68,4,63,
+ 64,8,7,76,75,73,72,71,70,77,
+ 9,79,78,83,82,95,95,3,121,119,
+ 1,131,1,1,196,28,6,150,59,162,
+ 95,162,158,62,55,187,164,156,117,157,
+ 190,24,116,4,118,95,152,1,166,166,
+ 195,121,103,103,102,102,105,105,104,104,
+ 104,104,107,106,109,108,121,110,198,176,
+ 95,121,32,121,121,55,1,95,197,59,
+ 146,158,1,95,55,116,116,6,149,1,
+ 165,95,118,118,59,55,158,55,201,67,
+ 42,202,118,1,118,118,142,153,177,55,
+ 59,95,149,95,152,95,156,62,150,67,
+ 42,121,131,153,113,176,156,150,118,80,
+ 113,153,158,153,113,118,153,118
+ };
+ };
+ public final static char inSymb[] = InSymb.inSymb;
+ public final int inSymb(int index) { return inSymb[index]; }
+
+ public interface Name {
+ public final static String name[] = {
+ "",
+ "[",
+ "(",
+ "{",
+ ".",
+ "->",
+ "++",
+ "--",
+ "&",
+ "*",
+ "+",
+ "-",
+ "~",
+ "!",
+ "/",
+ "%",
+ ">>",
+ "<<",
+ "<",
+ ">",
+ "<=",
+ ">=",
+ "==",
+ "!=",
+ "^",
+ "|",
+ "&&",
+ "||",
+ "?",
+ ":",
+ "...",
+ "=",
+ "*=",
+ "/=",
+ "%=",
+ "+=",
+ "-=",
+ ">>=",
+ "<<=",
+ "&=",
+ "^=",
+ "|=",
+ ",",
+ "$empty",
+ "auto",
+ "break",
+ "case",
+ "char",
+ "const",
+ "continue",
+ "default",
+ "do",
+ "double",
+ "else",
+ "enum",
+ "extern",
+ "float",
+ "for",
+ "goto",
+ "if",
+ "inline",
+ "int",
+ "long",
+ "register",
+ "restrict",
+ "return",
+ "short",
+ "signed",
+ "sizeof",
+ "static",
+ "struct",
+ "switch",
+ "typedef",
+ "union",
+ "unsigned",
+ "void",
+ "volatile",
+ "while",
+ "_Bool",
+ "_Complex",
+ "_Imaginary",
+ "integer",
+ "floating",
+ "charconst",
+ "stringlit",
+ "identifier",
+ "TypedefName",
+ "Completion",
+ "EndOfCompletion",
+ "Invalid",
+ "RightBracket",
+ "RightParen",
+ "RightBrace",
+ "SemiColon",
+ "ERROR_TOKEN",
+ "EOF_TOKEN",
+ "]",
+ ")",
+ "}",
+ ";",
+ "expression",
+ "postfix_expression",
+ "member_name",
+ "type_name",
+ "initializer_list",
+ "unary_expression",
+ "cast_expression",
+ "multiplicative_expression",
+ "additive_expression",
+ "shift_expression",
+ "relational_expression",
+ "equality_expression",
+ "AND_expression",
+ "exclusive_OR_expression",
+ "inclusive_OR_expression",
+ "logical_AND_expression",
+ "logical_OR_expression",
+ "conditional_expression",
+ "assignment_expression",
+ "expression_in_statement",
+ "expression_list_actual",
+ "constant_expression",
+ "statement",
+ "compound_statement",
+ "identifier_or_typedefname",
+ "block_item_list",
+ "block_item",
+ "declaration",
+ "declaration_specifiers",
+ "init_declarator_list",
+ "simple_declaration_specifiers",
+ "struct_or_union_declaration_sp" +
+ "ecifiers",
+ "elaborated_declaration_specifi" +
+ "ers",
+ "enum_declaration_specifiers",
+ "typdef_name_declaration_specif" +
+ "iers",
+ "no_type_declaration_specifier",
+ "type_qualifier",
+ "no_type_declaration_specifiers",
+ "simple_type_specifier",
+ "struct_or_union_specifier",
+ "elaborated_specifier",
+ "enum_specifier",
+ "typedef_name_in_declspec",
+ "init_declarator",
+ "complete_declarator",
+ "initializer",
+ "declarator",
+ "struct_declaration_list",
+ "struct_declaration",
+ "specifier_qualifier_list",
+ "struct_declarator_list",
+ "complete_struct_declarator",
+ "enumerator_list",
+ "enumerator",
+ "direct_declarator",
+ "pointer",
+ "array_direct_declarator",
+ "basic_direct_declarator",
+ "knr_direct_declarator",
+ "array_modifier",
+ "function_direct_declarator",
+ "parameter_type_list",
+ "function_declarator",
+ "identifier_list",
+ "knr_function_declarator",
+ "array_modifier_type_qualifiers",
+ "type_qualifier_list",
+ "parameter_list",
+ "parameter_declaration",
+ "complete_parameter_declarator",
+ "abstract_declarator",
+ "direct_abstract_declarator",
+ "designated_initializer",
+ "designation",
+ "designator_list",
+ "designator",
+ "external_declaration_list",
+ "external_declaration",
+ "declaration_list",
+ "function_body"
+ };
+ };
+ public final static String name[] = Name.name;
+ public final String name(int index) { return name[index]; }
+
+ public final static int
+ ERROR_SYMBOL = 25,
+ SCOPE_UBOUND = 36,
+ SCOPE_SIZE = 37,
+ MAX_NAME_LENGTH = 38;
+
+ public final int getErrorSymbol() { return ERROR_SYMBOL; }
+ public final int getScopeUbound() { return SCOPE_UBOUND; }
+ public final int getScopeSize() { return SCOPE_SIZE; }
+ public final int getMaxNameLength() { return MAX_NAME_LENGTH; }
+
+ public final static int
+ NUM_STATES = 288,
+ NT_OFFSET = 94,
+ LA_STATE_OFFSET = 2482,
+ MAX_LA = 2147483647,
+ NUM_RULES = 305,
+ NUM_NONTERMINALS = 113,
+ NUM_SYMBOLS = 207,
+ SEGMENT_SIZE = 8192,
+ START_STATE = 1720,
+ IDENTIFIER_SYMBOL = 0,
+ EOFT_SYMBOL = 74,
+ EOLT_SYMBOL = 74,
+ ACCEPT_ACTION = 2160,
+ ERROR_ACTION = 2177;
+
+ public final static boolean BACKTRACK = true;
+
+ public final int getNumStates() { return NUM_STATES; }
+ public final int getNtOffset() { return NT_OFFSET; }
+ public final int getLaStateOffset() { return LA_STATE_OFFSET; }
+ public final int getMaxLa() { return MAX_LA; }
+ public final int getNumRules() { return NUM_RULES; }
+ public final int getNumNonterminals() { return NUM_NONTERMINALS; }
+ public final int getNumSymbols() { return NUM_SYMBOLS; }
+ public final int getSegmentSize() { return SEGMENT_SIZE; }
+ public final int getStartState() { return START_STATE; }
+ public final int getStartSymbol() { return lhs[0]; }
+ public final int getIdentifierSymbol() { return IDENTIFIER_SYMBOL; }
+ public final int getEoftSymbol() { return EOFT_SYMBOL; }
+ public final int getEoltSymbol() { return EOLT_SYMBOL; }
+ public final int getAcceptAction() { return ACCEPT_ACTION; }
+ public final int getErrorAction() { return ERROR_ACTION; }
+ public final boolean isValidForParser() { return isValidForParser; }
+ public final boolean getBacktrack() { return BACKTRACK; }
+
+ public final int originalState(int state) {
+ return -baseCheck[state];
+ }
+ public final int asi(int state) {
+ return asb[originalState(state)];
+ }
+ public final int nasi(int state) {
+ return nasb[originalState(state)];
+ }
+ public final int inSymbol(int state) {
+ return inSymb[originalState(state)];
+ }
+
+ public final int ntAction(int state, int sym) {
+ return baseAction[state + sym];
+ }
+
+ public final int tAction(int state, int sym) {
+ int i = baseAction[state],
+ k = i + sym;
+ return termAction[termCheck[k] == sym ? k : i];
+ }
+ public final int lookAhead(int la_state, int sym) {
+ int k = la_state + sym;
+ return termAction[termCheck[k] == sym ? k : la_state];
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parsersym.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parsersym.java
new file mode 100644
index 00000000000..f65bafc130d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parsersym.java
@@ -0,0 +1,212 @@
+/*******************************************************************************
+* Copyright (c) 2006, 2008 IBM Corporation and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* IBM Corporation - initial API and implementation
+*********************************************************************************/
+
+// This file was generated by LPG
+
+package org.eclipse.cdt.internal.core.dom.lrparser.c99;
+
+public interface C99Parsersym {
+ public final static int
+ TK_auto = 26,
+ TK_break = 33,
+ TK_case = 34,
+ TK_char = 43,
+ TK_const = 21,
+ TK_continue = 35,
+ TK_default = 36,
+ TK_do = 37,
+ TK_double = 44,
+ TK_else = 80,
+ TK_enum = 56,
+ TK_extern = 27,
+ TK_float = 45,
+ TK_for = 28,
+ TK_goto = 38,
+ TK_if = 39,
+ TK_inline = 29,
+ TK_int = 46,
+ TK_long = 47,
+ TK_register = 30,
+ TK_restrict = 22,
+ TK_return = 40,
+ TK_short = 48,
+ TK_signed = 49,
+ TK_sizeof = 12,
+ TK_static = 24,
+ TK_struct = 57,
+ TK_switch = 41,
+ TK_typedef = 31,
+ TK_union = 58,
+ TK_unsigned = 50,
+ TK_void = 51,
+ TK_volatile = 23,
+ TK_while = 32,
+ TK__Bool = 52,
+ TK__Complex = 53,
+ TK__Imaginary = 54,
+ TK_integer = 13,
+ TK_floating = 14,
+ TK_charconst = 15,
+ TK_stringlit = 16,
+ TK_identifier = 2,
+ TK_TypedefName = 19,
+ TK_Completion = 5,
+ TK_EndOfCompletion = 3,
+ TK_Invalid = 94,
+ TK_LeftBracket = 42,
+ TK_LeftParen = 1,
+ TK_LeftBrace = 6,
+ TK_Dot = 67,
+ TK_Arrow = 81,
+ TK_PlusPlus = 10,
+ TK_MinusMinus = 11,
+ TK_And = 9,
+ TK_Star = 4,
+ TK_Plus = 7,
+ TK_Minus = 8,
+ TK_Tilde = 17,
+ TK_Bang = 18,
+ TK_Slash = 68,
+ TK_Percent = 69,
+ TK_RightShift = 63,
+ TK_LeftShift = 64,
+ TK_LT = 70,
+ TK_GT = 71,
+ TK_LE = 72,
+ TK_GE = 73,
+ TK_EQ = 75,
+ TK_NE = 76,
+ TK_Caret = 77,
+ TK_Or = 78,
+ TK_AndAnd = 79,
+ TK_OrOr = 82,
+ TK_Question = 83,
+ TK_Colon = 59,
+ TK_DotDotDot = 65,
+ TK_Assign = 62,
+ TK_StarAssign = 84,
+ TK_SlashAssign = 85,
+ TK_PercentAssign = 86,
+ TK_PlusAssign = 87,
+ TK_MinusAssign = 88,
+ TK_RightShiftAssign = 89,
+ TK_LeftShiftAssign = 90,
+ TK_AndAssign = 91,
+ TK_CaretAssign = 92,
+ TK_OrAssign = 93,
+ TK_Comma = 55,
+ TK_RightBracket = 66,
+ TK_RightParen = 61,
+ TK_RightBrace = 60,
+ TK_SemiColon = 20,
+ TK_ERROR_TOKEN = 25,
+ TK_EOF_TOKEN = 74;
+
+ public final static String orderedTerminalSymbols[] = {
+ "",
+ "LeftParen",
+ "identifier",
+ "EndOfCompletion",
+ "Star",
+ "Completion",
+ "LeftBrace",
+ "Plus",
+ "Minus",
+ "And",
+ "PlusPlus",
+ "MinusMinus",
+ "sizeof",
+ "integer",
+ "floating",
+ "charconst",
+ "stringlit",
+ "Tilde",
+ "Bang",
+ "TypedefName",
+ "SemiColon",
+ "const",
+ "restrict",
+ "volatile",
+ "static",
+ "ERROR_TOKEN",
+ "auto",
+ "extern",
+ "for",
+ "inline",
+ "register",
+ "typedef",
+ "while",
+ "break",
+ "case",
+ "continue",
+ "default",
+ "do",
+ "goto",
+ "if",
+ "return",
+ "switch",
+ "LeftBracket",
+ "char",
+ "double",
+ "float",
+ "int",
+ "long",
+ "short",
+ "signed",
+ "unsigned",
+ "void",
+ "_Bool",
+ "_Complex",
+ "_Imaginary",
+ "Comma",
+ "enum",
+ "struct",
+ "union",
+ "Colon",
+ "RightBrace",
+ "RightParen",
+ "Assign",
+ "RightShift",
+ "LeftShift",
+ "DotDotDot",
+ "RightBracket",
+ "Dot",
+ "Slash",
+ "Percent",
+ "LT",
+ "GT",
+ "LE",
+ "GE",
+ "EOF_TOKEN",
+ "EQ",
+ "NE",
+ "Caret",
+ "Or",
+ "AndAnd",
+ "else",
+ "Arrow",
+ "OrOr",
+ "Question",
+ "StarAssign",
+ "SlashAssign",
+ "PercentAssign",
+ "PlusAssign",
+ "MinusAssign",
+ "RightShiftAssign",
+ "LeftShiftAssign",
+ "AndAssign",
+ "CaretAssign",
+ "OrAssign",
+ "Invalid"
+ };
+
+ public final static boolean isValidForParser = true;
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ResolverParser.g b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ResolverParser.g
new file mode 100644
index 00000000000..69a6f513521
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ResolverParser.g
@@ -0,0 +1,1835 @@
+-----------------------------------------------------------------------------------
+-- Copyright (c) 2006, 2007 IBM Corporation and others.
+-- All rights reserved. This program and the accompanying materials
+-- are made available under the terms of the Eclipse Public License v1.0
+-- which accompanies this distribution, and is available at
+-- http://www.eclipse.org/legal/epl-v10.html
+--
+-- Contributors:
+-- IBM Corporation - initial API and implementation
+-----------------------------------------------------------------------------------
+
+%options la=2
+%options package=org.eclipse.cdt.internal.core.dom.lrparser.c99
+%options template=TrialUndoParserTemplate.g
+%options import_terminals=C99Lexer.g
+
+-----------------------------------------------------------------------------------
+--
+-- An attempt was made to create a C99 parser that has the ability to do all the
+-- binding resolution during the parse. This parser was meant to be used with
+-- the C99ResolveParserAction class.
+--
+-- This initiative has since been abandoned and therefore this parser does
+-- not work correctly, use C99Parser.g instead.
+--
+-- This parser is deprecated.
+--
+-----------------------------------------------------------------------------------
+
+$Notice
+/./*******************************************************************************
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *********************************************************************************/
+
+ // This file was generated by LPG
+./
+$End
+
+$Terminals
+
+ -- Most terminals are defined in the lexer and imported from there.
+ -- This section lists terminals that are not defined in the lexer such as keywords.
+
+
+ -- The scanner does not recognize keywords, it will return them as identifier tokens.
+ -- An IKeywordMap is used to convert these identifiers to keyword tokens.
+
+ auto break case char
+ const continue default do
+ double else enum extern
+ float for goto if
+ inline int long register
+ restrict return short signed
+ sizeof static struct switch
+ typedef union unsigned void
+ volatile while
+ _Bool _Complex _Imaginary
+
+
+ -- Special token used to represent an identifier that has been declared as a typedef name.
+ -- This is the lexer feedback hack.
+
+ TypedefName
+
+
+ -- These are aliases for lexer tokens.
+
+
+ LeftBracket ::= '['
+ LeftParen ::= '('
+ LeftBrace ::= '{'
+ Dot ::= '.'
+ Arrow ::= '->'
+ PlusPlus ::= '++'
+ MinusMinus ::= '--'
+ And ::= '&'
+ Star ::= '*'
+ Plus ::= '+'
+ Minus ::= '-'
+ Tilde ::= '~'
+ Bang ::= '!'
+ Slash ::= '/'
+ Percent ::= '%'
+ RightShift ::= '>>'
+ LeftShift ::= '<<'
+ LT ::= '<'
+ GT ::= '>'
+ LE ::= '<='
+ GE ::= '>='
+ EQ ::= '=='
+ NE ::= '!='
+ Caret ::= '^'
+ Or ::= '|'
+ AndAnd ::= '&&'
+ OrOr ::= '||'
+ Question ::= '?'
+ Colon ::= ':'
+ DotDotDot ::= '...'
+ Assign ::= '='
+ StarAssign ::= '*='
+ SlashAssign ::= '/='
+ PercentAssign ::= '%='
+ PlusAssign ::= '+='
+ MinusAssign ::= '-='
+ RightShiftAssign ::= '>>='
+ LeftShiftAssign ::= '<<='
+ AndAssign ::= '&='
+ CaretAssign ::= '^='
+ OrAssign ::= '|='
+ Comma ::= ','
+
+
+$End
+
+
+$Globals
+/.
+ import java.util.*;
+
+ import org.eclipse.cdt.core.dom.ast.*;
+ import org.eclipse.cdt.core.dom.lrparser.IKeywordMap;
+ import org.eclipse.cdt.core.dom.lrparser.IParseResult;
+ import org.eclipse.cdt.core.dom.lrparser.IParser;
+ import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+ import org.eclipse.cdt.core.dom.lrparser.action.c99.C99BuildASTParserAction;
+ import org.eclipse.cdt.core.dom.lrparser.action.c99.C99ResolveParserAction;
+ import org.eclipse.cdt.core.dom.lrparser.c99.C99KeywordMap;
+ import org.eclipse.cdt.core.dom.lrparser.c99.C99ParseResult;
+ import org.eclipse.cdt.core.dom.lrparser.preprocessor.IPreprocessorTokenCollector;
+ import org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings.IC99Scope;
+ import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+./
+$End
+
+$Define
+ -- These macros allow the template and header code to be customized by an extending parser.
+ $ast_class /.Object./
+ $additional_interfaces /. , IPreprocessorTokenCollector<IToken> ./
+
+ $build_action_class /. C99BuildASTParserAction ./
+ $resolve_action_class /. C99ResolveParserAction ./
+
+ $keyword_map_class /. C99KeywordMap ./
+ $lexer_class /. C99Lexer ./
+ $action_class /. C99ParserAction ./
+ $data_class /. Object ./ -- allow anything to be passed between actions
+
+ $UndoResolver /.$Undo action.resolver.undo(); $EndUndo./
+
+ $Resolve /. $BeginTrial
+ ./
+ $EndResolve /. $EndTrial
+ $UndoResolver
+ ./ -- undo actions are automatically generated for binding resolution actions
+
+ $Builder /. $BeginFinal
+ ./
+ $EndBuilder /. /*$builder.getASTStack().print();*/ $EndFinal ./
+
+ $resolve /. action.resolver./
+ $builder /. action.builder./
+
+ $setBinding /. provider.getActiveRule().setData./
+ $getBinding /. (IBinding)provider.getActiveRule().getData./
+
+ $setScope /. provider.getActiveRule().setData./
+ $getScope /. (IC99Scope)provider.getActiveRule().getData./
+
+$End
+
+
+$Headers
+/.
+ private C99ParserAction action;
+
+ private List commentTokens = new ArrayList();
+ private IKeywordMap keywordMap = new $keyword_map_class();
+
+ public $action_type() { // constructor
+ this(new $lexer_class());
+ }
+
+ private void initActions() {
+ // binding resolution actions need access to IASTName nodes, temporary
+ action = new C99ParserAction();
+ action.resolver = new $resolve_action_class(this);
+ action.builder = new $build_action_class(this);
+ action.builder.setTokenMap(C99Parsersym.orderedTerminalSymbols);
+ parserAction = action;
+ }
+
+ public void addToken(IToken token) {
+ int newKind = mapKind(token.getKind());
+ if(keywordMap != null && newKind == $prs_type.TK_identifier) {
+ Integer keywordKind = keywordMap.getKeywordKind(token.toString());
+ if(keywordKind != null) {
+ newKind = keywordKind.intValue();
+ }
+ }
+ token.setKind(newKind);
+ super.addToken(token);
+ }
+
+ public void addCommentToken(IToken token) {
+ commentTokens.add(token);
+ }
+
+ public List getCommentTokens() {
+ return commentTokens;
+ }
+
+ public IParseResult parse() {
+ // this has to be done, or... kaboom!
+ setStreamLength(getSize());
+ initActions();
+ commentTokens = new ArrayList();
+
+ final int errorRepairCount = -1; // -1 means full error handling
+ parser(null, errorRepairCount);
+ super.resetTokenStream();
+
+ IASTTranslationUnit tu = action.builder.getAST();
+ boolean encounteredError = action.builder.encounteredError();
+ IASTCompletionNode compNode = action.builder.getASTCompletionNode();
+
+ boolean assertionsEnabled = false;
+ assert assertionsEnabled = true;
+ if(assertionsEnabled) {
+ DebugUtil.assertBindings(tu);
+ }
+
+ action = null;
+ parserAction = null;
+ return new C99ParseResult(tu, compNode, encounteredError);
+ }
+
+ // implements IParserActionTokenProvider.getEOFToken()
+ public IToken getEOFToken() {
+ List tokens = getTokens();
+ IToken eof = (IToken) tokens.get(tokens.size() - 1);
+ return eof;
+ }
+
+ public int getKind(int i) {
+ int kind = super.getKind(i);
+ if(kind == C99Parsersym.TK_identifier && action.resolver.isTypedef(getTokenText(i))) {
+ kind = C99Parsersym.TK_TypedefName;
+ }
+ return kind;
+ }
+
+./
+$End
+
+
+$Start -- the grammar start symbol
+ translation_unit
+$End
+
+
+
+$Rules
+
+-------------------------------------------------------------------------------------------
+-- AST and Symbol Table Scoping
+-------------------------------------------------------------------------------------------
+
+
+<openscope-ast>
+ ::= $empty
+ /.$Action $Builder $builder.openASTScope(); $EndBuilder $EndAction./
+
+<openscope-symbol>
+ ::= $empty
+ /.$Action $Resolve $resolve.openSymbolScope(); $EndResolve $EndAction./
+
+<openscope-declaration>
+ ::= $empty
+ /.$Action $Resolve $resolve.openDeclarationScope(); $EndResolve $EndAction./
+
+<openscope-name> ::= $empty
+
+-------------------------------------------------------------------------------------------
+-- Content assist
+-------------------------------------------------------------------------------------------
+
+']' ::=? 'RightBracket'
+-- | 'EndOfCompletion'
+
+')' ::=? 'RightParen'
+-- | 'EndOfCompletion'
+
+'}' ::=? 'RightBrace'
+-- | 'EndOfCompletion'
+
+';' ::=? 'SemiColon'
+-- | 'EndOfCompletion'
+
+
+
+-------------------------------------------------------------------------------------------
+-- Expressions
+-------------------------------------------------------------------------------------------
+
+
+constant
+ ::= 'integer'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionConstant(IASTLiteralExpression.lk_integer_constant); $EndResolve
+ $Builder $builder.consumeExpressionConstant(IASTLiteralExpression.lk_integer_constant); $EndBuilder
+ $EndAction
+ ./
+ | 'floating'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionConstant(IASTLiteralExpression.lk_float_constant); $EndResolve
+ $Builder $builder.consumeExpressionConstant(IASTLiteralExpression.lk_float_constant); $EndBuilder
+ $EndAction
+ ./
+ | 'charconst'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionConstant(IASTLiteralExpression.lk_char_constant); $EndResolve
+ $Builder $builder.consumeExpressionConstant(IASTLiteralExpression.lk_char_constant); $EndBuilder
+ $EndAction
+ ./
+ | 'stringlit'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionConstant(IASTLiteralExpression.lk_string_literal); $EndResolve
+ $Builder $builder.consumeExpressionConstant(IASTLiteralExpression.lk_string_literal); $EndBuilder
+ $EndAction
+ ./
+
+
+primary_expression
+ ::= constant
+ | primary_expression_id
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeExpressionID()); $EndResolve
+ $Builder $builder.consumeExpressionID($getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | '(' expression ')'
+ /.
+ $Action
+ $Builder $builder.consumeExpressionBracketed(); $EndBuilder
+ $EndAction
+ ./
+
+
+primary_expression_id -- Typedefname not allowed as a variable name.
+ ::= 'identifier'
+ | 'Completion'
+
+
+<openscope-type>
+ ::= $empty
+ /. $Action $Resolve $resolve.openTypeScope(); $EndResolve $EndAction ./
+
+
+postfix_expression
+ ::= primary_expression
+ | postfix_expression '[' expression ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionArraySubscript(); $EndResolve
+ $Builder $builder.consumeExpressionArraySubscript(); $EndBuilder
+ $EndAction
+ ./
+ | postfix_expression '(' ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionFunctionCall(false); $EndResolve
+ $Builder $builder.consumeExpressionFunctionCall(false); $EndBuilder
+ $EndAction
+ ./
+ | postfix_expression '(' <openscope-type> <openscope-ast> argument_expression_list ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionFunctionCall(true); $EndResolve
+ $Builder $builder.consumeExpressionFunctionCall(true); $EndBuilder
+ $EndAction
+ ./
+ | postfix_expression '.' member_name
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeExpressionFieldReference(false)); $EndResolve
+ $Builder $builder.consumeExpressionFieldReference($getBinding(), false); $EndBuilder
+ $EndAction
+ ./
+ | postfix_expression '->' member_name
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeExpressionFieldReference(true)); $EndResolve
+ $Builder $builder.consumeExpressionFieldReference($getBinding(), true); $EndBuilder
+ $EndAction
+ ./
+ | postfix_expression '++'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixIncr); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixIncr); $EndBuilder
+ $EndAction
+ ./
+ | postfix_expression '--'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixDecr); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixDecr); $EndBuilder
+ $EndAction
+ ./
+ | '(' type_name ')' '{' <openscope-type> <openscope-ast> initializer_list comma_opt '}'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionTypeIdInitializer(); $EndResolve
+ $Builder $builder.consumeExpressionTypeIdInitializer(); $EndBuilder
+ $EndAction
+ ./
+
+
+comma_opt
+ ::= ',' | $empty
+
+
+member_name
+ ::= 'identifier'
+ | 'TypedefName'
+ | 'Completion'
+
+
+argument_expression_list
+ ::= assignment_expression
+ | argument_expression_list ',' assignment_expression
+
+
+unary_expression
+ ::= postfix_expression
+ | '++' unary_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixIncr); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixIncr); $EndBuilder
+ $EndAction
+ ./
+ | '--' unary_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixDecr); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixDecr); $EndBuilder
+ $EndAction
+ ./
+ | '&' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_amper); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_amper); $EndBuilder
+ $EndAction
+ ./
+ | '*' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_star); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_star); $EndBuilder
+ $EndAction
+ ./
+ | '+' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_plus); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_plus); $EndBuilder
+ $EndAction
+ ./
+ | '-' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_minus); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_minus); $EndBuilder
+ $EndAction
+ ./
+ | '~' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_tilde); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_tilde); $EndBuilder
+ $EndAction
+ ./
+ | '!' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_not); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_not); $EndBuilder
+ $EndAction
+ ./
+ | 'sizeof' unary_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnaryOperator(IASTUnaryExpression.op_sizeof); $EndResolve
+ $Builder $builder.consumeExpressionUnaryOperator(IASTUnaryExpression.op_sizeof); $EndBuilder
+ $EndAction
+ ./
+ | 'sizeof' '(' type_name ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionUnarySizeofTypeName(); $EndResolve
+ $Builder $builder.consumeExpressionUnarySizeofTypeName(); $EndBuilder
+ $EndAction
+ ./
+
+
+cast_expression
+ ::= unary_expression
+ | '(' type_name ')' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionCast(); $EndResolve
+ $Builder $builder.consumeExpressionCast(); $EndBuilder
+ $EndAction
+ ./
+
+
+multiplicative_expression
+ ::= cast_expression
+ | multiplicative_expression '*' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiply); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiply); $EndBuilder
+ $EndAction
+ ./
+ | multiplicative_expression '/' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_divide); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_divide); $EndBuilder
+ $EndAction
+ ./
+ | multiplicative_expression '%' cast_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_modulo); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_modulo); $EndBuilder
+ $EndAction
+ ./
+
+
+additive_expression
+ ::= multiplicative_expression
+ | additive_expression '+' multiplicative_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_plus); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_plus); $EndBuilder
+ $EndAction
+ ./
+ | additive_expression '-' multiplicative_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_minus); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_minus); $EndBuilder
+ $EndAction
+ ./
+
+
+shift_expression
+ ::= additive_expression
+ | shift_expression '<<' additive_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeft); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeft); $EndBuilder
+ $EndAction
+ ./
+ | shift_expression '>>' additive_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRight); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRight); $EndBuilder
+ $EndAction
+ ./
+
+
+relational_expression
+ ::= shift_expression
+ | relational_expression '<' shift_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessThan); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessThan); $EndBuilder
+ $EndAction
+ ./
+ | relational_expression '>' shift_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterThan); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterThan); $EndBuilder
+ $EndAction
+ ./
+ | relational_expression '<=' shift_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessEqual); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_lessEqual); $EndBuilder
+ $EndAction
+ ./
+ | relational_expression '>=' shift_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterEqual); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_greaterEqual); $EndBuilder
+ $EndAction
+ ./
+
+
+equality_expression
+ ::= relational_expression
+ | equality_expression '==' relational_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_equals); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_equals); $EndBuilder
+ $EndAction
+ ./
+ | equality_expression '!=' relational_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_notequals); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_notequals); $EndBuilder
+ $EndAction
+ ./
+
+
+AND_expression
+ ::= equality_expression
+ | AND_expression '&' equality_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAnd); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAnd); $EndBuilder
+ $EndAction
+ ./
+
+
+exclusive_OR_expression
+ ::= AND_expression
+ | exclusive_OR_expression '^' AND_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXor); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXor); $EndBuilder
+ $EndAction
+ ./
+
+
+inclusive_OR_expression
+ ::= exclusive_OR_expression
+ | inclusive_OR_expression '|' exclusive_OR_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOr); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOr); $EndBuilder
+ $EndAction
+ ./
+
+
+logical_AND_expression
+ ::= inclusive_OR_expression
+ | logical_AND_expression '&&' inclusive_OR_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalAnd); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalAnd); $EndBuilder
+ $EndAction
+ ./
+
+
+logical_OR_expression
+ ::= logical_AND_expression
+ | logical_OR_expression '||' logical_AND_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalOr); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_logicalOr); $EndBuilder
+ $EndAction
+ ./
+
+
+conditional_expression
+ ::= logical_OR_expression
+ | logical_OR_expression '?' expression ':' conditional_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionConditional(); $EndResolve
+ $Builder $builder.consumeExpressionConditional(); $EndBuilder
+ $EndAction
+ ./
+
+
+assignment_expression
+ ::= conditional_expression
+ | unary_expression '=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_assign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_assign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '*=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiplyAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_multiplyAssign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '/=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_divideAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_divideAssign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '%=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_moduloAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_moduloAssign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '+=' assignment_expression
+ /.$Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_plusAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_plusAssign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '-=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_minusAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_minusAssign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '<<=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeftAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftLeftAssign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '>>=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRightAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_shiftRightAssign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '&=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAndAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryAndAssign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '^=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXorAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryXorAssign); $EndBuilder
+ $EndAction
+ ./
+ | unary_expression '|=' assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOrAssign); $EndResolve
+ $Builder $builder.consumeExpressionBinaryOperator(IASTBinaryExpression.op_binaryOrAssign); $EndBuilder
+ $EndAction
+ ./
+
+
+-- special rule to avoid conflict between problem statements and problem expressions
+expression_in_statement
+ ::= <openscope-ast> expression_list
+ /.$Action $Builder $builder.consumeExpression(); $EndBuilder $EndAction./
+
+
+expression
+ ::= <openscope-ast> expression_list
+ /.$Action $Builder $builder.consumeExpression(); $EndBuilder $EndAction./
+
+
+expression_list
+ ::= assignment_expression
+ | expression_list ',' assignment_expression
+
+
+constant_expression
+ ::= conditional_expression
+
+
+-------------------------------------------------------------------------------------------
+-- Statements
+-------------------------------------------------------------------------------------------
+
+
+
+statement
+ ::= labeled_statement
+ | compound_statement
+ | expression_statement
+ | selection_statement
+ | iteration_statement
+ | jump_statement
+ | ERROR_TOKEN
+ /.$Action $Builder $builder.consumeStatementProblem(); $EndBuilder $EndAction./
+
+
+labeled_statement
+ ::= identifier_or_typedefname ':' statement
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeStatementLabeled()); $EndResolve
+ $Builder $builder.consumeStatementLabeled($getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | 'case' constant_expression ':'
+ /.$Action $Builder $builder.consumeStatementCase(); $EndBuilder $EndAction./
+ | 'default' ':'
+ /.$Action $Builder $builder.consumeStatementDefault(); $EndBuilder $EndAction./
+
+
+compound_statement
+ ::= <openscope-symbol> '{' '}'
+ /.
+ $Action
+ $Resolve $setScope($resolve.closeSymbolScope()); $EndResolve
+ $Builder $builder.consumeStatementCompoundStatementEmpty($getScope()); $EndBuilder
+
+ $EndAction
+ ./
+ | <openscope-symbol> '{' <openscope-ast> block_item_list '}'
+ /.
+ $Action
+ $Resolve $setScope($resolve.closeSymbolScope()); $EndResolve
+ $Builder $builder.consumeStatementCompoundStatement($getScope()); $EndBuilder
+ $EndAction
+ ./
+
+
+block_item_list
+ ::= block_item
+ | block_item_list block_item
+
+
+block_item
+ ::= statement
+ | declaration
+ /.$Action $Builder $builder.consumeStatementDeclaration(); $EndBuilder $EndAction./
+
+
+expression_statement
+ ::= ';'
+ /.$Action $Builder $builder.consumeStatementNull(); $EndBuilder $EndAction./
+ | expression_in_statement ';'
+ /.$Action $Builder $builder.consumeStatementExpression(); $EndBuilder $EndAction./
+
+
+selection_statement
+ ::= 'if' '(' expression ')' statement
+ /.$Action $Builder $builder.consumeStatementIfThen(); $EndBuilder $EndAction./
+ | 'if' '(' expression ')' statement 'else' statement
+ /.$Action $Builder $builder.consumeStatementIfThenElse(); $EndBuilder $EndAction./
+ | 'switch' '(' expression ')' statement
+ /.$Action $Builder $builder.consumeStatementSwitch(); $EndBuilder $EndAction./
+
+
+expression_opt
+ ::= expression
+ | $empty
+ /.$Action $Builder $builder.consumeExpressionOptional(); $EndBuilder $EndAction./
+
+
+iteration_statement
+ ::= 'do' statement 'while' '(' expression ')' ';'
+ /.$Action $Builder $builder.consumeStatementDoLoop(); $EndBuilder $EndAction./
+ | 'while' '(' expression ')' statement
+ /.$Action $Builder $builder.consumeStatementWhileLoop(); $EndBuilder $EndAction./
+ | <openscope-symbol> 'for' '(' expression_opt ';' expression_opt ';' expression_opt ')' statement
+ /.
+ $Action
+ $Resolve $resolve.closeSymbolScope(); $EndResolve
+ $Builder $builder.consumeStatementForLoop(); $EndBuilder
+ $EndAction
+ ./
+ | <openscope-symbol> 'for' '(' declaration expression_opt ';' expression_opt ')' statement
+ /.
+ $Action
+ $Resolve $resolve.closeSymbolScope(); $EndResolve
+ $Builder $builder.consumeStatementForLoop(); $EndBuilder
+ $EndAction
+ ./
+
+
+jump_statement
+ ::= 'goto' identifier_or_typedefname ';'
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeStatementGoto()); $EndResolve
+ $Builder $builder.consumeStatementGoto($getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | 'continue' ';'
+ /.$Action $Builder $builder.consumeStatementContinue(); $EndBuilder $EndAction./
+ | 'break' ';'
+ /.$Action $Builder $builder.consumeStatementBreak(); $EndBuilder $EndAction./
+ | 'return' ';'
+ /.$Action $Builder $builder.consumeStatementReturn(false); $EndBuilder $EndAction./
+ | 'return' expression ';'
+ /.$Action $Builder $builder.consumeStatementReturn(true); $EndBuilder $EndAction./
+
+
+
+-------------------------------------------------------------------------------------------
+-- Declarations
+-------------------------------------------------------------------------------------------
+
+
+
+declaration
+ ::= declaration_specifiers ';'
+ /.
+ $Action
+ $Resolve $resolve.closeDeclarationScope(); $EndResolve
+ $Builder $builder.consumeDeclaration(false); $EndBuilder
+ $EndAction
+ ./
+ | declaration_specifiers <openscope-ast> init_declarator_list ';'
+ /.
+ $Action
+ $Resolve $resolve.closeDeclarationScope(); $EndResolve
+ $Builder $builder.consumeDeclaration(true); $EndBuilder
+ $EndAction
+ ./
+
+
+declaration_specifiers
+ ::= <openscope-declaration> <openscope-ast> simple_declaration_specifiers
+ /.$Action $Builder $builder.consumeDeclarationSpecifiersSimple(); $EndBuilder $EndAction./
+ | <openscope-declaration> <openscope-ast> struct_or_union_declaration_specifiers
+ /.$Action $Builder $builder.consumeDeclarationSpecifiersStructUnionEnum(); $EndBuilder $EndAction./
+ | <openscope-declaration> <openscope-ast> elaborated_declaration_specifiers
+ /.$Action $Builder $builder.consumeDeclarationSpecifiersStructUnionEnum(); $EndBuilder $EndAction./
+ | <openscope-declaration> <openscope-ast> enum_declaration_specifiers
+ /.$Action $Builder $builder.consumeDeclarationSpecifiersStructUnionEnum(); $EndBuilder $EndAction./
+ | <openscope-declaration> <openscope-ast> typdef_name_declaration_specifiers
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeDeclarationSpecifiersTypedefName()); $EndResolve
+ $Builder $builder.consumeDeclarationSpecifiersTypedefName($getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+no_type_declaration_specifier
+ ::= storage_class_specifier
+ | type_qualifier
+ | function_specifier
+
+
+no_type_declaration_specifiers
+ ::= no_type_declaration_specifier
+ | no_type_declaration_specifiers no_type_declaration_specifier
+
+
+simple_declaration_specifiers
+ ::= type_specifier
+ | no_type_declaration_specifiers type_specifier
+ | simple_declaration_specifiers type_specifier
+ | simple_declaration_specifiers no_type_declaration_specifier
+
+
+struct_or_union_declaration_specifiers
+ ::= struct_or_union_specifier
+ | no_type_declaration_specifiers struct_or_union_specifier
+ | struct_or_union_declaration_specifiers no_type_declaration_specifier
+
+
+elaborated_declaration_specifiers
+ ::= elaborated_specifier
+ | no_type_declaration_specifiers elaborated_specifier
+ | elaborated_declaration_specifiers no_type_declaration_specifier
+
+
+enum_declaration_specifiers
+ ::= enum_specifier
+ | no_type_declaration_specifiers enum_specifier
+ | enum_declaration_specifiers no_type_declaration_specifier
+
+
+typdef_name_declaration_specifiers
+ ::= typedef_name
+ | no_type_declaration_specifiers typedef_name
+ | typdef_name_declaration_specifiers no_type_declaration_specifier
+
+
+init_declarator_list
+ ::= init_declarator
+ | init_declarator_list ',' init_declarator
+
+
+init_declarator
+ ::= complete_declarator
+ /.
+ $Action
+ $Resolve $resolve.consumeInitDeclarator(); $EndResolve
+ $EndAction
+ ./
+ | complete_declarator '=' initializer
+ /.
+ $Action
+ $Resolve $resolve.consumeInitDeclarator(); $EndResolve
+ $Builder $builder.consumeDeclaratorWithInitializer(); $EndBuilder
+ $EndAction
+ ./
+
+
+complete_declarator
+ ::= declarator
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeDeclaratorComplete()); $EndResolve
+ $Builder $builder.consumeDeclaratorComplete($getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+storage_class_specifier
+ ::= storage_class_specifier_token
+ /.
+ $Action
+ $Resolve $resolve.consumeDeclSpecToken(); $EndResolve
+ $Builder $builder.consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+
+storage_class_specifier_token
+ ::= 'typedef'
+ | 'extern'
+ | 'static'
+ | 'auto'
+ | 'register'
+
+
+type_specifier
+ ::= type_specifier_token
+ /.
+ $Action
+ $Resolve $resolve.consumeDeclSpecToken(); $EndResolve
+ $Builder $builder.consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+type_specifier_token
+ ::= 'void'
+ | 'char'
+ | 'short'
+ | 'int'
+ | 'long'
+ | 'float'
+ | 'double'
+ | 'signed'
+ | 'unsigned'
+ | '_Bool'
+ | '_Complex'
+ | '_Imaginary'
+
+
+typedef_name
+ ::= 'TypedefName'
+ /.
+ $Action
+ $Resolve $resolve.consumeDeclSpecToken(); $EndResolve
+ $Builder $builder.consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+
+identifier_or_typedefname
+ ::= 'identifier'
+ | 'TypedefName'
+
+
+struct_or_union_specifier
+ ::= 'struct' '{' <openscope-name> <openscope-ast> struct_declaration_list_opt '}'
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_struct)); $EndResolve
+ $Builder $builder.consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_struct, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | 'union' '{' <openscope-name> <openscope-ast> struct_declaration_list_opt '}'
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_union)); $EndResolve
+ $Builder $builder.consumeTypeSpecifierComposite(false, IASTCompositeTypeSpecifier.k_union, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | 'struct' identifier_or_typedefname '{' <openscope-name> <openscope-ast> struct_declaration_list_opt '}'
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_struct)); $EndResolve
+ $Builder $builder.consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_struct, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | 'union' identifier_or_typedefname '{' <openscope-name> <openscope-ast> struct_declaration_list_opt '}'
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_union)); $EndResolve
+ $Builder $builder.consumeTypeSpecifierComposite(true, IASTCompositeTypeSpecifier.k_union, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+elaborated_specifier
+ ::= 'struct' identifier_or_typedefname
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeTypeSpecifierElaborated(IASTCompositeTypeSpecifier.k_struct)); $EndResolve
+ $Builder $builder.consumeTypeSpecifierElaborated(IASTCompositeTypeSpecifier.k_struct, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | 'union' identifier_or_typedefname
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeTypeSpecifierElaborated(IASTCompositeTypeSpecifier.k_union)); $EndResolve
+ $Builder $builder.consumeTypeSpecifierElaborated(IASTCompositeTypeSpecifier.k_union, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | 'enum' identifier_or_typedefname
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeTypeSpecifierElaborated(IASTElaboratedTypeSpecifier.k_enum)); $EndResolve
+ $Builder $builder.consumeTypeSpecifierElaborated(IASTElaboratedTypeSpecifier.k_enum, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+struct_declaration_list_opt
+ ::= struct_declaration_list
+ | $empty
+
+struct_declaration_list
+ ::= struct_declaration
+ | struct_declaration_list struct_declaration
+
+
+struct_declaration
+ ::= specifier_qualifier_list <openscope-ast> struct_declarator_list ';' -- regular declarators plus bit fields
+ /.
+ $Action
+ $Resolve $resolve.closeDeclarationScope(); $EndResolve
+ $Builder $builder.consumeStructDeclaration(true); $EndBuilder
+ $EndAction
+ ./
+ | specifier_qualifier_list ';'
+ /.
+ $Action
+ $Resolve $resolve.closeDeclarationScope(); $EndResolve
+ $Builder $builder.consumeStructDeclaration(false); $EndBuilder
+ $EndAction
+ ./
+
+
+-- just reuse declaration_specifiers, makes grammar a bit more lenient but thats OK
+specifier_qualifier_list
+ ::= declaration_specifiers
+
+
+struct_declarator_list
+ ::= complete_struct_declarator
+ | struct_declarator_list ',' complete_struct_declarator
+
+
+complete_struct_declarator
+ ::= struct_declarator
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeDeclaratorCompleteField()); $EndResolve
+ $Builder $builder.consumeDeclaratorCompleteField($getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+struct_declarator
+ ::= declarator
+ | ':' constant_expression
+ /.$Action $Builder $builder.consumeStructBitField(false); $EndBuilder $EndAction./
+ | declarator ':' constant_expression
+ /.$Action $Builder $builder.consumeStructBitField(true); $EndBuilder $EndAction./
+
+
+enum_specifier
+ ::= 'enum' '{' <openscope-name> <openscope-ast> enumerator_list_opt comma_opt '}'
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeTypeSpecifierEnumeration(false)); $EndResolve
+ $Builder $builder.consumeTypeSpecifierEnumeration(false, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | 'enum' identifier_or_typedefname '{' <openscope-name> <openscope-ast> enumerator_list_opt comma_opt '}'
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeTypeSpecifierEnumeration(true)); $EndResolve
+ $Builder $builder.consumeTypeSpecifierEnumeration(true, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+
+enumerator_list_opt
+ ::= enumerator_list
+ | $empty
+
+
+enumerator_list
+ ::= enumerator
+ | enumerator_list ',' enumerator
+
+
+enumerator
+ ::= identifier_or_typedefname
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeEnumerator(false)); $EndResolve
+ $Builder $builder.consumeEnumerator(false, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | identifier_or_typedefname '=' constant_expression
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeEnumerator(false)); $EndResolve
+ $Builder $builder.consumeEnumerator(false, $getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+type_qualifier
+ ::= type_qualifier_token
+ /.
+ $Action
+ $Resolve $resolve.consumeDeclSpecToken(); $EndResolve
+ $Builder $builder.consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+
+type_qualifier_token
+ ::= 'const'
+ | 'restrict'
+ | 'volatile'
+
+
+function_specifier
+ ::= 'inline'
+ /.$Action
+ $Resolve $resolve.consumeDeclSpecToken(); $EndResolve
+ $Builder $builder.consumeDeclSpecToken(); $EndBuilder
+ $EndAction
+ ./
+
+
+declarator
+ ::= direct_declarator
+ | <openscope-ast> pointer direct_declarator
+ /.
+ $Action
+ $Resolve $resolve.consumeDeclaratorWithPointer(); $EndResolve
+ $Builder $builder.consumeDeclaratorWithPointer(true); $EndBuilder
+ $EndAction
+ ./
+
+
+direct_declarator
+ ::= array_direct_declarator
+ | function_prototype_direct_declarator
+ | basic_direct_declarator
+
+
+basic_direct_declarator
+ ::= 'identifier'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorIdentifier(); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorIdentifier(); $EndBuilder
+ $EndAction
+ ./
+ | '(' declarator ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorBracketed(); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorBracketed(); $EndBuilder
+ $EndAction
+ ./
+
+
+array_direct_declarator
+ ::= basic_direct_declarator array_modifier
+ /.
+ $Action
+ $Resolve /*$resolve.consumeDirectDeclaratorArrayDeclarator();*/ $EndResolve
+ $Builder $builder.consumeDirectDeclaratorArrayDeclarator(); $EndBuilder
+ $EndAction
+ ./
+ | array_direct_declarator array_modifier
+ /.
+ $Action
+ $Resolve /*$resolve.consumeDirectDeclaratorArrayDeclarator();*/ $EndResolve
+ $Builder $builder.consumeDirectDeclaratorArrayDeclarator(); $EndBuilder
+ $EndAction
+ ./
+
+
+function_prototype_direct_declarator
+ ::= function_direct_declarator
+ /.$Action $Resolve $resolve.closeSymbolScope(); $EndResolve $EndAction./
+
+
+function_direct_declarator
+ ::= basic_direct_declarator '(' <openscope-name> <openscope-symbol> <openscope-ast> parameter_type_list ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorFunctionDeclarator(); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorFunctionDeclarator(true); $EndBuilder
+ $EndAction
+ ./
+ | basic_direct_declarator '(' <openscope-name> <openscope-symbol> ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorFunctionDeclarator(); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorFunctionDeclarator(false); $EndBuilder
+ $EndAction
+ ./
+
+
+function_declarator
+ ::= function_direct_declarator
+ | <openscope-ast> pointer function_direct_declarator
+ /.
+ $Action
+ $Resolve $resolve.consumeDeclaratorWithPointer(); $EndResolve
+ $Builder $builder.consumeDeclaratorWithPointer(true); $EndBuilder
+ $EndAction
+ ./
+
+
+-- This is a hack because the parser cannot tell the difference between
+-- plain identifiers and types. Because of this an identifier_list would
+-- always be parsed as a parameter_type_list instead. In a KnR funciton
+-- definition we can use the extra list of declarators to disambiguate.
+-- This rule should be merged back into direct_declarator if type info is
+-- added to the parser.
+--knr_direct_declarator
+-- ::= basic_direct_declarator '(' <openscope-ast> identifier_list ')'
+-- -- /.$ba consumeDirectDeclaratorFunctionDeclaratorKnR(); $ea./
+--
+--
+--knr_function_declarator
+-- ::= knr_direct_declarator
+-- | <openscope> pointer knr_direct_declarator
+-- -- /.$ba consumeDeclaratorWithPointer(true); $ea./
+--
+--identifier_list
+-- ::= 'identifier'
+-- -- /.$ba consumeName(); $ea./
+-- | identifier_list ',' 'identifier'
+-- -- /.$ba consumeName(); $ea./
+
+
+array_modifier
+ ::= '[' ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorArrayModifier(); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorArrayModifier(false); $EndBuilder
+ $EndAction
+ ./
+ | '[' <openscope-ast> array_modifier_type_qualifiers ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorModifiedArrayModifier(false, false, true); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorModifiedArrayModifier(false, false, true, false); $EndBuilder
+ $EndAction
+ ./
+ | '[' assignment_expression ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorArrayModifier(); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorArrayModifier(true); $EndBuilder
+ $EndAction
+ ./
+ | '[' <openscope-ast> array_modifier_type_qualifiers assignment_expression ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorModifiedArrayModifier(false, false, true); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorModifiedArrayModifier(false, false, true, true); $EndBuilder
+ $EndAction
+ ./
+ | '[' 'static' assignment_expression ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorModifiedArrayModifier(true, false, false); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorModifiedArrayModifier(true, false, false, true); $EndBuilder
+ $EndAction
+ ./
+ | '[' 'static' <openscope-ast> array_modifier_type_qualifiers assignment_expression ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorModifiedArrayModifier(true, false, true); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorModifiedArrayModifier(true, false, true, true); $EndBuilder
+ $EndAction
+ ./
+ | '[' <openscope-ast> array_modifier_type_qualifiers 'static' assignment_expression ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorModifiedArrayModifier(true, false, true); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorModifiedArrayModifier(true, false, true, true); $EndBuilder
+ $EndAction
+ ./
+ | '[' '*' ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorModifiedArrayModifier(false, true, false); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorModifiedArrayModifier(false, true, false, false); $EndBuilder
+ $EndAction
+ ./
+ | '[' <openscope-ast> array_modifier_type_qualifiers '*' ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDirectDeclaratorModifiedArrayModifier(false, true, true); $EndResolve
+ $Builder $builder.consumeDirectDeclaratorModifiedArrayModifier(false, true, true, false); $EndBuilder
+ $EndAction
+ ./
+
+
+array_modifier_type_qualifiers
+ ::= type_qualifier_list
+ /.$Action $Resolve $resolve.consumeTypeQualifiers(); $EndResolve $EndAction./
+
+
+<openscope-pointer>
+ ::= $empty
+ /.$Action $Resolve $resolve.openPointerScope(); $EndResolve $EndAction./
+
+
+pointer
+ ::= <openscope-pointer> pointers
+
+
+pointers
+ ::= '*'
+ /.
+ $Action
+ $Resolve $resolve.consumePointer(); $EndResolve
+ $Builder $builder.consumePointer(); $EndBuilder
+ $EndAction
+ ./
+ | pointers '*'
+ /.
+ $Action
+ $Resolve $resolve.consumePointer(); $EndResolve
+ $Builder $builder.consumePointer(); $EndBuilder
+ $EndAction
+ ./
+ | '*' <openscope-ast> pointer_type_qualifiers
+ /.
+ $Action
+ $Resolve $resolve.consumePointerTypeQualifierList(); $EndResolve
+ $Builder $builder.consumePointerTypeQualifierList(); $EndBuilder
+ $EndAction
+ ./
+ | pointers '*' <openscope-ast> pointer_type_qualifiers
+ /.
+ $Action
+ $Resolve $resolve.consumePointerTypeQualifierList(); $EndResolve
+ $Builder $builder.consumePointerTypeQualifierList(); $EndBuilder
+ $EndAction
+ ./
+
+
+pointer_type_qualifiers
+ ::= type_qualifier_list
+ /.$Action $Resolve $resolve.consumeTypeQualifiers(); $EndResolve $EndAction./
+
+
+type_qualifier_list
+ ::= type_qualifier
+ | type_qualifier_list type_qualifier
+
+
+parameter_type_list
+ ::= parameter_list
+ | parameter_list ',' '...'
+ | '...' -- not spec
+
+
+parameter_list
+ ::= parameter_declaration
+ | parameter_list ',' parameter_declaration
+
+
+parameter_declaration
+ ::= declaration_specifiers complete_parameter_declarator
+ /.
+ $Action
+ $Builder $builder.consumeParameterDeclaration(); $EndBuilder
+ $EndAction
+ ./
+ | declaration_specifiers
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeParameterDeclarationWithoutDeclarator()); $EndResolve
+ $Builder $builder.consumeParameterDeclarationWithoutDeclarator($getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+complete_parameter_declarator
+ ::= declarator
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeDeclaratorCompleteParameter()); $EndResolve
+ $Builder $builder.consumeDeclaratorCompleteParameter($getBinding()); $EndBuilder
+ $EndAction
+ ./
+ | abstract_declarator
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeDeclaratorCompleteParameter()); $EndResolve
+ $Builder $builder.consumeDeclaratorCompleteParameter($getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+-- only used in expressions, eg) sizeof, casts etc...
+type_name
+ ::= specifier_qualifier_list
+ /.
+ $Action
+ $Resolve $resolve.consumeTypeId(); $EndResolve
+ $Builder $builder.consumeTypeId(false); $EndBuilder
+ $EndAction
+ ./
+ | specifier_qualifier_list abstract_declarator
+ /.
+ $Action
+ $Resolve $resolve.consumeTypeId(); $EndResolve
+ $Builder $builder.consumeTypeId(true); $EndBuilder
+ $EndAction
+ ./
+
+
+abstract_declarator -- a declarator that does not include an identifier
+ ::= direct_abstract_declarator
+ | <openscope-ast> pointer
+ /.
+ $Action
+ $Resolve $resolve.consumeDeclaratorWithPointer(); $EndResolve
+ $Builder $builder.consumeDeclaratorWithPointer(false); $EndBuilder
+ $EndAction
+ ./
+ | <openscope-ast> pointer direct_abstract_declarator
+ /.
+ $Action
+ $Resolve $resolve.consumeDeclaratorWithPointer(); $EndResolve
+ $Builder $builder.consumeDeclaratorWithPointer(true); $EndBuilder
+ $EndAction
+ ./
+
+
+-- rewritten to use the more general array_modifier rule
+direct_abstract_declarator
+ ::= '(' abstract_declarator ')'
+ /.
+ $Action
+ $Builder $builder.consumeDirectDeclaratorBracketed(); $EndBuilder
+ $EndAction
+ ./
+ | array_modifier
+ /.
+ $Action
+ $Resolve $resolve.consumeAbstractDeclaratorArrayModifier(); $EndResolve
+ $Builder $builder.consumeAbstractDeclaratorArrayModifier(false); $EndBuilder
+ $EndAction
+ ./
+ | direct_abstract_declarator array_modifier
+ /.
+ $Action
+ $Resolve $resolve.consumeAbstractDeclaratorArrayModifier(); $EndResolve
+ $Builder $builder.consumeAbstractDeclaratorArrayModifier(true); $EndBuilder
+ $EndAction
+ ./
+ | '(' ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeAbstractDeclaratorFunctionDeclarator(); $EndResolve
+ $Builder $builder.consumeAbstractDeclaratorFunctionDeclarator(false, false); $EndBuilder
+ $EndAction
+ ./
+ | direct_abstract_declarator '(' ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeAbstractDeclaratorFunctionDeclarator(); $EndResolve
+ $Builder $builder.consumeAbstractDeclaratorFunctionDeclarator(true, false); $EndBuilder
+ $EndAction
+ ./
+ | '(' <openscope-name> <openscope-ast> parameter_type_list ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeAbstractDeclaratorFunctionDeclarator(); $EndResolve
+ $Builder $builder.consumeAbstractDeclaratorFunctionDeclarator(false, true); $EndBuilder
+ $EndAction
+ ./
+ | direct_abstract_declarator '(' <openscope-name> <openscope-ast> parameter_type_list ')'
+ /.
+ $Action
+ $Resolve $resolve.consumeAbstractDeclaratorFunctionDeclarator(); $EndResolve
+ $Builder $builder.consumeAbstractDeclaratorFunctionDeclarator(true, true); $EndBuilder
+ $EndAction
+ ./
+
+
+
+initializer
+ ::= assignment_expression
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionInitializer(); $EndResolve
+ $Builder $builder.consumeInitializer(); $EndBuilder
+ $EndAction
+ ./
+ | '{' <openscope-type> <openscope-ast> initializer_list comma_opt '}'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionTypeIdInitializer(); $EndResolve
+ $Builder $builder.consumeInitializerList(); $EndBuilder
+ $EndAction
+ ./
+
+initializer_list
+ ::= positional initializer
+ | designated_initializer
+ | initializer_list ',' positional initializer
+ | initializer_list ',' designated_initializer
+
+positional
+ ::= $empty
+ /.
+ $Action
+ $Resolve $resolve.consumeInitializerStartPositional(); $EndResolve
+ $EndAction
+ ./
+
+designated_initializer
+ ::= <openscope-ast> designation '=' initializer
+ /.$Action $Builder $builder.consumeInitializerDesignated(); $EndBuilder $EndAction./
+
+
+designation
+ ::= designator_list
+
+
+designator_list
+ ::= designator_base
+ | designator_list designator
+
+
+designator_base
+ ::= '[' constant_expression ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeDesignatorBaseArray(); $EndResolve
+ $Builder $builder.consumeDesignatorArray(); $EndBuilder
+ $EndAction
+ ./
+ | '.' identifier_or_typedefname
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeDesignatorBaseField()); $EndResolve
+ $Builder $builder.consumeDesignatorField($getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+designator
+ ::= '[' constant_expression ']'
+ /.
+ $Action
+ $Resolve $resolve.consumeExpressionArraySubscript(); $EndResolve
+ $Builder $builder.consumeDesignatorArray(); $EndBuilder
+ $EndAction
+ ./
+ | '.' identifier_or_typedefname
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeExpressionFieldReference(false)); $EndResolve
+ $Builder $builder.consumeDesignatorField($getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+-------------------------------------------------------------------------------------------
+-- External Definitions
+-------------------------------------------------------------------------------------------
+
+translation_unit
+ ::= external_declaration_list
+ /.
+ $Action
+ $Resolve $setScope($resolve.getCurrentScope()); $EndResolve
+ $Builder $builder.consumeTranslationUnit($getScope()); $EndBuilder
+ $EndAction
+ ./
+ | $empty
+ /.
+ $Action
+ $Resolve $setScope($resolve.getCurrentScope()); $EndResolve
+ $Builder $builder.consumeTranslationUnit($getScope()); $EndBuilder
+ $EndAction
+ ./
+
+
+external_declaration_list
+ ::= external_declaration
+ | external_declaration_list external_declaration
+
+
+external_declaration
+ ::= function_definition
+ | declaration
+ | ';'
+ /.$Action $Builder $builder.consumeDeclarationEmpty(); $EndBuilder $EndAction./
+ | ERROR_TOKEN
+ /.$Action $Builder $builder.consumeDeclarationProblem(); $EndBuilder $EndAction./
+
+
+declaration_list
+ ::= declaration
+ | declaration_list declaration
+
+
+-- The extra <openscope-ast> nonterminal before declarator in this rule is only there
+-- to avoid a shift/reduce error with the rule for declaration.
+-- The symbol table scoped is opened in the rule for function_definition_direct_declarator
+function_definition
+ ::= declaration_specifiers <openscope-ast> function_definition_direct_declarator <openscope-name> function_body
+ /.
+ $Action
+ $Resolve $resolve.consumeFunctionDefinition(); $EndResolve
+ $Builder $builder.consumeFunctionDefinition(true); $EndBuilder
+ $EndAction
+ ./
+
+ -- this rule is here as a special case (its not C99 spec) just to support implicit int in function definitions
+ | <openscope-declaration> <openscope-ast> function_definition_direct_declarator <openscope-name> function_body
+ /.
+ $Action
+ $Resolve $resolve.consumeFunctionDefinition(); $EndResolve
+ $Builder $builder.consumeFunctionDefinition(false); $EndBuilder
+ $EndAction
+ ./
+
+
+
+
+-- comment out KnR for now
+--| declaration_specifiers <openscope-ast> knr_function_declarator <openscope-ast> declaration_list compound_statement
+-- /.$ba $resolve.closeDeclarationScope(); $ea./
+--
+
+
+
+
+-- the symbol table scope that holds the parameter declarations is not closed
+-- until after the body of the function has been parsed
+function_definition_direct_declarator
+ ::= function_direct_declarator
+ /.
+ $Action
+ $Resolve $setBinding($resolve.consumeFunctionDefinitionHeader()); $EndResolve
+ $Builder $builder.consumeFunctionDefinitionHeader($getBinding()); $EndBuilder
+ $EndAction
+ ./
+
+
+-- same syntax as compound_statement but a symbol table scope isn't opened
+function_body
+ ::= '{' '}'
+ /.
+ $Action
+ $Resolve $setScope($resolve.getCurrentScope()); $EndResolve
+ $Builder $builder.consumeStatementCompoundStatementEmpty($getScope()); $EndBuilder
+ $EndAction
+ ./
+ | '{' <openscope-ast> block_item_list '}'
+ /.
+ $Action
+ $Resolve $setScope($resolve.getCurrentScope()); $EndResolve
+ $Builder $builder.consumeStatementCompoundStatement($getScope()); $EndBuilder
+ $EndAction
+ ./
+
+$End
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99ArrayType.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99ArrayType.java
new file mode 100644
index 00000000000..398de9359ae
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99ArrayType.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+
+public class C99ArrayType implements ICArrayType, ITypeContainer {
+
+ private boolean isConst;
+ private boolean isRestrict;
+ private boolean isStatic;
+ private boolean isVolatile;
+ private boolean isVariableLength;
+
+ private IType type;
+
+
+ public C99ArrayType() {
+ }
+
+ public C99ArrayType(IType type) {
+ this.type = type;
+ }
+
+ public boolean isConst() {
+ return isConst;
+ }
+
+ public void setConst(boolean isConst) {
+ this.isConst = isConst;
+ }
+
+ public boolean isRestrict() {
+ return isRestrict;
+ }
+
+ public void setRestrict(boolean isRestrict) {
+ this.isRestrict = isRestrict;
+ }
+
+ public boolean isStatic() {
+ return isStatic;
+ }
+
+ public void setStatic(boolean isStatic) {
+ this.isStatic = isStatic;
+ }
+
+ public boolean isVolatile() {
+ return isVolatile;
+ }
+
+ public void setVolatile(boolean isVolatile) {
+ this.isVolatile = isVolatile;
+ }
+
+ public boolean isVariableLength() {
+ return isVariableLength;
+ }
+
+ public void setVariableLength(boolean isVariableLength) {
+ this.isVariableLength = isVariableLength;
+ }
+
+ public IASTExpression getArraySizeExpression() throws DOMException {
+ return null;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public void setType(IType type) {
+ this.type = type;
+ }
+
+ public boolean isSameType(IType t) {
+ if(t == this)
+ return true;
+ if(t instanceof ITypedef)
+ return t.isSameType(this);
+ if(t instanceof ICArrayType) {
+ ICArrayType at = (ICArrayType)t;
+ try {
+ if(at.isConst() == isConst &&
+ at.isRestrict() == isRestrict &&
+ at.isStatic() == isStatic &&
+ at.isVolatile() == isVolatile &&
+ at.isVariableLength() == isVariableLength) {
+ return at.isSameType(type);
+ }
+ } catch(DOMException _) { }
+ }
+ return false;
+ }
+
+
+ public C99ArrayType clone() {
+ C99ArrayType clone = null;
+ try {
+ clone = (C99ArrayType) super.clone();
+ clone.type = (IType) type.clone();
+ } catch (CloneNotSupportedException e) {
+ assert false; // not going to happen
+ }
+ return clone;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99BasicType.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99BasicType.java
new file mode 100644
index 00000000000..32d391ba56a
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99BasicType.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
+
+public class C99BasicType implements ICBasicType {
+
+ /* Type flags given in IBasicType */
+ private int type;
+
+ private boolean isLong;
+ private boolean isShort;
+ private boolean isSigned;
+ private boolean isUnsigned;
+ private boolean isComplex;
+ private boolean isImaginary;
+ private boolean isLongLong;
+
+
+ public C99BasicType() {
+ }
+
+ public C99BasicType(int type) {
+ this.type = type;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public boolean isLong() {
+ return isLong;
+ }
+
+ public void setLong(boolean isLong) {
+ this.isLong = isLong;
+ }
+
+ public boolean isShort() {
+ return isShort;
+ }
+
+ public void setShort(boolean isShort) {
+ this.isShort = isShort;
+ }
+
+ public boolean isSigned() {
+ return isSigned;
+ }
+
+ public void setSigned(boolean isSigned) {
+ this.isSigned = isSigned;
+ }
+
+ public boolean isUnsigned() {
+ return isUnsigned;
+ }
+
+ public void setUnsigned(boolean isUnsigned) {
+ this.isUnsigned = isUnsigned;
+ }
+
+ public boolean isComplex() {
+ return isComplex;
+ }
+
+ public void setComplex(boolean isComplex) {
+ this.isComplex = isComplex;
+ }
+
+ public boolean isImaginary() {
+ return isImaginary;
+ }
+
+ public void setImaginary(boolean isImaginary) {
+ this.isImaginary = isImaginary;
+ }
+
+ public boolean isLongLong() {
+ return isLongLong;
+ }
+
+ public void setLongLong(boolean isLongLong) {
+ this.isLongLong = isLongLong;
+ }
+
+ public IASTExpression getValue() {
+ return null;
+ }
+
+ public boolean isSameType(IType t) {
+ if(t == this)
+ return true;
+ if(!(t instanceof C99BasicType))
+ return false;
+
+ C99BasicType bt = (C99BasicType) t;
+ return bt.type == this.type &&
+ bt.isLong == this.isLong &&
+ bt.isShort == this.isShort &&
+ bt.isSigned == this.isSigned &&
+ bt.isUnsigned == this.isUnsigned &&
+ bt.isComplex == this.isComplex &&
+ bt.isImaginary == this.isImaginary &&
+ bt.isLongLong == this.isLongLong;
+ }
+
+ public C99BasicType clone() {
+ try {
+ return (C99BasicType) super.clone();
+ } catch (CloneNotSupportedException e) {
+ assert false;
+ return null;
+ }
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99CompositeTypeScope.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99CompositeTypeScope.java
new file mode 100644
index 00000000000..d7c30ac260c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99CompositeTypeScope.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
+
+public class C99CompositeTypeScope extends C99Scope implements ICCompositeTypeScope {
+
+
+ private ICompositeType struct;
+
+
+ public C99CompositeTypeScope(ICompositeType struct) {
+ this.struct = struct;
+ }
+
+ public ICompositeType getCompositeType() {
+ return struct;
+ }
+
+ public IBinding getBinding(char[] name) throws DOMException {
+ throw new UnsupportedOperationException();
+ }
+
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java
new file mode 100644
index 00000000000..0edb9bd1da8
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.core.runtime.PlatformObject;
+
+public class C99Enumeration extends PlatformObject implements IC99Binding, IEnumeration, ITypeable {
+
+ private List<IEnumerator> enumerators = new ArrayList<IEnumerator>();
+ private String name;
+
+ private IScope scope;
+
+
+ public C99Enumeration() {
+ }
+
+ public C99Enumeration(String name) {
+ this.name = name;
+ }
+
+ public void addEnumerator(IEnumerator e) {
+ enumerators.add(e);
+ }
+
+ public IEnumerator[] getEnumerators() {
+ return enumerators.toArray(new IEnumerator[enumerators.size()]);
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public char[] getNameCharArray() {
+ return name.toCharArray();
+ }
+
+
+ public IType getType() {
+ return this;
+ }
+
+ public boolean isSameType(IType type) {
+ if( type == this )
+ return true;
+ if( type instanceof ITypedef)
+ return type.isSameType( this );
+
+ return false;
+ }
+
+ public C99Enumeration clone() {
+ try {
+ C99Enumeration clone = (C99Enumeration) super.clone();
+ clone.enumerators = new ArrayList<IEnumerator>();
+ for(IEnumerator e : enumerators) {
+ // TODO this is wrong,
+ // IEnumerator is not Cloneable so we are not returning a deep copy here
+ clone.addEnumerator(e);
+ }
+ return clone;
+ } catch (CloneNotSupportedException e1) {
+ assert false;
+ return null;
+ }
+
+ }
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
+
+ public IScope getScope() {
+ return scope;
+ }
+
+ public void setScope(IScope scope) {
+ this.scope = scope;
+ }
+
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumerator.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumerator.java
new file mode 100644
index 00000000000..f5c6fa23727
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumerator.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.core.runtime.PlatformObject;
+
+public class C99Enumerator extends PlatformObject implements IC99Binding, IEnumerator, ITypeable {
+
+ private String name;
+ private IType type;
+ private IScope scope;
+
+
+ public C99Enumerator() {
+ }
+
+ public C99Enumerator(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public void setType(IType type) {
+ this.type = type;
+ }
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
+
+ public char[] getNameCharArray() {
+ return name.toCharArray();
+ }
+
+ public IScope getScope() {
+ return scope;
+ }
+
+ public void setScope(IScope scope) {
+ this.scope = scope;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Field.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Field.java
new file mode 100644
index 00000000000..9404cc15053
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Field.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IScope;
+
+public class C99Field extends C99Variable implements IC99Binding, IField, ITypeable {
+
+ private ICompositeType compositeTypeOwner;
+
+
+ public C99Field() {
+ }
+
+ public C99Field(String name) {
+ super(name);
+ }
+
+ public ICompositeType getCompositeTypeOwner() {
+ return compositeTypeOwner;
+ }
+
+ public void setCompositeTypeOwner(ICompositeType compositeTypeOwner) {
+ this.compositeTypeOwner = compositeTypeOwner;
+ }
+
+ public IScope getScope() {
+ try {
+ return compositeTypeOwner.getCompositeScope();
+ } catch (DOMException e) {
+ return null; // should never happen
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java
new file mode 100644
index 00000000000..9e15f32cbf1
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IFunctionType;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.core.runtime.PlatformObject;
+
+public class C99Function extends PlatformObject implements IC99Binding, IFunction, ITypeable {
+
+ private String name;
+ private IFunctionType type;
+ private List<IParameter> parameters = new ArrayList<IParameter>();
+
+ private boolean isAuto;
+ private boolean isExtern;
+ private boolean isInline;
+ private boolean isRegister;
+ private boolean isStatic;
+ private boolean isVarArgs;
+
+ // the scope that the function is in (must be the global scope, no?)
+ private IScope scope;
+
+ // the scope that represents the body of the function
+ private IScope bodyScope;
+
+
+ public C99Function() {
+ }
+
+ public C99Function(String name) {
+ this.name = name;
+ }
+
+ public C99Function(String name, IFunctionType type) {
+ this(name);
+ this.type = type;
+ }
+
+
+ public IParameter[] getParameters() {
+ return parameters.toArray(new IParameter[parameters.size()]);
+ }
+
+ public void addParameter(IParameter parameter) {
+ parameters.add(parameter);
+ }
+
+ public IFunctionType getType() {
+ return type;
+ }
+
+ public void setType(IFunctionType type) {
+ this.type = type;
+ }
+
+ public boolean isAuto() {
+ return isAuto;
+ }
+
+ public void setAuto(boolean isAuto) {
+ this.isAuto = isAuto;
+ }
+
+ public boolean isExtern() {
+ return isExtern;
+ }
+
+ public void setExtern(boolean isExtern) {
+ this.isExtern = isExtern;
+ }
+
+ public boolean isInline() {
+ return isInline;
+ }
+
+ public void setInline(boolean isInline) {
+ this.isInline = isInline;
+ }
+
+ public boolean isRegister() {
+ return isRegister;
+ }
+
+ public void setRegister(boolean isRegister) {
+ this.isRegister = isRegister;
+ }
+
+ public boolean isStatic() {
+ return isStatic;
+ }
+
+ public void setStatic(boolean isStatic) {
+ this.isStatic = isStatic;
+ }
+
+ public boolean takesVarArgs() {
+ return isVarArgs;
+ }
+
+ public void setTakesVarArgs(boolean isVarArgs) {
+ this.isVarArgs = isVarArgs;
+ }
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public char[] getNameCharArray() {
+ return name.toCharArray();
+ }
+
+ public IScope getScope() {
+ return scope;
+ }
+
+ public IScope getFunctionScope() {
+ return bodyScope;
+ }
+
+ public void setFunctionScope(IScope bodyScope) {
+ this.bodyScope = bodyScope;
+ }
+
+ public void setScope(IScope scope) {
+ this.scope = scope;
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99FunctionScope.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99FunctionScope.java
new file mode 100644
index 00000000000..c4a11f2e9f7
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99FunctionScope.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
+
+public class C99FunctionScope extends C99Scope implements ICFunctionScope {
+
+
+ /**
+ * Scope that represents the compound statement of the body of this scope.
+ * Does not include the parameters which are part of this function scope.
+ */
+ private IScope bodyScope;
+
+
+ public IBinding getBinding(char[] name) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setBodyScope(IScope bodyScope) {
+ this.bodyScope = bodyScope;
+ }
+
+ public IScope getBodyScope() throws DOMException {
+ return bodyScope;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99FunctionType.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99FunctionType.java
new file mode 100644
index 00000000000..51a7cf2e7aa
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99FunctionType.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.dom.ast.IFunctionType;
+import org.eclipse.cdt.core.dom.ast.IType;
+
+public class C99FunctionType implements IFunctionType {
+
+ private IType returnType;
+ private List<IType> parameterTypes = new ArrayList<IType>();
+
+ public IType[] getParameterTypes() {
+ return parameterTypes.toArray(new IType[parameterTypes.size()]);
+ }
+
+ public void addParameterType(IType parameterType) {
+ parameterTypes.add(parameterType);
+ }
+
+ public IType getReturnType() {
+ return returnType;
+ }
+
+ public void setReturnType(IType returnType) {
+ this.returnType = returnType;
+ }
+
+ public boolean isSameType(IType type) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public C99FunctionType clone() {
+ try {
+ C99FunctionType clone = (C99FunctionType) super.clone();
+ clone.setReturnType((IType)returnType.clone());
+ clone.parameterTypes = new ArrayList<IType>();
+ for(IType parameterType : parameterTypes) {
+ clone.addParameterType((IType)parameterType.clone());
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ assert false;
+ return null;
+ }
+
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Label.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Label.java
new file mode 100644
index 00000000000..964e9bd820f
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Label.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
+import org.eclipse.cdt.core.dom.ast.ILabel;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.core.runtime.PlatformObject;
+
+public class C99Label extends PlatformObject implements IC99Binding, ILabel {
+
+ private String name;
+ private IScope scope;
+
+ public C99Label() {
+ }
+
+ public C99Label(String name) {
+ this.name = name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public char[] getNameCharArray() {
+ return name.toCharArray();
+ }
+
+
+
+ public IASTLabelStatement getLabelStatement() {
+ return null;
+ }
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
+
+ public IScope getScope() {
+ return scope;
+ }
+
+ public void setScope(IScope scope) {
+ this.scope = scope;
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Parameter.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Parameter.java
new file mode 100644
index 00000000000..31e8aa81a2c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Parameter.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.IParameter;
+
+public class C99Parameter extends C99Variable implements IParameter, ITypeable {
+
+ public C99Parameter() {
+ }
+
+ public C99Parameter(String name) {
+ super(name);
+ }
+
+ public static C99Parameter valueOf(C99Variable var) {
+ C99Parameter param = new C99Parameter(var.getName());
+ param.setType(var.getType());
+ param.setAuto(var.isAuto());
+ param.setExtern(var.isExtern());
+ param.setRegister(var.isRegister());
+ param.setStatic(var.isStatic());
+ return param;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99PointerType.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99PointerType.java
new file mode 100644
index 00000000000..3bd44ae4f25
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99PointerType.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.c.ICPointerType;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+
+
+public class C99PointerType implements ITypeContainer, ICPointerType {
+
+
+ private IType type;
+ private boolean isConst;
+ private boolean isRestrict;
+ private boolean isVolatile;
+
+ public C99PointerType() {
+ }
+
+
+ public C99PointerType(IType type) {
+ this.type = type;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public void setType(IType type) {
+ this.type = type;
+ }
+
+ public boolean isConst() {
+ return isConst;
+ }
+
+ public void setConst(boolean isConst) {
+ this.isConst = isConst;
+ }
+
+ public boolean isRestrict() {
+ return isRestrict;
+ }
+
+ public void setRestrict(boolean isRestrict) {
+ this.isRestrict = isRestrict;
+ }
+
+ public boolean isVolatile() {
+ return isVolatile;
+ }
+
+ public void setVolatile(boolean isVolatile) {
+ this.isVolatile = isVolatile;
+ }
+
+
+ public boolean isSameType(IType t) {
+ if(t == this)
+ return true;
+
+ if (t instanceof ICPointerType) {
+ try {
+ ICPointerType pointerType = (ICPointerType) t;
+ if(pointerType.isConst() == isConst &&
+ pointerType.isRestrict() == isRestrict &&
+ pointerType.isVolatile() == isVolatile) {
+ return type.isSameType(pointerType.getType());
+ }
+ } catch(DOMException _) { }
+ }
+ return false;
+ }
+
+
+
+ public C99PointerType clone() {
+ try {
+ C99PointerType clone = (C99PointerType) super.clone();
+ clone.type = (IType) type.clone();
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ assert false;
+ return null;
+ }
+
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99ProblemBinding.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99ProblemBinding.java
new file mode 100644
index 00000000000..97e822af261
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99ProblemBinding.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
+
+public class C99ProblemBinding extends ProblemBinding implements IProblemBinding {
+
+
+ public C99ProblemBinding(int messageId) {
+ super(null, messageId, null);
+ }
+
+ public C99ProblemBinding(int messageId, String arg) {
+ super(null, messageId, arg.toCharArray());
+ }
+
+ public static C99ProblemBinding badType() {
+ return new C99ProblemBinding(IProblemBinding.SEMANTIC_INVALID_TYPE);
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99QualifierType.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99QualifierType.java
new file mode 100644
index 00000000000..97fd0fe92c8
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99QualifierType.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+
+public class C99QualifierType implements ICQualifierType, ITypeContainer {
+
+ private boolean isRestrict;
+ private boolean isConst;
+ private boolean isVolatile;
+
+ private IType type;
+
+
+ public C99QualifierType() {
+ }
+
+ public C99QualifierType(IType type) {
+ this.type = type;
+ }
+
+ public C99QualifierType(IType type, boolean isConst, boolean isVolatile, boolean isRestrict) {
+ this.isConst = isConst;
+ this.isRestrict = isRestrict;
+ this.isVolatile = isVolatile;
+ this.type = type;
+ }
+
+ public boolean isRestrict() {
+ return isRestrict;
+ }
+
+ public void setRestrict(boolean isRestrict) {
+ this.isRestrict = isRestrict;
+ }
+
+ public boolean isConst() {
+ return isConst;
+ }
+
+ public void setConst(boolean isConst) {
+ this.isConst = isConst;
+ }
+
+ public boolean isVolatile() {
+ return isVolatile;
+ }
+
+ public void setVolatile(boolean isVolatile) {
+ this.isVolatile = isVolatile;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public void setType(IType type) {
+ this.type = type;
+ }
+
+ public boolean isSameType(IType t) {
+ if(t == this)
+ return true;
+
+ if (t instanceof ICQualifierType) {
+ try {
+ ICQualifierType pointerType = (ICQualifierType) t;
+ if(pointerType.isConst() == isConst &&
+ pointerType.isRestrict() == isRestrict &&
+ pointerType.isVolatile() == isVolatile) {
+ return type.isSameType(pointerType.getType());
+ }
+ } catch(DOMException _) { }
+ }
+ return false;
+ }
+
+
+ public C99QualifierType clone() {
+ try {
+ C99QualifierType clone = (C99QualifierType) super.clone();
+ clone.type = (IType) type.clone();
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ assert false;
+ return null;
+ }
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java
new file mode 100644
index 00000000000..a64990b1594
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.lrparser.action.c99.C99SymbolTable;
+import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
+
+/**
+ * @author Mike Kucera
+ *
+ */
+public class C99Scope implements IC99Scope, IASTInternalScope {
+
+
+
+ private IScope parent;
+ private IASTNode physicalNode;
+ private IName scopeName;
+
+
+
+
+
+ public IScope getParent() {
+ return parent;
+ }
+
+ public void setParent(IScope parent) {
+ this.parent = parent;
+ }
+
+ public IASTNode getPhysicalNode() {
+ return physicalNode;
+ }
+
+ public void setPhysicalNode(IASTNode physicalNode) {
+ this.physicalNode = physicalNode;
+ }
+
+ public IName getScopeName() {
+ return scopeName;
+ }
+
+ public void setScopeName(IName scopeName) {
+ this.scopeName = scopeName;
+ }
+
+
+ public IBinding[] find(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ public IBinding getBinding(IASTName name, boolean resolve) {
+ throw new UnsupportedOperationException();
+ }
+
+ public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) {
+ throw new UnsupportedOperationException();
+ }
+
+
+
+
+ public void addBinding(IBinding binding) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addName(IASTName name) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void flushCache() {
+
+ }
+
+ public boolean isFullyCached() {
+ return true;
+ }
+
+ public void removeBinding(IBinding binding) {
+
+ }
+
+ public void setFullyCached(boolean b) {
+
+ }
+
+
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Structure.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Structure.java
new file mode 100644
index 00000000000..e5d883647d0
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Structure.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.PlatformObject;
+
+public class C99Structure extends PlatformObject implements IC99Binding, ICompositeType, ITypeable {
+
+
+ private Map<String,IField> fields = new LinkedHashMap<String,IField>();
+ private IField[] fieldArray = null;
+
+ /** either t_union or t_structure defined in IASTCompositeTypeSpecifier */
+ private int key;
+ private String name;
+
+ private IScope scope;
+
+ public C99Structure() {
+ }
+
+ public C99Structure(String name) {
+ this.name = name;
+ }
+
+ public C99Structure(int key) {
+ this.key = key;
+ }
+
+ public C99Structure(String name, int key) {
+ this.name = name;
+ this.key = key;
+ }
+
+ public void addField(IField field) {
+ fields.put(field.getName(), field);
+ fieldArray = null;
+ }
+
+ public IField findField(String name) {
+ return fields.get(name);
+ }
+
+ public IScope getCompositeScope() {
+// C99Scope scope = new C99CompositeTypeScope(this);
+// scope.setScopeName(nameNode);
+// return scope;
+ return null;
+ }
+
+ public IField[] getFields() {
+ if(fieldArray == null)
+ fieldArray = fields.values().toArray(new IField[fields.size()]);
+ return fieldArray;
+ }
+
+ public void setKey(int key) {
+ this.key = key;
+ }
+
+ public int getKey() {
+ return key;
+ }
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public char[] getNameCharArray() {
+ if(name == null)
+ return new char[0];
+
+ return name.toCharArray();
+ }
+
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
+
+ public IType getType() {
+ return this;
+ }
+
+ public boolean isSameType(IType type) {
+ if(type == this)
+ return true;
+ if( type instanceof ITypedef)
+ return type.isSameType( this );
+ return false;
+ }
+
+ //private Map<String,IField> fields = new LinkedHashMap<String,IField>();
+ //private IField[] fieldArray = null;
+
+
+ //private IScope scope;
+
+ public C99Structure clone() {
+ try {
+ C99Structure clone = (C99Structure) super.clone();
+ //clone.scope = (IScope) scope.clone(); TODO
+ clone.fieldArray = null;
+ clone.fields = new LinkedHashMap<String,IField>();
+ for(IField field : fields.values())
+ clone.addField(field); // TODO not a deep clone
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ assert false;
+ return null;
+ }
+ }
+
+ public IScope getScope() {
+ return scope;
+ }
+
+ public void setScope(IScope scope) {
+ this.scope = scope;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Typedef.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Typedef.java
new file mode 100644
index 00000000000..967d027b60c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Typedef.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+import org.eclipse.core.runtime.PlatformObject;
+
+public class C99Typedef extends PlatformObject implements IC99Binding, ITypedef, ITypeContainer, ITypeable {
+
+ private IType type;
+ private String name;
+
+ private IScope scope;
+
+
+ public C99Typedef() {
+ }
+
+ public C99Typedef(IType type) {
+ this.type = type;
+ }
+
+ public C99Typedef(IType type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+
+ public IType getType() {
+ return type;
+ }
+
+ public void setType(IType type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public char[] getNameCharArray() {
+ return name.toCharArray();
+ }
+
+
+ public boolean isSameType(IType t) {
+ if(t == this)
+ return true;
+
+ try {
+ if(t instanceof ITypedef)
+ return type.isSameType(((ITypedef)t).getType());
+ else
+ return type.isSameType(t);
+ } catch(DOMException _) {
+ return false;
+ }
+ }
+
+ public C99Typedef clone() {
+ try {
+ C99Typedef clone = (C99Typedef) super.clone();
+ clone.type = (IType) type.clone();
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ assert false;
+ return null;
+ }
+ }
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
+
+ public IScope getScope() {
+ return scope;
+ }
+
+ public void setScope(IScope scope) {
+ this.scope = scope;
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Variable.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Variable.java
new file mode 100644
index 00000000000..3ce77ab6785
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Variable.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.core.runtime.PlatformObject;
+
+public class C99Variable extends PlatformObject implements IC99Binding, IVariable, ITypeable {
+
+
+ private boolean isAuto;
+ private boolean isExtern;
+ private boolean isRegister;
+ private boolean isStatic;
+
+ private String name;
+ private IType type;
+
+ private IScope scope;
+
+ public C99Variable() {
+
+ }
+
+ public C99Variable(String name) {
+ this.name = name;
+ }
+
+
+ public void setType(IType type) {
+ this.type = type;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+
+ public void setAuto(boolean auto) {
+ this.isAuto = auto;
+ }
+
+ public boolean isAuto() {
+ return isAuto;
+ }
+
+
+ public void setExtern(boolean extern) {
+ this.isExtern = extern;
+ }
+
+ public boolean isExtern() {
+ return isExtern;
+ }
+
+
+ public void setRegister(boolean isRegister) {
+ this.isRegister = isRegister;
+ }
+
+ public boolean isRegister() {
+ return isRegister;
+ }
+
+
+ public void setStatic(boolean isStatic) {
+ this.isStatic = isStatic;
+ }
+
+ public boolean isStatic() {
+ return isStatic;
+ }
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public char[] getNameCharArray() {
+ return name.toCharArray();
+ }
+
+ public ILinkage getLinkage() {
+ return Linkage.C_LINKAGE;
+ }
+
+ public IScope getScope() {
+ return scope;
+ }
+
+ public void setScope(IScope scope) {
+ this.scope = scope;
+ }
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/IC99Binding.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/IC99Binding.java
new file mode 100644
index 00000000000..a928b923ce4
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/IC99Binding.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+
+public interface IC99Binding extends IBinding {
+
+ void setScope(IScope scope);
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/IC99Scope.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/IC99Scope.java
new file mode 100644
index 00000000000..629bd3c416c
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/IC99Scope.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.c.ICScope;
+
+
+/**
+ * TODO maybe rename to IC99InternalScope or something else.
+ *
+ * @author Mike Kucera
+ */
+public interface IC99Scope extends ICScope {
+
+ void setParent(IScope parent);
+
+ void setPhysicalNode(IASTNode node);
+
+ void setScopeName(IName name);
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/ITypeable.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/ITypeable.java
new file mode 100644
index 00000000000..ca9129e39d9
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/ITypeable.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
+
+import org.eclipse.cdt.core.dom.ast.IType;
+
+public interface ITypeable {
+ IType getType();
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.g b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.g
new file mode 100644
index 00000000000..260c67b706e
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.g
@@ -0,0 +1,1660 @@
+----------------------------------------------------------------------------------
+-- Copyright (c) 2006, 2008 IBM Corporation and others.
+-- All rights reserved. This program and the accompanying materials
+-- are made available under the terms of the Eclipse Public License v1.0
+-- which accompanies this distribution, and is available at
+-- http://www.eclipse.org/legal/epl_v10.html
+--
+-- Contributors:
+-- IBM Corporation - initial API and implementation
+----------------------------------------------------------------------------------
+
+%options la=2
+%options package=org.eclipse.cdt.internal.core.dom.lrparser.cpp
+%options template=TrialUndoParserTemplate.g
+
+
+
+$Notice
+-- Copied into all files generated by LPG
+/./*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl_v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *********************************************************************************/
+
+ // This file was generated by LPG
+./
+$End
+
+
+
+$Terminals
+
+ -- Keywords
+
+ asm auto bool break case catch char class
+ const const_cast continue default delete do
+ double dynamic_cast else enum explicit export
+ extern false float for friend goto if inline
+ int long mutable namespace new operator private
+ protected public register reinterpret_cast return
+ short signed sizeof static static_cast struct
+ switch template this throw try true typedef
+ typeid typename union unsigned using virtual
+ void volatile wchar_t while
+
+ -- Literals (also true and false are considered literals)
+
+ integer floating charconst stringlit
+
+ zero -- this is a special token used to disambiguate the the grammar rule for pure virtual functions
+ -- TODO is this really necessary? because it adds overhead in getKind()
+
+ -- identifiers
+ -- Special token that represents identifiers that have been declared as typedefs (lexer feedback hack)
+ -- there's going to be more of these
+
+ identifier
+ TypedefName
+
+ -- Special tokens used in content assist
+
+ Completion
+ EndOfCompletion
+
+ -- Unrecognized token
+
+ Invalid
+
+ -- Punctuation (with aliases to make grammar more readable)
+
+ LeftBracket ::= '['
+ LeftParen ::= '('
+ LeftBrace ::= '{'
+ Dot ::= '.'
+ DotStar ::= '.*'
+ Arrow ::= '->'
+ ArrowStar ::= '->*'
+ PlusPlus ::= '++'
+ MinusMinus ::= '--'
+ And ::= '&'
+ Star ::= '*'
+ Plus ::= '+'
+ Minus ::= '-'
+ Tilde ::= '~'
+ Bang ::= '!'
+ Slash ::= '/'
+ Percent ::= '%'
+ RightShift ::= '>>'
+ LeftShift ::= '<<'
+ LT ::= '<'
+ GT ::= '>'
+ LE ::= '<='
+ GE ::= '>='
+ EQ ::= '=='
+ NE ::= '!='
+ Caret ::= '^'
+ Or ::= '|'
+ AndAnd ::= '&&'
+ OrOr ::= '||'
+ Question ::= '?'
+ Colon ::= ':'
+ ColonColon ::= '::'
+ DotDotDot ::= '...'
+ Assign ::= '='
+ StarAssign ::= '*='
+ SlashAssign ::= '/='
+ PercentAssign ::= '%='
+ PlusAssign ::= '+='
+ MinusAssign ::= '-='
+ RightShiftAssign ::= '>>='
+ LeftShiftAssign ::= '<<='
+ AndAssign ::= '&='
+ CaretAssign ::= '^='
+ OrAssign ::= '|='
+ Comma ::= ','
+ zero ::= '0'
+
+ RightBracket -- these four have special rules for content assist
+ RightParen
+ RightBrace
+ SemiColon
+
+$End
+
+
+$Globals
+/.
+ import java.util.*;
+
+ import org.eclipse.cdt.core.dom.ast.*;
+ import org.eclipse.cdt.core.dom.ast.cpp.*;
+ import org.eclipse.cdt.core.dom.lrparser.action.cpp.CPPASTNodeFactory;
+ import org.eclipse.cdt.core.dom.lrparser.action.cpp.CPPBuildASTParserAction;
+ import org.eclipse.cdt.core.dom.lrparser.IParser;
+ import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+ import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+./
+$End
+
+-- TODO move as much code and macros as possible into a common file
+
+$Define
+ -- These macros allow the template and header code to be customized by an extending parser.
+ $ast_class /.Object./
+ $additional_interfaces /. ./
+
+ $build_action_class /. CPPBuildASTParserAction ./
+ $resolve_action_class /. C99TypedefTrackerParserAction ./
+ $node_factory_create_expression /. CPPASTNodeFactory.DEFAULT_INSTANCE ./
+
+ $action_class /. CPPParserAction ./
+ $data_class /. Object ./ -- allow anything to be passed between actions
+
+ $UndoResolver /.$Undo action.resolver.undo(); $EndUndo./
+
+ $Resolve /. $BeginTrial $resolve.
+ ./
+ $EndResolve /. $EndTrial
+ $UndoResolver
+ ./ -- undo actions are automatically generated for binding resolution actions
+
+ $Builder /. $BeginFinal $builder.
+ ./
+ $EndBuilder /. $EndFinal ./
+
+ $Build /. $Action $Builder ./
+ $EndBuild /. $EndBuilder $EndAction ./
+
+ $resolve /. action.resolver./
+ $builder /. action.builder./
+
+ --$Action /. $BeginAction ./
+ --$BeginFinal /. ./
+ --$EndFinal /. ./
+
+$End
+
+
+$Headers
+/.
+ private $action_class action;
+
+ // uncomment to use with backtracking parser
+ // public CPPParser() {}
+
+ private void initActions(IASTTranslationUnit tu) {
+ // binding resolution actions need access to IASTName nodes, temporary
+ action = new $action_class();
+ //action.resolver = new $resolve_action_class(this);
+ action.builder = new $build_action_class($node_factory_create_expression, this, tu);
+ //action.builder.setTokenMap(CPPParsersym.orderedTerminalSymbols);
+
+ // comment this line to use with backtracking parser
+ setParserAction(action);
+ }
+
+
+ public void addToken(IToken token) {
+ token.setKind(mapKind(token.getKind()));
+ super.addToken(token);
+ }
+
+
+ public IASTCompletionNode parse(IASTTranslationUnit tu) {
+ // this has to be done, or... kaboom!
+ setStreamLength(getSize());
+ initActions(tu);
+
+ final int errorRepairCount = -1; // _1 means full error handling
+ parser(null, errorRepairCount); // do the actual parse
+ super.resetTokenStream(); // allow tokens to be garbage collected
+
+ // the completion node may be null
+ IASTCompletionNode compNode = action.builder.getASTCompletionNode();
+
+ action = null;
+
+ // Comment this line to use with backtracking parser
+ //parserAction = null;
+
+ return compNode;
+ }
+
+
+ public int getKind(int i) {
+ int kind = super.getKind(i);
+ if(kind == CPPParsersym.TK_integer && "0".equals(getTokenText(i))) { //$NON-NLS-1$
+ kind = CPPParsersym.TK_zero;
+ }
+
+ // lexer feedback hack!
+ //else if(kind == C99Parsersym.TK_identifier && action.resolver.isTypedef(getTokenText(i))) {
+ // kind = C99Parsersym.TK_TypedefName;
+ //}
+
+ return kind;
+ }
+
+
+ // uncomment this method to use with backtracking parser
+ //public List getRuleTokens() {
+ // return Collections.unmodifiableList(getTokens().subList(getLeftSpan(), getRightSpan() + 1));
+ //}
+
+
+./
+$End
+
+
+$Start
+ translation_unit
+$End
+
+
+
+$Rules
+
+------------------------------------------------------------------------------------------
+-- AST and Symbol Table Scoping
+------------------------------------------------------------------------------------------
+
+
+<openscope-ast>
+ ::= $empty
+ /.$Action $Builder openASTScope(); $EndBuilder $EndAction./
+
+<openscope-symbol>
+ ::= $empty
+ -- /.$Action $Resolve openSymbolScope(); $EndResolve $EndAction./
+
+<openscope-declaration>
+ ::= $empty
+ -- /.$Action $Resolve openDeclarationScope(); $EndResolve $EndAction./
+
+<placeholder>
+ ::= $empty
+ /.$Action $Builder consumePlaceHolder(); $EndBuilder $EndAction./
+
+<empty>
+ ::= $empty
+ /.$Action $Builder consumeEmpty(); $EndBuilder $EndAction./
+
+------------------------------------------------------------------------------------------
+-- Content assist
+------------------------------------------------------------------------------------------
+
+-- The EndOfCompletion token is a special token that matches some punctuation.
+-- These tokens allow the parse to complete successfully after a Completion token
+-- is encountered.
+
+
+']' ::=? 'RightBracket'
+ --| 'EndOfCompletion'
+
+')' ::=? 'RightParen'
+ --| 'EndOfCompletion'
+
+'}' ::=? 'RightBrace'
+ --| 'EndOfCompletion'
+
+';' ::=? 'SemiColon'
+ --| 'EndOfCompletion'
+
+
+
+
+------------------------------------------------------------------------------------------
+-- Basic Concepts
+------------------------------------------------------------------------------------------
+
+
+translation_unit
+ ::= declaration_seq
+ /. $Build consumeTranslationUnit(); $EndBuild ./
+ | $empty
+ /. $Build consumeTranslationUnit(); $EndBuild ./
+
+--expression_as_translation_unit
+-- ::= expression
+-- /. $Build consumeExpressionAsTranslationUnit(); $EndBuild ./
+
+
+------------------------------------------------------------------------------------------
+-- Expressions
+------------------------------------------------------------------------------------------
+
+literal
+ ::= 'integer'
+ /. $Build consumeExpressionLiteral(ICPPASTLiteralExpression.lk_integer_constant); $EndBuild ./
+ | '0'
+ /. $Build consumeExpressionLiteral(ICPPASTLiteralExpression.lk_integer_constant); $EndBuild ./
+ | 'floating'
+ /. $Build consumeExpressionLiteral(ICPPASTLiteralExpression.lk_float_constant); $EndBuild ./
+ | 'charconst'
+ /. $Build consumeExpressionLiteral(ICPPASTLiteralExpression.lk_char_constant); $EndBuild ./
+ | 'stringlit'
+ /. $Build consumeExpressionLiteral(ICPPASTLiteralExpression.lk_string_literal); $EndBuild ./
+ | 'true'
+ /. $Build consumeExpressionLiteral(ICPPASTLiteralExpression.lk_true); $EndBuild ./
+ | 'false'
+ /. $Build consumeExpressionLiteral(ICPPASTLiteralExpression.lk_false); $EndBuild ./
+ | 'this'
+ /. $Build consumeExpressionLiteral(ICPPASTLiteralExpression.lk_this); $EndBuild ./
+
+
+primary_expression
+ ::= literal
+ | '(' expression ')'
+ /. $Build consumeExpressionBracketed(); $EndBuild ./
+ | qualified_or_unqualified_name
+ /. $Build consumeExpressionName(); $EndBuild ./
+
+
+-- Pushes an IASTName on the stack, if you want an id expression then wrap the name
+qualified_or_unqualified_name
+ ::= unqualified_id_name
+ | qualified_id_name
+
+
+unqualified_id_name
+ ::= identifier_name
+ | operator_function_id_name
+ | conversion_function_id_name
+ | template_id_name
+ | '~' class_name
+ /. $Build consumeDestructorName(); $EndBuild ./
+
+
+-- wrap an identifier in a name node
+identifier_name
+ ::= 'identifier'
+ /. $Build consumeIdentifierName(); $EndBuild ./
+
+
+template_opt
+ ::= 'template'
+ /. $Build consumePlaceHolder(); $EndBuild ./
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+dcolon_opt
+ ::= '::'
+ /. $Build consumePlaceHolder(); $EndBuild ./
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+-- this is a compound name
+qualified_id_name
+ ::= dcolon_opt nested_name_specifier template_opt unqualified_id_name
+ /. $Build consumeQualifiedId(true); $EndBuild ./
+ | '::' identifier_name
+ /. $Build consumeGlobalQualifiedId(); $EndBuild ./
+ | '::' operator_function_id_name
+ /. $Build consumeGlobalQualifiedId(); $EndBuild ./
+ | '::' template_id_name
+ /. $Build consumeGlobalQualifiedId(); $EndBuild ./
+
+
+
+--unqualified_id_with_template_name
+-- ::= template_opt unqualified_id_name
+-- /. $Build consumeNameWithTemplateKeyword(); $EndBuild ./
+
+
+-- puts a list of names in reverse order on the stack
+-- always ends with ::
+-- this is the part of a qualified id that comes before the last ::
+-- but does not include a :: at the front
+nested_name_specifier
+ ::= class_or_namespace_name '::' nested_name_specifier_with_template
+ /. $Build consumeNestedNameSpecifier(true); $EndBuild ./
+ | class_or_namespace_name '::'
+ /. $Build consumeNestedNameSpecifier(false); $EndBuild ./
+
+
+nested_name_specifier_with_template
+ ::= class_or_namespace_name_with_template '::' nested_name_specifier_with_template
+ /. $Build consumeNestedNameSpecifier(true); $EndBuild ./
+ | class_or_namespace_name_with_template '::'
+ /. $Build consumeNestedNameSpecifier(false); $EndBuild ./
+
+
+class_or_namespace_name_with_template
+ ::= template_opt class_or_namespace_name
+ /. $Build consumeNameWithTemplateKeyword(); $EndBuild ./
+
+
+
+nested_name_specifier_opt
+ ::= nested_name_specifier
+ | $empty
+ /. $Build consumeNestedNameSpecifierEmpty(); $EndBuild ./
+
+
+class_or_namespace_name -- just identifiers
+ ::= class_name
+ | namespace_name
+
+
+postfix_expression
+ ::= primary_expression
+ | postfix_expression '[' expression ']'
+ /. $Build consumeExpressionArraySubscript(); $EndBuild ./
+ | postfix_expression '(' expression_list_opt ')'
+ /. $Build consumeExpressionFunctionCall(); $EndBuild ./
+ | simple_type_specifier '(' expression_list_opt ')' -- explicit type conversion operator
+ /. $Build consumeExpressionSimpleTypeConstructor(); $EndBuild ./
+ | 'typename' dcolon_opt nested_name_specifier <empty> identifier_name '(' expression_list_opt ')'
+ /. $Build consumeExpressionTypeName(); $EndBuild ./
+ | 'typename' dcolon_opt nested_name_specifier template_opt template_id_name '(' expression_list_opt ')'
+ /. $Build consumeExpressionTypeName(); $EndBuild ./
+ | postfix_expression '.' qualified_or_unqualified_name
+ /. $Build consumeExpressionFieldReference(false, false); $EndBuild ./
+ | postfix_expression '->' qualified_or_unqualified_name
+ /. $Build consumeExpressionFieldReference(true, false); $EndBuild ./
+ | postfix_expression '.' 'template' qualified_or_unqualified_name
+ /. $Build consumeExpressionFieldReference(false, true); $EndBuild ./
+ | postfix_expression '->' 'template' qualified_or_unqualified_name
+ /. $Build consumeExpressionFieldReference(true, true); $EndBuild ./
+ | postfix_expression '.' pseudo_destructor_name
+ /. $Build consumeExpressionFieldReference(false, false); $EndBuild ./
+ | postfix_expression '->' pseudo_destructor_name
+ /. $Build consumeExpressionFieldReference(true, false); $EndBuild ./
+ | postfix_expression '++'
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixIncr); $EndBuild ./
+ | postfix_expression '--'
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixDecr); $EndBuild ./
+ | 'dynamic_cast' '<' type_id '>' '(' expression ')'
+ /. $Build consumeExpressionCast(ICPPASTCastExpression.op_dynamic_cast); $EndBuild ./
+ | 'static_cast' '<' type_id '>' '(' expression ')'
+ /. $Build consumeExpressionCast(ICPPASTCastExpression.op_static_cast); $EndBuild ./
+ | 'reinterpret_cast' '<' type_id '>' '(' expression ')'
+ /. $Build consumeExpressionCast(ICPPASTCastExpression.op_reinterpret_cast); $EndBuild ./
+ | 'const_cast' '<' type_id '>' '(' expression ')'
+ /. $Build consumeExpressionCast(ICPPASTCastExpression.op_const_cast); $EndBuild ./
+ | 'typeid' '(' expression ')'
+ /. $Build consumeExpressionUnaryOperator(ICPPASTUnaryExpression.op_typeid); $EndBuild ./
+ | 'typeid' '(' type_id ')'
+ /. $Build consumeExpressionTypeId(ICPPASTTypeIdExpression.op_typeid); $EndBuild ./
+
+
+
+-- just names
+-- Don't even know if I really need this rule, the DOM parser just parses qualified_or_unqualified_name
+-- instead of pseudo_destructor_name. But the difference is I have different
+-- token types, so maybe I do need this rule.
+pseudo_destructor_name
+ ::= dcolon_opt nested_name_specifier_opt type_name '::' '~' type_name
+ /. $Build consumePsudoDestructorName(true); $EndBuild ./
+ | dcolon_opt nested_name_specifier 'template' template_id_name '::' '~' type_name
+ /. $Build consumePsudoDestructorName(true); $EndBuild ./
+ | dcolon_opt nested_name_specifier_opt '~' type_name
+ /. $Build consumePsudoDestructorName(false); $EndBuild ./
+
+
+unary_expression
+ ::= postfix_expression
+ | new_expression
+ | delete_expression
+ | '++' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixIncr); $EndBuild ./
+ | '--' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixDecr); $EndBuild ./
+ | '&' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_amper); $EndBuild ./
+ | '*' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_star); $EndBuild ./
+ | '+' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_plus); $EndBuild ./
+ | '-' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_minus); $EndBuild ./
+ | '~' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_tilde); $EndBuild ./
+ | '!' cast_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_not); $EndBuild ./
+ | 'sizeof' unary_expression
+ /. $Build consumeExpressionUnaryOperator(IASTUnaryExpression.op_sizeof); $EndBuild ./
+ | 'sizeof' '(' type_id ')'
+ /. $Build consumeExpressionTypeId(ICPPASTTypeIdExpression.op_sizeof); $EndBuild ./
+
+
+new_expression -- done
+ ::= dcolon_opt 'new' new_placement_opt new_type_id <openscope-ast> new_array_expressions_opt new_initializer_opt
+ /. $Build consumeExpressionNew(false); $EndBuild ./
+ | dcolon_opt 'new' new_placement_opt '(' type_id ')' new_initializer_opt
+ /. $Build consumeExpressionNew(true); $EndBuild ./
+
+
+new_placement -- done
+ ::= '(' expression_list ')'
+
+
+new_placement_opt -- done
+ ::= new_placement
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+new_type_id
+ ::= type_specifier_seq
+ /. $Build consumeTypeId(false); $EndBuild ./
+ | type_specifier_seq new_declarator
+ /. $Build consumeTypeId(true); $EndBuild ./
+
+
+new_declarator -- pointer operators are part of the type id, held in an empty declarator
+ ::= <openscope-ast> new_pointer_operators
+ /. $Build consumeNewDeclarator(); $EndBuild ./
+
+
+new_pointer_operators -- presumably this will not need an action as ptr_operator will have one
+ ::= ptr_operator
+ | ptr_operator new_pointer_operators
+
+
+new_array_expressions
+ ::= '[' expression ']'
+ | new_array_expressions '[' constant_expression ']'
+
+
+new_array_expressions_opt
+ ::= new_array_expressions
+ | $empty
+
+
+new_initializer -- done
+ ::= '(' expression_list_opt ')' -- even if the parens are there we get null in the AST
+
+
+new_initializer_opt -- done
+ ::= new_initializer
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+delete_expression
+ ::= dcolon_opt 'delete' cast_expression
+ /. $Build consumeExpressionDelete(false); $EndBuild ./
+ | dcolon_opt 'delete' '[' ']' cast_expression
+ /. $Build consumeExpressionDelete(true); $EndBuild ./
+
+
+cast_expression
+ ::= unary_expression
+ | '(' type_id ')' cast_expression
+ /. $Build consumeExpressionCast(ICPPASTCastExpression.op_cast); $EndBuild ./
+
+
+pm_expression
+ ::= cast_expression
+ | pm_expression '.*' cast_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_pmdot); $EndBuild ./
+ | pm_expression '->*' cast_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_pmarrow); $EndBuild ./
+
+
+multiplicative_expression
+ ::= pm_expression
+ | multiplicative_expression '*' pm_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_multiply); $EndBuild ./
+ | multiplicative_expression '/' pm_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_divide); $EndBuild ./
+ | multiplicative_expression '%' pm_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_modulo); $EndBuild ./
+
+
+additive_expression
+ ::= multiplicative_expression
+ | additive_expression '+' multiplicative_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_plus); $EndBuild ./
+ | additive_expression '-' multiplicative_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_minus); $EndBuild ./
+
+
+shift_expression
+ ::= additive_expression
+ | shift_expression '<<' additive_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_shiftLeft); $EndBuild ./
+ | shift_expression '>>' additive_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_shiftRight); $EndBuild ./
+
+
+relational_expression
+ ::= shift_expression
+ | relational_expression '<' shift_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_lessThan); $EndBuild ./
+ | relational_expression '>' shift_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_greaterThan); $EndBuild ./
+ | relational_expression '<=' shift_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_lessEqual); $EndBuild ./
+ | relational_expression '>=' shift_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_greaterEqual); $EndBuild ./
+
+
+equality_expression
+ ::= relational_expression
+ | equality_expression '==' relational_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_equals); $EndBuild ./
+ | equality_expression '!=' relational_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_notequals); $EndBuild ./
+
+
+and_expression
+ ::= equality_expression
+ | and_expression '&' equality_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryAnd); $EndBuild ./
+
+
+exclusive_or_expression
+ ::= and_expression
+ | exclusive_or_expression '^' and_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryXor); $EndBuild ./
+
+
+inclusive_or_expression
+ ::= exclusive_or_expression
+ | inclusive_or_expression '|' exclusive_or_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryOr); $EndBuild ./
+
+
+logical_and_expression
+ ::= inclusive_or_expression
+ | logical_and_expression '&&' inclusive_or_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_logicalAnd); $EndBuild ./
+
+
+logical_or_expression
+ ::= logical_and_expression
+ | logical_or_expression '||' logical_and_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_logicalOr); $EndBuild ./
+
+
+conditional_expression
+ ::= logical_or_expression
+ | logical_or_expression '?' expression ':' assignment_expression
+ /. $Build consumeExpressionConditional(); $EndBuild ./
+
+
+throw_expression
+ ::= 'throw'
+ /. $Build consumeExpressionThrow(false); $EndBuild ./
+ | 'throw' assignment_expression
+ /. $Build consumeExpressionThrow(true); $EndBuild ./
+
+
+assignment_expression
+ ::= conditional_expression
+ | throw_expression
+ | logical_or_expression '=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_assign); $EndBuild ./
+ | logical_or_expression '*=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_multiplyAssign); $EndBuild ./
+ | logical_or_expression '/=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_divideAssign); $EndBuild ./
+ | logical_or_expression '%=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_moduloAssign); $EndBuild ./
+ | logical_or_expression '+=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_plusAssign); $EndBuild ./
+ | logical_or_expression '-=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_minusAssign); $EndBuild ./
+ | logical_or_expression '>>=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_shiftRightAssign); $EndBuild ./
+ | logical_or_expression '<<=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_shiftLeftAssign); $EndBuild ./
+ | logical_or_expression '&=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryAndAssign); $EndBuild ./
+ | logical_or_expression '^=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryXorAssign); $EndBuild ./
+ | logical_or_expression '|=' assignment_expression
+ /. $Build consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryOrAssign); $EndBuild ./
+
+
+expression
+ ::= expression_list
+ | ERROR_TOKEN
+ /. $Build consumeExpressionProblem(); $EndBuild ./
+
+-- expression_list and expression_list_opt always result in a single element on the stack
+-- the element might be an expression, an expression list or null
+
+expression_list
+ ::= <openscope-ast> expression_list_actual
+ /. $Build consumeExpressionList(); $EndBuild ./
+
+
+expression_list_actual
+ ::= assignment_expression
+ | expression_list_actual ',' assignment_expression
+
+
+expression_list_opt
+ ::= expression_list
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+expression_opt
+ ::= expression
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+constant_expression
+ ::= conditional_expression
+
+
+constant_expression_opt
+ ::= constant_expression
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+------------------------------------------------------------------------------------------
+-- Statements
+------------------------------------------------------------------------------------------
+
+-- TODO: declarations in conditions
+
+statement
+ ::= labeled_statement
+ | expression_statement
+ | compound_statement
+ | selection_statement
+ | iteration_statement
+ | jump_statement
+ | declaration_statement
+ | try_block
+ | ERROR_TOKEN
+ /. $Build consumeStatementProblem(); $EndBuild ./
+
+
+labeled_statement
+ ::= identifier ':' statement
+ /. $Build consumeStatementLabeled(); $EndBuild ./
+ | case constant_expression ':'
+ /. $Build consumeStatementCase(); $EndBuild ./
+ | default ':'
+ /. $Build consumeStatementDefault(); $EndBuild ./
+
+
+expression_statement
+ ::= expression ';'
+ /. $Build consumeStatementExpression(); $EndBuild ./
+ | ';'
+ /. $Build consumeStatementNull(); $EndBuild ./
+
+
+compound_statement
+ ::= '{' <openscope-ast> statement_seq '}'
+ /. $Build consumeStatementCompoundStatement(true); $EndBuild ./
+ | '{' '}'
+ /. $Build consumeStatementCompoundStatement(false); $EndBuild ./
+
+
+statement_seq
+ ::= statement
+ | statement_seq statement
+
+
+selection_statement
+ ::= 'if' '(' condition ')' statement
+ /. $Build consumeStatementIf(false); $EndBuild ./
+ | 'if' '(' condition ')' statement 'else' statement
+ /. $Build consumeStatementIf(true); $EndBuild ./
+ | 'switch' '(' condition ')' statement
+ /. $Build consumeStatementSwitch(); $EndBuild ./
+
+
+
+condition
+ ::= expression
+ | type_specifier_seq declarator '=' assignment_expression
+ /. $Build consumeConditionDeclaration(); $EndBuild ./
+
+
+-- where did this come from?
+--condition_opt
+-- ::= condition
+-- | $empty
+-- /. $Build consumeEmpty(); $EndBuild ./
+
+
+iteration_statement
+ ::= 'while' '(' condition ')' statement
+ /. $Build consumeStatementWhileLoop(); $EndBuild ./
+ | 'do' statement 'while' '(' expression ')' ';'
+ /. $Build consumeStatementDoLoop(); $EndBuild ./
+ | 'for' '(' expression_opt ';' expression_opt ';' expression_opt ')' statement
+ /. $Build consumeStatementForLoop(); $EndBuild ./
+ | 'for' '(' simple_declaration expression_opt ';' expression_opt ')' statement
+ /. $Build consumeStatementForLoop(); $EndBuild ./
+
+
+jump_statement
+ ::= 'break' ';'
+ /. $Build consumeStatementBreak(); $EndBuild ./
+ | 'continue' ';'
+ /. $Build consumeStatementContinue(); $EndBuild ./
+ | 'return' expression ';'
+ /. $Build consumeStatementReturn(true); $EndBuild ./
+ | 'return' ';'
+ /. $Build consumeStatementReturn(false); $EndBuild ./
+ | 'goto' 'identifier' ';'
+ /. $Build consumeStatementGoto(); $EndBuild ./
+
+
+declaration_statement
+ ::= block_declaration
+ /. $Build consumeStatementDeclaration(); $EndBuild ./
+
+
+
+------------------------------------------------------------------------------------------
+-- Declarations
+------------------------------------------------------------------------------------------
+
+
+declaration
+ ::= block_declaration
+ | function_definition
+ | template_declaration -- done
+ | explicit_instantiation -- done
+ | explicit_specialization -- done
+ | linkage_specification -- done
+ | namespace_definition -- done
+
+
+block_declaration
+ ::= simple_declaration
+ | asm_definition -- done
+ | namespace_alias_definition -- done
+ | using_declaration -- done
+ | using_directive -- done
+
+
+declaration_seq
+ ::= declaration
+ | declaration_seq declaration
+
+
+
+declaration_seq_opt
+ ::= declaration_seq
+ | $empty
+
+
+
+simple_declaration
+ ::= declaration_specifiers_opt <openscope-ast> init_declarator_list_opt ';'
+ /. $Build consumeDeclarationSimple(true); $EndBuild ./
+
+
+-- declaration specifier nodes not created here, they are created by sub-rules
+-- these rules add IToken modifiers to the declspec nodes
+declaration_specifiers
+ ::= <openscope-ast> simple_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersSimple(); $EndBuild ./
+ | <openscope-ast> class_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersComposite(); $EndBuild ./
+ | <openscope-ast> elaborated_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersComposite(); $EndBuild ./
+ | <openscope-ast> enum_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersComposite(); $EndBuild ./
+ | <openscope-ast> type_name_declaration_specifiers
+ /. $Build consumeDeclarationSpecifiersTypeName(); $EndBuild ./
+
+
+declaration_specifiers_opt
+ ::= declaration_specifiers
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+-- what about type qualifiers... cv_qualifier
+no_type_declaration_specifier
+ ::= storage_class_specifier
+ | function_specifier
+ | 'friend'
+ /. $Build consumeDeclSpecToken(); $EndBuild ./
+ | 'typedef'
+ /. $Build consumeDeclSpecToken(); $EndBuild ./
+
+
+no_type_declaration_specifiers
+ ::= no_type_declaration_specifier
+ | no_type_declaration_specifiers no_type_declaration_specifier
+
+
+-- now also includes qualified names
+-- if there is no long long then this may be simplified
+simple_declaration_specifiers
+ ::= simple_type_specifier
+ | no_type_declaration_specifiers simple_type_specifier
+ | simple_declaration_specifiers simple_type_specifier
+ | simple_declaration_specifiers no_type_declaration_specifier
+
+
+-- struct, union or class!
+class_declaration_specifiers
+ ::= class_specifier
+ | no_type_declaration_specifiers class_specifier
+ | class_declaration_specifiers no_type_declaration_specifier
+
+
+-- elaborated means something different, but how different?
+elaborated_declaration_specifiers
+ ::= elaborated_type_specifier
+ | no_type_declaration_specifiers elaborated_type_specifier
+ | elaborated_declaration_specifiers no_type_declaration_specifier
+
+
+-- Think this is the same
+enum_declaration_specifiers
+ ::= enum_specifier
+ | no_type_declaration_specifiers enum_specifier
+ | enum_declaration_specifiers no_type_declaration_specifier
+
+
+-- just typedefs in C99, but expanded to type names in C++ (no tagging needed)
+type_name_declaration_specifiers
+ ::= type_name_specifier
+ | no_type_declaration_specifiers type_name_specifier
+ | type_name_declaration_specifiers no_type_declaration_specifier
+
+
+ -- TODO comment this out
+--decl_specifier
+-- ::= storage_class_specifier -- just keywords
+-- | type_specifier -- this is where the fun is
+ -- | function_specifier -- just keywords
+ -- | 'friend'
+ -- | 'typedef'
+
+
+storage_class_specifier
+ ::= 'auto'
+ | 'register'
+ | 'static'
+ | 'extern'
+ | 'mutable'
+
+
+function_specifier
+ ::= 'inline'
+ | 'virtual'
+ | 'explicit'
+
+
+typedef_name
+ ::= 'identifier'
+
+
+type_specifier
+ ::= simple_type_specifier -- int, void etc...
+ | class_specifier -- structs, unions, classes
+ | enum_specifier -- enums
+ | elaborated_type_specifier -- its elaborated, but this is different than c, includes typename
+ | cv_qualifier -- the const and volatile keywords (separated because they can be applied to pointer modifiers)
+
+
+
+--simple_type_specifier
+-- ::= dcolon_opt nested_name_specifier_opt type_name
+-- /. $Build consumeQualifiedId(false); $EndBuild ./
+-- | dcolon_opt nested_name_specifier 'template' template_id_name
+-- /. $Build consumeQualifiedId(false); $EndBuild ./
+-- | simple_type_primitive_specifier
+
+
+simple_type_specifier
+ ::= simple_type_specifier_token
+ /. $Build consumeDeclSpecToken(); $EndBuild ./
+
+
+simple_type_specifier_token
+ ::= 'char'
+ | 'wchar_t'
+ | 'bool'
+ | 'short'
+ | 'int'
+ | 'long'
+ | 'signed'
+ | 'unsigned'
+ | 'float'
+ | 'double'
+ | 'void'
+
+
+-- last two rules moved here from simple_type_specifier
+type_name -- all identifiers of some kind
+ ::= class_name
+ | enum_name -- identifier
+ | typedef_name
+
+
+-- last two rules moved here from simple_type_specifier
+type_name_specifier -- all identifiers of some kind
+ ::= type_name
+ | dcolon_opt nested_name_specifier_opt type_name
+ /. $Build consumeQualifiedId(false); $EndBuild ./
+ | dcolon_opt nested_name_specifier 'template' template_id_name
+ /. $Build consumeQualifiedId(false); $EndBuild ./
+ | 'typename' dcolon_opt nested_name_specifier identifier_name
+ /. $Build consumeQualifiedId(false); $EndBuild ./
+ | 'typename' dcolon_opt nested_name_specifier template_opt template_id_name
+ /. $Build consumeQualifiedId(true); $EndBuild ./
+
+
+-- used for forward declaration and incomplete types
+elaborated_type_specifier
+ ::= class_keyword dcolon_opt nested_name_specifier_opt identifier_name
+ /. $Build consumeTypeSpecifierElaborated(false); $EndBuild ./
+ | class_keyword dcolon_opt nested_name_specifier_opt template_opt template_id_name
+ /. $Build consumeTypeSpecifierElaborated(true); $EndBuild ./
+ | 'enum' dcolon_opt nested_name_specifier_opt identifier_name
+ /. $Build consumeTypeSpecifierElaborated(false); $EndBuild ./
+
+
+enum_name
+ ::= 'identifier'
+
+
+enum_specifier
+ ::= 'enum' '{' <openscope-ast> enumerator_list_opt '}'
+ /. $Build consumeTypeSpecifierEnumeration(false); $EndBuild ./
+ | 'enum' 'identifier' '{' <openscope-ast> enumerator_list_opt '}'
+ /. $Build consumeTypeSpecifierEnumeration(true); $EndBuild ./
+
+
+enumerator_list
+ ::= enumerator_definition
+ | enumerator_list ',' enumerator_definition
+
+
+enumerator_list_opt
+ ::= enumerator_list
+ | $empty
+
+
+enumerator_definition
+ ::= enumerator
+ /. $Build consumeEnumerator(false); $EndBuild ./
+ | enumerator '=' constant_expression
+ /. $Build consumeEnumerator(true); $EndBuild ./
+
+
+enumerator
+ ::= 'identifier'
+
+
+namespace_name
+ ::= original_namespace_name
+ | namespace_alias
+
+
+original_namespace_name
+ ::= 'identifier'
+
+
+namespace_definition
+ ::= named_namespace_definition
+ | unnamed_namespace_definition
+
+
+named_namespace_definition
+ ::= original_namespace_definition
+ | extension_namespace_definition
+
+
+original_namespace_definition
+ ::= 'namespace' identifier_name '{' <openscope-ast> declaration_seq_opt '}'
+ /. $Build consumeNamespaceDefinition(true); $EndBuild ./
+
+
+extension_namespace_definition
+ ::= 'namespace' original_namespace_name '{' <openscope-ast> declaration_seq_opt '}'
+ /. $Build consumeNamespaceDefinition(true); $EndBuild ./
+
+
+unnamed_namespace_definition
+ ::= 'namespace' '{' <openscope-ast> declaration_seq_opt '}'
+ /. $Build consumeNamespaceDefinition(false); $EndBuild ./
+
+
+namespace_alias
+ ::= 'identifier'
+
+
+namespace_alias_definition
+ ::= 'namespace' 'identifier' '=' dcolon_opt nested_name_specifier_opt namespace_name ';'
+ /. $Build consumeNamespaceAliasDefinition(); $EndBuild ./
+
+
+--qualified_namespace_specifier
+-- ::= dcolon_opt nested_name_specifier_opt namespace_name
+
+
+-- make more lenient!
+-- using_declaration
+-- ::= 'using' typename_opt dcolon_opt nested_name_specifier unqualified_id_name ';'
+-- | 'using' '::' unqualified_id_name ';'
+
+
+using_declaration
+ ::= 'using' typename_opt dcolon_opt nested_name_specifier_opt unqualified_id_name ';'
+ /. $Build consumeUsingDeclaration(); $EndBuild ./
+
+
+typename_opt
+ ::= 'typename'
+ /. $Build consumePlaceHolder(); $EndBuild ./
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+using_directive
+ ::= 'using' 'namespace' dcolon_opt nested_name_specifier_opt namespace_name ';'
+ /. $Build consumeUsingDirective(); $EndBuild ./
+
+
+asm_definition
+ ::= 'asm' '(' 'stringlit' ')' ';'
+ /. $Build consumeDeclarationASM(); $EndBuild ./
+
+
+linkage_specification
+ ::= 'extern' 'stringlit' '{' <openscope-ast> declaration_seq_opt '}'
+ /. $Build consumeLinkageSpecification(); $EndBuild ./
+ | 'extern' 'stringlit' <openscope-ast> declaration
+ /. $Build consumeLinkageSpecification(); $EndBuild ./
+
+
+init_declarator_list
+ ::= init_declarator
+ | init_declarator_list ',' init_declarator
+
+
+init_declarator_list_opt
+ ::= init_declarator_list
+ | $empty
+
+
+init_declarator
+ ::= declarator
+ | declarator initializer
+ /. $Build consumeDeclaratorWithInitializer(); $EndBuild ./
+
+
+declarator
+ ::= <openscope-ast> ptr_operator_seq_opt direct_declarator
+ /. $Build consumeDeclaratorWithPointer(); $EndBuild ./
+
+
+direct_declarator
+ ::= basic_direct_declarator
+ | function_direct_declarator
+ | array_direct_declarator
+
+
+basic_direct_declarator
+ ::= declarator_id_name
+ /. $Build consumeDirectDeclaratorIdentifier(); $EndBuild ./
+ | '(' declarator ')'
+ /. $Build consumeDirectDeclaratorBracketed(); $EndBuild ./
+
+
+function_direct_declarator
+ ::= basic_direct_declarator '(' <openscope-ast> parameter_declaration_clause ')' <openscope-ast> cv_qualifier_seq_opt <openscope-ast> exception_specification_opt
+ /. $Build consumeDirectDeclaratorFunctionDeclarator(); $EndBuild ./
+
+array_direct_declarator
+ ::= array_direct_declarator array_modifier
+ /. $Build consumeDirectDeclaratorArrayDeclarator(); $EndBuild ./
+ | basic_direct_declarator array_modifier
+ /. $Build consumeDirectDeclaratorArrayDeclarator(); $EndBuild ./
+
+
+array_modifier
+ ::= '[' constant_expression ']'
+ /. $Build consumeDirectDeclaratorArrayModifier(true); $EndBuild ./
+ | '[' ']'
+ /. $Build consumeDirectDeclaratorArrayModifier(false); $EndBuild ./
+
+
+ptr_operator
+ ::= '*' <openscope-ast> cv_qualifier_seq_opt
+ /. $Build consumePointer(); $EndBuild ./
+ | '&'
+ /. $Build consumeReferenceOperator(); $EndBuild ./
+ | dcolon_opt nested_name_specifier '*' <openscope-ast> cv_qualifier_seq_opt
+ /. $Build consumePointerToMember(); $EndBuild ./
+
+
+ptr_operator_seq
+ ::= ptr_operator
+ | ptr_operator_seq ptr_operator
+
+
+ptr_operator_seq_opt
+ ::= ptr_operator_seq
+ | $empty
+
+
+cv_qualifier_seq
+ ::= cv_qualifier cv_qualifier_seq_opt
+
+
+cv_qualifier_seq_opt
+ ::= cv_qualifier_seq
+ | $empty
+
+
+cv_qualifier
+ ::= 'const'
+ /. $Build consumeDeclSpecToken(); $EndBuild ./
+ | 'volatile'
+ /. $Build consumeDeclSpecToken(); $EndBuild ./
+
+
+declarator_id_name
+ ::= qualified_or_unqualified_name
+ | dcolon_opt nested_name_specifier_opt type_name
+ /. $Build consumeQualifiedId(false); $EndBuild ./
+
+
+type_id
+ ::= type_specifier_seq
+ /. $Build consumeTypeId(false); $EndBuild ./
+ | type_specifier_seq abstract_declarator
+ /. $Build consumeTypeId(true); $EndBuild ./
+
+
+type_specifier_seq
+ ::= type_specifier
+ | type_specifier_seq type_specifier
+
+
+abstract_declarator
+ ::= ptr_operator abstract_declarator_opt
+ | direct_abstract_declarator
+
+
+abstract_declarator_opt
+ ::= abstract_declarator
+ | $empty
+
+
+direct_abstract_declarator
+ ::= direct_abstract_declarator_opt '(' <openscope-ast> parameter_declaration_clause ')' <openscope-ast> cv_qualifier_seq_opt <openscope-ast> exception_specification_opt
+ | direct_abstract_declarator_opt '[' constant_expression_opt ']'
+ | '(' abstract_declarator ')'
+
+
+direct_abstract_declarator_opt
+ ::= direct_abstract_declarator
+ | $empty
+
+
+parameter_declaration_clause
+ ::= parameter_declaration_list_opt '...'
+ /. $Build consumePlaceHolder(); $EndBuild ./
+ | parameter_declaration_list_opt
+ /. $Build consumeEmpty(); $EndBuild ./
+ | parameter_declaration_list ',' '...'
+ /. $Build consumePlaceHolder(); $EndBuild ./
+
+
+parameter_declaration_list
+ ::= parameter_declaration
+ | parameter_declaration_list ',' parameter_declaration
+
+parameter_declaration_list_opt
+ ::= parameter_declaration_list
+ | $empty
+
+parameter_declaration
+ ::= declaration_specifiers declarator
+ | declaration_specifiers declarator = assignment_expression
+ | declaration_specifiers abstract_declarator_opt
+ | declaration_specifiers abstract_declarator_opt = assignment_expression
+
+
+function_definition
+ ::= declaration_specifiers_opt declarator ctor_initializer_opt function_body
+ | declaration_specifiers_opt declarator function_try_block
+
+
+function_body
+ ::= compound_statement
+
+
+initializer
+ ::= '=' initializer_clause
+ | '(' expression_list ')'
+ /. $Build consumeInitializerConstructor(); $EndBuild ./
+
+
+initializer_clause
+ ::= assignment_expression
+ /. $Build consumeInitializer(); $EndBuild ./
+ | '{' <openscope-ast> initializer_list ',' '}'
+ /. $Build consumeInitializerList(); $EndBuild ./
+ | '{' <openscope-ast> initializer_list '}'
+ /. $Build consumeInitializerList(); $EndBuild ./
+ | '{' <openscope-ast> '}'
+ /. $Build consumeInitializerList(); $EndBuild ./
+
+
+initializer_list
+ ::= initializer_clause
+ | initializer_list ',' initializer_clause
+
+
+
+------------------------------------------------------------------------------------------
+-- Classes
+------------------------------------------------------------------------------------------
+
+
+class_name
+ ::= identifier_name
+ | template_id_name
+
+
+class_specifier -- done
+ ::= class_head '{' <openscope-ast> member_declaration_list_opt '}'
+ /. $Build consumeClassSpecifier(); $EndBuild ./
+
+
+class_head -- done
+ ::= class_keyword identifier_name_opt <openscope-ast> base_clause_opt
+ /. $Build consumeClassHead(false); $EndBuild ./
+ | class_keyword template_id_name <openscope-ast> base_clause_opt
+ /. $Build consumeClassHead(false); $EndBuild ./
+ | class_keyword nested_name_specifier identifier_name <openscope-ast> base_clause_opt
+ /. $Build consumeClassHead(true); $EndBuild ./
+ | class_keyword nested_name_specifier template_id_name <openscope-ast> base_clause_opt
+ /. $Build consumeClassHead(true); $EndBuild ./
+
+
+identifier_opt
+ ::= 'identifier'
+ | $empty
+
+
+identifier_name_opt
+ ::= identifier_name
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild./
+
+
+class_keyword
+ ::= 'class'
+ | 'struct'
+ | 'union'
+
+
+visibility_label
+ ::= access_specifier_keyword ':'
+ /. $Build consumeVisibilityLabel(); $EndBuild ./
+
+
+
+member_declaration
+ ::= declaration_specifiers_opt member_declarator_list ';'
+ | declaration_specifiers_opt ';'
+ | function_definition ';'
+ | function_definition
+ | dcolon_opt nested_name_specifier template_opt unqualified_id_name ';'
+ | using_declaration
+ | template_declaration
+ | visibility_label
+
+
+member_declaration_list
+ ::= member_declaration
+ | member_declaration_list member_declaration
+
+
+member_declaration_list_opt
+ ::= member_declaration_list
+ | $empty
+
+
+member_declarator_list
+ ::= member_declarator
+ | member_declarator_list ',' member_declarator
+
+
+member_declarator
+ ::= declarator
+ | declarator pure_specifier
+ | declarator constant_initializer
+ | identifier_opt ':' constant_expression
+
+
+pure_specifier
+ ::= '=' '0'
+
+
+constant_initializer
+ ::= '=' constant_expression
+
+
+base_clause
+ ::= ':' base_specifier_list
+
+
+base_clause_opt
+ ::= base_clause
+ | $empty
+
+
+base_specifier_list
+ ::= base_specifier
+ | base_specifier_list ',' base_specifier
+
+
+-- make this more lenient, allow virtual both before and after
+base_specifier
+ ::= dcolon_opt nested_name_specifier_opt class_name
+ /. $Build consumeBaseSpecifier(false); $EndBuild ./
+ | virtual_opt access_specifier_keyword virtual_opt dcolon_opt nested_name_specifier_opt class_name
+ /. $Build consumeBaseSpecifier(true); $EndBuild ./
+
+
+virtual_opt
+ ::= 'virtual'
+ /. $Build consumePlaceHolder(); $EndBuild ./
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+access_specifier_keyword
+ ::= 'private'
+ | 'protected'
+ | 'public'
+
+
+access_specifier_keyword_opt
+ ::= access_specifier_keyword
+ | $empty
+
+
+conversion_function_id_name
+ ::= 'operator' conversion_type_id
+ /. $Build consumeConversionName(); $EndBuild ./
+
+
+conversion_type_id
+ ::= type_specifier_seq conversion_declarator_opt
+
+
+conversion_declarator
+ ::= ptr_operator conversion_declarator_opt
+
+
+conversion_declarator_opt
+ ::= conversion_declarator
+ | $empty
+
+
+ctor_initializer
+ ::= ':' mem_initializer_list
+
+
+ctor_initializer_opt
+ ::= ctor_initializer
+ | $empty
+
+
+mem_initializer_list
+ ::= mem_initializer
+ | mem_initializer ',' mem_initializer_list
+
+
+mem_initializer
+ ::= mem_initializer_id '(' expression_list_opt ')'
+
+
+mem_initializer_id
+ ::= dcolon_opt nested_name_specifier_opt class_name
+ | 'identifier'
+
+
+operator_function_id_name
+ ::= operator_id_name
+ | operator_id_name '<' <openscope-ast> template_argument_list_opt '>'
+ /. $Build consumeTemplateId(); $EndBuild ./
+
+
+operator_id_name
+ ::= 'operator' overloadable_operator
+ /. $Build consumeOperatorName(); $EndBuild ./
+
+
+overloadable_operator
+ ::= 'new' | 'delete' | 'new' '[' ']' | 'delete' '[' ']'
+ | '+' | '-' | '*' | '/' | '%' | '^' | '&' | '|' | '~'
+ | '!' | '=' | '<' | '>' | '+=' | '-=' | '*=' | '/=' | '%='
+ | '^=' | '&=' | '|=' | '<<' | '>>' | '>>=' | '<<=' | '==' | '!='
+ | '<=' | '>=' | '&&' | '||' | '++' | '--' | ',' | '->*' | '->'
+ | '(' ')' | '[' ']'
+
+
+template_declaration
+ ::= export_opt 'template' '<' template_parameter_list '>' declaration
+ /. $Build consumeTemplateDeclaration(); $EndBuild ./
+
+
+export_opt
+ ::= 'export'
+ /. $Build consumePlaceHolder(); $EndBuild ./
+ | $empty
+ /. $Build consumeEmpty(); $EndBuild ./
+
+
+template_parameter_list
+ ::= template_parameter
+ | template_parameter_list ',' template_parameter
+
+
+template_parameter
+ ::= type_parameter
+ | parameter_declaration
+
+
+type_parameter
+ ::= 'class' identifier_opt
+ | 'class' identifier_opt '=' type_id
+ | 'typename' identifier_opt
+ | 'typename' identifier_opt '=' type_id
+ | 'template' '<' template_parameter_list '>' 'class' identifier_opt
+ | 'template' '<' template_parameter_list '>' 'class' identifier_opt '=' qualified_or_unqualified_name
+
+
+-- pushes name node on stack
+template_id_name
+ ::= template_identifier '<' <openscope-ast> template_argument_list_opt '>'
+ /. $Build consumeTemplateId(); $EndBuild ./
+
+template_identifier
+ ::= 'identifier'
+
+
+template_argument_list
+ ::= template_argument
+ | template_argument_list ',' template_argument
+
+
+template_argument_list_opt
+ ::= template_argument_list
+ | $empty
+
+
+template_argument
+ ::= assignment_expression
+ | type_id
+ | qualified_or_unqualified_name
+
+
+explicit_instantiation
+ ::= 'template' declaration
+ /. $Build consumeTemplateExplicitInstantiation(); $EndBuild ./
+
+
+explicit_specialization
+ ::= 'template' '<' '>' declaration
+ /. $Build consumeTemplateExplicitSpecialization(); $EndBuild ./
+
+
+try_block
+ ::= 'try' compound_statement <openscope-ast> handler_seq
+ /. $Build consumeStatementTryBlock(); $EndBuild ./
+
+
+function_try_block
+ ::= 'try' ctor_initializer_opt function_body handler_seq
+
+
+handler_seq
+ ::= handler
+ | handler_seq handler
+
+
+handler
+ ::= 'catch' '(' exception_declaration ')' compound_statement
+ /. $Build consumeStatementCatchHandler(false); $EndBuild ./
+ | 'catch' '(' '...' ')' compound_statement
+ /. $Build consumeStatementCatchHandler(true); $EndBuild ./
+
+
+exception_declaration
+ ::= type_specifier_seq declarator
+ | type_specifier_seq abstract_declarator
+ | type_specifier_seq
+
+
+-- puts type ids on the stack
+exception_specification
+ ::= 'throw' '(' type_id_list ')'
+ | 'throw' '(' ')'
+
+
+exception_specification_opt
+ ::= exception_specification
+ | $empty
+
+
+type_id_list
+ ::= type_id
+ | type_id_list ',' type_id \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.java
new file mode 100644
index 00000000000..2edf09a6d12
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.java
@@ -0,0 +1,2573 @@
+/*******************************************************************************
+* Copyright (c) 2006, 2008 IBM Corporation and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl_v10.html
+*
+* Contributors:
+* IBM Corporation - initial API and implementation
+*********************************************************************************/
+
+// This file was generated by LPG
+
+package org.eclipse.cdt.internal.core.dom.lrparser.cpp;
+
+
+import lpg.lpgjavaruntime.*;
+import org.eclipse.cdt.core.dom.lrparser.lpgextensions.ITrialUndoActionProvider;
+import org.eclipse.cdt.core.dom.lrparser.lpgextensions.AbstractTrialUndoActionProvider;
+import org.eclipse.cdt.core.dom.lrparser.lpgextensions.TrialUndoParser;
+
+import java.util.*;
+
+import org.eclipse.cdt.core.dom.ast.*;
+import org.eclipse.cdt.core.dom.ast.cpp.*;
+import org.eclipse.cdt.core.dom.lrparser.action.cpp.CPPASTNodeFactory;
+import org.eclipse.cdt.core.dom.lrparser.action.cpp.CPPBuildASTParserAction;
+import org.eclipse.cdt.core.dom.lrparser.IParser;
+import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
+
+public class CPPParser extends AbstractTrialUndoActionProvider< CPPParserAction , Object > implements IParserActionTokenProvider, IParser {
+ private static ParseTable prs = new CPPParserprs();
+ protected static final Action< CPPParserAction , Object >[] RULE_ACTIONS;
+
+ {
+ ruleAction = RULE_ACTIONS;
+ }
+
+ public CPPParser(LexStream lexStream) {
+ super(lexStream);
+
+ try {
+ super.remapTerminalSymbols(orderedTerminalSymbols(), CPPParserprs.EOFT_SYMBOL);
+ } catch (NullExportedSymbolsException e) {
+ } catch (NullTerminalSymbolsException e) {
+ } catch (UnimplementedTerminalsException e) {
+ java.util.ArrayList unimplemented_symbols = e.getSymbols();
+ System.out.println("The Lexer will not scan the following token(s):");
+ for (int i = 0; i < unimplemented_symbols.size(); i++) {
+ Integer id = (Integer) unimplemented_symbols.get(i);
+ System.out.println(" " + CPPParsersym.orderedTerminalSymbols[id.intValue()]);
+ }
+ System.out.println();
+ } catch (UndefinedEofSymbolException e) {
+ throw new Error(new UndefinedEofSymbolException("The Lexer does not implement the Eof symbol " + CPPParsersym.orderedTerminalSymbols[CPPParserprs.EOFT_SYMBOL]));
+ }
+ }
+
+
+ public CPPParser() { // constructor
+ // this(new $lexer_class());
+ }
+
+ public String[] orderedTerminalSymbols() {
+ return CPPParsersym.orderedTerminalSymbols;
+ }
+
+ public String getTokenKindName(int kind) {
+ return CPPParsersym.orderedTerminalSymbols[kind];
+ }
+
+ public int getEOFTokenKind() {
+ return CPPParserprs.EOFT_SYMBOL;
+ }
+
+ public PrsStream getParseStream() {
+ return (PrsStream) this;
+ }
+
+ //
+ // Report error message for given error_token.
+ //
+ public final void reportErrorTokenMessage(int error_token, String msg) {
+ int firsttok = super.getFirstRealToken(error_token), lasttok = super.getLastRealToken(error_token);
+ String location = super.getFileName() + ':' +
+ (firsttok > lasttok
+ ? (super.getEndLine(lasttok) + ":" + super.getEndColumn(lasttok))
+ : (super.getLine(error_token) + ":" +
+ super.getColumn(error_token) + ":" +
+ super.getEndLine(error_token) + ":" +
+ super.getEndColumn(error_token))) + ": ";
+ super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
+ }
+
+ public Object parser() {
+ return parser(null, 0);
+ }
+
+ public Object parser(Monitor monitor) {
+ return parser(monitor, 0);
+ }
+
+ public Object parser(int error_repair_count) {
+ return parser(null, error_repair_count);
+ }
+
+ public Object parser(Monitor monitor, int error_repair_count) {
+ try {
+ btParser = new TrialUndoParser((TokenStream) this, prs, (ITrialUndoActionProvider< Object >) this);
+ } catch (NotBacktrackParseTableException e) {
+ throw new Error(new NotBacktrackParseTableException("Regenerate CPPParserprs.java with -BACKTRACK option"));
+ } catch (BadParseSymFileException e) {
+ throw new Error(new BadParseSymFileException("Bad Parser Symbol File -- CPPParsersym.java"));
+ }
+
+ try {
+ Object result = (Object) btParser.parse(error_repair_count);
+ btParser.commit();
+ return result;
+ } catch (BadParseException e) {
+ reset(e.error_token); // point to error token
+
+ //DiagnoseParser diagnoseParser = new DiagnoseParser((TokenStream) this, prs);
+ //diagnoseParser.diagnose(e.error_token);
+ }
+
+ return null;
+ }
+
+
+private CPPParserAction action;
+
+// uncomment to use with backtracking parser
+// public CPPParser() {}
+
+private void initActions(IASTTranslationUnit tu) {
+ // binding resolution actions need access to IASTName nodes, temporary
+ action = new CPPParserAction ();
+ //action.resolver = new C99TypedefTrackerParserAction (this);
+ action.builder = new CPPBuildASTParserAction ( CPPASTNodeFactory.DEFAULT_INSTANCE , this, tu);
+ //action.builder.setTokenMap(CPPParsersym.orderedTerminalSymbols);
+
+ // comment this line to use with backtracking parser
+ setParserAction(action);
+}
+
+
+public void addToken(IToken token) {
+ token.setKind(mapKind(token.getKind()));
+ super.addToken(token);
+}
+
+
+public IASTCompletionNode parse(IASTTranslationUnit tu) {
+ // this has to be done, or... kaboom!
+ setStreamLength(getSize());
+ initActions(tu);
+
+ final int errorRepairCount = -1; // _1 means full error handling
+ parser(null, errorRepairCount); // do the actual parse
+ super.resetTokenStream(); // allow tokens to be garbage collected
+
+ // the completion node may be null
+ IASTCompletionNode compNode = action.builder.getASTCompletionNode();
+
+ action = null;
+
+ // Comment this line to use with backtracking parser
+ //parserAction = null;
+
+ return compNode;
+}
+
+
+public int getKind(int i) {
+ int kind = super.getKind(i);
+ if(kind == CPPParsersym.TK_integer && "0".equals(getTokenText(i))) { //$NON-NLS-1$
+ kind = CPPParsersym.TK_zero;
+ }
+
+ // lexer feedback hack!
+ //else if(kind == C99Parsersym.TK_identifier && action.resolver.isTypedef(getTokenText(i))) {
+ // kind = C99Parsersym.TK_TypedefName;
+ //}
+
+ return kind;
+}
+
+
+// uncomment this method to use with backtracking parser
+//public List getRuleTokens() {
+// return Collections.unmodifiableList(getTokens().subList(getLeftSpan(), getRightSpan() + 1));
+//}
+
+
+
+
+ //
+ // Initialize ruleAction array.
+ //
+ static {
+ RULE_ACTIONS = new Action[521 + 1];
+ RULE_ACTIONS[0] = null;
+
+ RULE_ACTIONS[1] = new Action1();
+ RULE_ACTIONS[4] = new Action4();
+ RULE_ACTIONS[5] = new Action5();
+ RULE_ACTIONS[10] = new Action10();
+ RULE_ACTIONS[11] = new Action11();
+ RULE_ACTIONS[12] = new Action12();
+ RULE_ACTIONS[13] = new Action13();
+ RULE_ACTIONS[14] = new Action14();
+ RULE_ACTIONS[15] = new Action15();
+ RULE_ACTIONS[16] = new Action16();
+ RULE_ACTIONS[17] = new Action17();
+ RULE_ACTIONS[18] = new Action18();
+ RULE_ACTIONS[19] = new Action19();
+ RULE_ACTIONS[21] = new Action21();
+ RULE_ACTIONS[22] = new Action22();
+ RULE_ACTIONS[29] = new Action29();
+ RULE_ACTIONS[30] = new Action30();
+ RULE_ACTIONS[31] = new Action31();
+ RULE_ACTIONS[32] = new Action32();
+ RULE_ACTIONS[33] = new Action33();
+ RULE_ACTIONS[34] = new Action34();
+ RULE_ACTIONS[35] = new Action35();
+ RULE_ACTIONS[36] = new Action36();
+ RULE_ACTIONS[37] = new Action37();
+ RULE_ACTIONS[38] = new Action38();
+ RULE_ACTIONS[39] = new Action39();
+ RULE_ACTIONS[40] = new Action40();
+ RULE_ACTIONS[41] = new Action41();
+ RULE_ACTIONS[42] = new Action42();
+ RULE_ACTIONS[43] = new Action43();
+ RULE_ACTIONS[45] = new Action45();
+ RULE_ACTIONS[49] = new Action49();
+ RULE_ACTIONS[50] = new Action50();
+ RULE_ACTIONS[51] = new Action51();
+ RULE_ACTIONS[52] = new Action52();
+ RULE_ACTIONS[53] = new Action53();
+ RULE_ACTIONS[54] = new Action54();
+ RULE_ACTIONS[55] = new Action55();
+ RULE_ACTIONS[56] = new Action56();
+ RULE_ACTIONS[57] = new Action57();
+ RULE_ACTIONS[58] = new Action58();
+ RULE_ACTIONS[59] = new Action59();
+ RULE_ACTIONS[60] = new Action60();
+ RULE_ACTIONS[61] = new Action61();
+ RULE_ACTIONS[62] = new Action62();
+ RULE_ACTIONS[63] = new Action63();
+ RULE_ACTIONS[64] = new Action64();
+ RULE_ACTIONS[65] = new Action65();
+ RULE_ACTIONS[66] = new Action66();
+ RULE_ACTIONS[67] = new Action67();
+ RULE_ACTIONS[68] = new Action68();
+ RULE_ACTIONS[69] = new Action69();
+ RULE_ACTIONS[70] = new Action70();
+ RULE_ACTIONS[74] = new Action74();
+ RULE_ACTIONS[75] = new Action75();
+ RULE_ACTIONS[76] = new Action76();
+ RULE_ACTIONS[77] = new Action77();
+ RULE_ACTIONS[78] = new Action78();
+ RULE_ACTIONS[79] = new Action79();
+ RULE_ACTIONS[80] = new Action80();
+ RULE_ACTIONS[81] = new Action81();
+ RULE_ACTIONS[82] = new Action82();
+ RULE_ACTIONS[83] = new Action83();
+ RULE_ACTIONS[84] = new Action84();
+ RULE_ACTIONS[85] = new Action85();
+ RULE_ACTIONS[88] = new Action88();
+ RULE_ACTIONS[89] = new Action89();
+ RULE_ACTIONS[90] = new Action90();
+ RULE_ACTIONS[91] = new Action91();
+ RULE_ACTIONS[100] = new Action100();
+ RULE_ACTIONS[101] = new Action101();
+ RULE_ACTIONS[102] = new Action102();
+ RULE_ACTIONS[104] = new Action104();
+ RULE_ACTIONS[106] = new Action106();
+ RULE_ACTIONS[107] = new Action107();
+ RULE_ACTIONS[109] = new Action109();
+ RULE_ACTIONS[110] = new Action110();
+ RULE_ACTIONS[111] = new Action111();
+ RULE_ACTIONS[113] = new Action113();
+ RULE_ACTIONS[114] = new Action114();
+ RULE_ACTIONS[116] = new Action116();
+ RULE_ACTIONS[117] = new Action117();
+ RULE_ACTIONS[119] = new Action119();
+ RULE_ACTIONS[120] = new Action120();
+ RULE_ACTIONS[121] = new Action121();
+ RULE_ACTIONS[122] = new Action122();
+ RULE_ACTIONS[124] = new Action124();
+ RULE_ACTIONS[125] = new Action125();
+ RULE_ACTIONS[127] = new Action127();
+ RULE_ACTIONS[129] = new Action129();
+ RULE_ACTIONS[131] = new Action131();
+ RULE_ACTIONS[133] = new Action133();
+ RULE_ACTIONS[135] = new Action135();
+ RULE_ACTIONS[137] = new Action137();
+ RULE_ACTIONS[138] = new Action138();
+ RULE_ACTIONS[139] = new Action139();
+ RULE_ACTIONS[142] = new Action142();
+ RULE_ACTIONS[143] = new Action143();
+ RULE_ACTIONS[144] = new Action144();
+ RULE_ACTIONS[145] = new Action145();
+ RULE_ACTIONS[146] = new Action146();
+ RULE_ACTIONS[147] = new Action147();
+ RULE_ACTIONS[148] = new Action148();
+ RULE_ACTIONS[149] = new Action149();
+ RULE_ACTIONS[150] = new Action150();
+ RULE_ACTIONS[151] = new Action151();
+ RULE_ACTIONS[152] = new Action152();
+ RULE_ACTIONS[154] = new Action154();
+ RULE_ACTIONS[155] = new Action155();
+ RULE_ACTIONS[159] = new Action159();
+ RULE_ACTIONS[161] = new Action161();
+ RULE_ACTIONS[164] = new Action164();
+ RULE_ACTIONS[173] = new Action173();
+ RULE_ACTIONS[174] = new Action174();
+ RULE_ACTIONS[175] = new Action175();
+ RULE_ACTIONS[176] = new Action176();
+ RULE_ACTIONS[177] = new Action177();
+ RULE_ACTIONS[178] = new Action178();
+ RULE_ACTIONS[179] = new Action179();
+ RULE_ACTIONS[180] = new Action180();
+ RULE_ACTIONS[183] = new Action183();
+ RULE_ACTIONS[184] = new Action184();
+ RULE_ACTIONS[185] = new Action185();
+ RULE_ACTIONS[187] = new Action187();
+ RULE_ACTIONS[188] = new Action188();
+ RULE_ACTIONS[189] = new Action189();
+ RULE_ACTIONS[190] = new Action190();
+ RULE_ACTIONS[191] = new Action191();
+ RULE_ACTIONS[192] = new Action192();
+ RULE_ACTIONS[193] = new Action193();
+ RULE_ACTIONS[194] = new Action194();
+ RULE_ACTIONS[195] = new Action195();
+ RULE_ACTIONS[196] = new Action196();
+ RULE_ACTIONS[197] = new Action197();
+ RULE_ACTIONS[214] = new Action214();
+ RULE_ACTIONS[215] = new Action215();
+ RULE_ACTIONS[216] = new Action216();
+ RULE_ACTIONS[217] = new Action217();
+ RULE_ACTIONS[218] = new Action218();
+ RULE_ACTIONS[219] = new Action219();
+ RULE_ACTIONS[221] = new Action221();
+ RULE_ACTIONS[224] = new Action224();
+ RULE_ACTIONS[225] = new Action225();
+ RULE_ACTIONS[258] = new Action258();
+ RULE_ACTIONS[274] = new Action274();
+ RULE_ACTIONS[275] = new Action275();
+ RULE_ACTIONS[276] = new Action276();
+ RULE_ACTIONS[277] = new Action277();
+ RULE_ACTIONS[278] = new Action278();
+ RULE_ACTIONS[279] = new Action279();
+ RULE_ACTIONS[280] = new Action280();
+ RULE_ACTIONS[282] = new Action282();
+ RULE_ACTIONS[283] = new Action283();
+ RULE_ACTIONS[288] = new Action288();
+ RULE_ACTIONS[289] = new Action289();
+ RULE_ACTIONS[298] = new Action298();
+ RULE_ACTIONS[299] = new Action299();
+ RULE_ACTIONS[300] = new Action300();
+ RULE_ACTIONS[302] = new Action302();
+ RULE_ACTIONS[303] = new Action303();
+ RULE_ACTIONS[304] = new Action304();
+ RULE_ACTIONS[305] = new Action305();
+ RULE_ACTIONS[306] = new Action306();
+ RULE_ACTIONS[307] = new Action307();
+ RULE_ACTIONS[308] = new Action308();
+ RULE_ACTIONS[309] = new Action309();
+ RULE_ACTIONS[315] = new Action315();
+ RULE_ACTIONS[316] = new Action316();
+ RULE_ACTIONS[320] = new Action320();
+ RULE_ACTIONS[321] = new Action321();
+ RULE_ACTIONS[322] = new Action322();
+ RULE_ACTIONS[323] = new Action323();
+ RULE_ACTIONS[324] = new Action324();
+ RULE_ACTIONS[325] = new Action325();
+ RULE_ACTIONS[326] = new Action326();
+ RULE_ACTIONS[327] = new Action327();
+ RULE_ACTIONS[328] = new Action328();
+ RULE_ACTIONS[329] = new Action329();
+ RULE_ACTIONS[337] = new Action337();
+ RULE_ACTIONS[338] = new Action338();
+ RULE_ACTIONS[340] = new Action340();
+ RULE_ACTIONS[341] = new Action341();
+ RULE_ACTIONS[342] = new Action342();
+ RULE_ACTIONS[354] = new Action354();
+ RULE_ACTIONS[355] = new Action355();
+ RULE_ACTIONS[356] = new Action356();
+ RULE_ACTIONS[369] = new Action369();
+ RULE_ACTIONS[370] = new Action370();
+ RULE_ACTIONS[371] = new Action371();
+ RULE_ACTIONS[372] = new Action372();
+ RULE_ACTIONS[373] = new Action373();
+ RULE_ACTIONS[378] = new Action378();
+ RULE_ACTIONS[379] = new Action379();
+ RULE_ACTIONS[380] = new Action380();
+ RULE_ACTIONS[381] = new Action381();
+ RULE_ACTIONS[382] = new Action382();
+ RULE_ACTIONS[386] = new Action386();
+ RULE_ACTIONS[390] = new Action390();
+ RULE_ACTIONS[416] = new Action416();
+ RULE_ACTIONS[417] = new Action417();
+ RULE_ACTIONS[418] = new Action418();
+ RULE_ACTIONS[419] = new Action419();
+ RULE_ACTIONS[425] = new Action425();
+ RULE_ACTIONS[439] = new Action439();
+ RULE_ACTIONS[440] = new Action440();
+ RULE_ACTIONS[483] = new Action483();
+ RULE_ACTIONS[484] = new Action484();
+ RULE_ACTIONS[485] = new Action485();
+ RULE_ACTIONS[496] = new Action496();
+ RULE_ACTIONS[505] = new Action505();
+ RULE_ACTIONS[506] = new Action506();
+ RULE_ACTIONS[507] = new Action507();
+ RULE_ACTIONS[511] = new Action511();
+ RULE_ACTIONS[512] = new Action512();
+
+
+ //
+ // Make sure that all elements of ruleAction are properly initialized
+ //
+ for (int i = 0; i < RULE_ACTIONS.length; i++) {
+ if (RULE_ACTIONS[i] == null) {
+ RULE_ACTIONS[i] = emptyAction();
+ }
+ }
+ }
+
+ //
+ // Rule 1: <openscope-ast> ::= $Empty
+ //
+ static final class Action1 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ openASTScope();
+ }
+ }
+
+ //
+ // Rule 4: <placeholder> ::= $Empty
+ //
+ static final class Action4 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePlaceHolder();
+ }
+ }
+
+ //
+ // Rule 5: <empty> ::= $Empty
+ //
+ static final class Action5 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 10: translation_unit ::= declaration_seq
+ //
+ static final class Action10 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTranslationUnit();
+ }
+ }
+
+ //
+ // Rule 11: translation_unit ::= $Empty
+ //
+ static final class Action11 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTranslationUnit();
+ }
+ }
+
+ //
+ // Rule 12: literal ::= integer
+ //
+ static final class Action12 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionLiteral(ICPPASTLiteralExpression.lk_integer_constant);
+ }
+ }
+
+ //
+ // Rule 13: literal ::= 0
+ //
+ static final class Action13 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionLiteral(ICPPASTLiteralExpression.lk_integer_constant);
+ }
+ }
+
+ //
+ // Rule 14: literal ::= floating
+ //
+ static final class Action14 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionLiteral(ICPPASTLiteralExpression.lk_float_constant);
+ }
+ }
+
+ //
+ // Rule 15: literal ::= charconst
+ //
+ static final class Action15 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionLiteral(ICPPASTLiteralExpression.lk_char_constant);
+ }
+ }
+
+ //
+ // Rule 16: literal ::= stringlit
+ //
+ static final class Action16 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionLiteral(ICPPASTLiteralExpression.lk_string_literal);
+ }
+ }
+
+ //
+ // Rule 17: literal ::= true
+ //
+ static final class Action17 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionLiteral(ICPPASTLiteralExpression.lk_true);
+ }
+ }
+
+ //
+ // Rule 18: literal ::= false
+ //
+ static final class Action18 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionLiteral(ICPPASTLiteralExpression.lk_false);
+ }
+ }
+
+ //
+ // Rule 19: literal ::= this
+ //
+ static final class Action19 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionLiteral(ICPPASTLiteralExpression.lk_this);
+ }
+ }
+
+ //
+ // Rule 21: primary_expression ::= ( expression )
+ //
+ static final class Action21 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBracketed();
+ }
+ }
+
+ //
+ // Rule 22: primary_expression ::= qualified_or_unqualified_name
+ //
+ static final class Action22 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionName();
+ }
+ }
+
+ //
+ // Rule 29: unqualified_id_name ::= ~ class_name
+ //
+ static final class Action29 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDestructorName();
+ }
+ }
+
+ //
+ // Rule 30: identifier_name ::= identifier
+ //
+ static final class Action30 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeIdentifierName();
+ }
+ }
+
+ //
+ // Rule 31: template_opt ::= template
+ //
+ static final class Action31 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePlaceHolder();
+ }
+ }
+
+ //
+ // Rule 32: template_opt ::= $Empty
+ //
+ static final class Action32 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 33: dcolon_opt ::= ::
+ //
+ static final class Action33 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePlaceHolder();
+ }
+ }
+
+ //
+ // Rule 34: dcolon_opt ::= $Empty
+ //
+ static final class Action34 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 35: qualified_id_name ::= dcolon_opt nested_name_specifier template_opt unqualified_id_name
+ //
+ static final class Action35 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeQualifiedId(true);
+ }
+ }
+
+ //
+ // Rule 36: qualified_id_name ::= :: identifier_name
+ //
+ static final class Action36 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeGlobalQualifiedId();
+ }
+ }
+
+ //
+ // Rule 37: qualified_id_name ::= :: operator_function_id_name
+ //
+ static final class Action37 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeGlobalQualifiedId();
+ }
+ }
+
+ //
+ // Rule 38: qualified_id_name ::= :: template_id_name
+ //
+ static final class Action38 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeGlobalQualifiedId();
+ }
+ }
+
+ //
+ // Rule 39: nested_name_specifier ::= class_or_namespace_name :: nested_name_specifier_with_template
+ //
+ static final class Action39 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNestedNameSpecifier(true);
+ }
+ }
+
+ //
+ // Rule 40: nested_name_specifier ::= class_or_namespace_name ::
+ //
+ static final class Action40 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNestedNameSpecifier(false);
+ }
+ }
+
+ //
+ // Rule 41: nested_name_specifier_with_template ::= class_or_namespace_name_with_template :: nested_name_specifier_with_template
+ //
+ static final class Action41 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNestedNameSpecifier(true);
+ }
+ }
+
+ //
+ // Rule 42: nested_name_specifier_with_template ::= class_or_namespace_name_with_template ::
+ //
+ static final class Action42 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNestedNameSpecifier(false);
+ }
+ }
+
+ //
+ // Rule 43: class_or_namespace_name_with_template ::= template_opt class_or_namespace_name
+ //
+ static final class Action43 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNameWithTemplateKeyword();
+ }
+ }
+
+ //
+ // Rule 45: nested_name_specifier_opt ::= $Empty
+ //
+ static final class Action45 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNestedNameSpecifierEmpty();
+ }
+ }
+
+ //
+ // Rule 49: postfix_expression ::= postfix_expression [ expression ]
+ //
+ static final class Action49 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionArraySubscript();
+ }
+ }
+
+ //
+ // Rule 50: postfix_expression ::= postfix_expression ( expression_list_opt )
+ //
+ static final class Action50 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionFunctionCall();
+ }
+ }
+
+ //
+ // Rule 51: postfix_expression ::= simple_type_specifier ( expression_list_opt )
+ //
+ static final class Action51 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionSimpleTypeConstructor();
+ }
+ }
+
+ //
+ // Rule 52: postfix_expression ::= typename dcolon_opt nested_name_specifier <empty> identifier_name ( expression_list_opt )
+ //
+ static final class Action52 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionTypeName();
+ }
+ }
+
+ //
+ // Rule 53: postfix_expression ::= typename dcolon_opt nested_name_specifier template_opt template_id_name ( expression_list_opt )
+ //
+ static final class Action53 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionTypeName();
+ }
+ }
+
+ //
+ // Rule 54: postfix_expression ::= postfix_expression . qualified_or_unqualified_name
+ //
+ static final class Action54 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionFieldReference(false, false);
+ }
+ }
+
+ //
+ // Rule 55: postfix_expression ::= postfix_expression -> qualified_or_unqualified_name
+ //
+ static final class Action55 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionFieldReference(true, false);
+ }
+ }
+
+ //
+ // Rule 56: postfix_expression ::= postfix_expression . template qualified_or_unqualified_name
+ //
+ static final class Action56 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionFieldReference(false, true);
+ }
+ }
+
+ //
+ // Rule 57: postfix_expression ::= postfix_expression -> template qualified_or_unqualified_name
+ //
+ static final class Action57 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionFieldReference(true, true);
+ }
+ }
+
+ //
+ // Rule 58: postfix_expression ::= postfix_expression . pseudo_destructor_name
+ //
+ static final class Action58 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionFieldReference(false, false);
+ }
+ }
+
+ //
+ // Rule 59: postfix_expression ::= postfix_expression -> pseudo_destructor_name
+ //
+ static final class Action59 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionFieldReference(true, false);
+ }
+ }
+
+ //
+ // Rule 60: postfix_expression ::= postfix_expression ++
+ //
+ static final class Action60 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixIncr);
+ }
+ }
+
+ //
+ // Rule 61: postfix_expression ::= postfix_expression --
+ //
+ static final class Action61 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_postFixDecr);
+ }
+ }
+
+ //
+ // Rule 62: postfix_expression ::= dynamic_cast < type_id > ( expression )
+ //
+ static final class Action62 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionCast(ICPPASTCastExpression.op_dynamic_cast);
+ }
+ }
+
+ //
+ // Rule 63: postfix_expression ::= static_cast < type_id > ( expression )
+ //
+ static final class Action63 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionCast(ICPPASTCastExpression.op_static_cast);
+ }
+ }
+
+ //
+ // Rule 64: postfix_expression ::= reinterpret_cast < type_id > ( expression )
+ //
+ static final class Action64 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionCast(ICPPASTCastExpression.op_reinterpret_cast);
+ }
+ }
+
+ //
+ // Rule 65: postfix_expression ::= const_cast < type_id > ( expression )
+ //
+ static final class Action65 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionCast(ICPPASTCastExpression.op_const_cast);
+ }
+ }
+
+ //
+ // Rule 66: postfix_expression ::= typeid ( expression )
+ //
+ static final class Action66 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(ICPPASTUnaryExpression.op_typeid);
+ }
+ }
+
+ //
+ // Rule 67: postfix_expression ::= typeid ( type_id )
+ //
+ static final class Action67 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionTypeId(ICPPASTTypeIdExpression.op_typeid);
+ }
+ }
+
+ //
+ // Rule 68: pseudo_destructor_name ::= dcolon_opt nested_name_specifier_opt type_name :: ~ type_name
+ //
+ static final class Action68 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePsudoDestructorName(true);
+ }
+ }
+
+ //
+ // Rule 69: pseudo_destructor_name ::= dcolon_opt nested_name_specifier template template_id_name :: ~ type_name
+ //
+ static final class Action69 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePsudoDestructorName(true);
+ }
+ }
+
+ //
+ // Rule 70: pseudo_destructor_name ::= dcolon_opt nested_name_specifier_opt ~ type_name
+ //
+ static final class Action70 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePsudoDestructorName(false);
+ }
+ }
+
+ //
+ // Rule 74: unary_expression ::= ++ cast_expression
+ //
+ static final class Action74 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixIncr);
+ }
+ }
+
+ //
+ // Rule 75: unary_expression ::= -- cast_expression
+ //
+ static final class Action75 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_prefixDecr);
+ }
+ }
+
+ //
+ // Rule 76: unary_expression ::= & cast_expression
+ //
+ static final class Action76 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_amper);
+ }
+ }
+
+ //
+ // Rule 77: unary_expression ::= * cast_expression
+ //
+ static final class Action77 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_star);
+ }
+ }
+
+ //
+ // Rule 78: unary_expression ::= + cast_expression
+ //
+ static final class Action78 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_plus);
+ }
+ }
+
+ //
+ // Rule 79: unary_expression ::= - cast_expression
+ //
+ static final class Action79 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_minus);
+ }
+ }
+
+ //
+ // Rule 80: unary_expression ::= ~ cast_expression
+ //
+ static final class Action80 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_tilde);
+ }
+ }
+
+ //
+ // Rule 81: unary_expression ::= ! cast_expression
+ //
+ static final class Action81 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_not);
+ }
+ }
+
+ //
+ // Rule 82: unary_expression ::= sizeof unary_expression
+ //
+ static final class Action82 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionUnaryOperator(IASTUnaryExpression.op_sizeof);
+ }
+ }
+
+ //
+ // Rule 83: unary_expression ::= sizeof ( type_id )
+ //
+ static final class Action83 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionTypeId(ICPPASTTypeIdExpression.op_sizeof);
+ }
+ }
+
+ //
+ // Rule 84: new_expression ::= dcolon_opt new new_placement_opt new_type_id <openscope-ast> new_array_expressions_opt new_initializer_opt
+ //
+ static final class Action84 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionNew(false);
+ }
+ }
+
+ //
+ // Rule 85: new_expression ::= dcolon_opt new new_placement_opt ( type_id ) new_initializer_opt
+ //
+ static final class Action85 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionNew(true);
+ }
+ }
+
+ //
+ // Rule 88: new_placement_opt ::= $Empty
+ //
+ static final class Action88 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 89: new_type_id ::= type_specifier_seq
+ //
+ static final class Action89 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTypeId(false);
+ }
+ }
+
+ //
+ // Rule 90: new_type_id ::= type_specifier_seq new_declarator
+ //
+ static final class Action90 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTypeId(true);
+ }
+ }
+
+ //
+ // Rule 91: new_declarator ::= <openscope-ast> new_pointer_operators
+ //
+ static final class Action91 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNewDeclarator();
+ }
+ }
+
+ //
+ // Rule 100: new_initializer_opt ::= $Empty
+ //
+ static final class Action100 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 101: delete_expression ::= dcolon_opt delete cast_expression
+ //
+ static final class Action101 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionDelete(false);
+ }
+ }
+
+ //
+ // Rule 102: delete_expression ::= dcolon_opt delete [ ] cast_expression
+ //
+ static final class Action102 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionDelete(true);
+ }
+ }
+
+ //
+ // Rule 104: cast_expression ::= ( type_id ) cast_expression
+ //
+ static final class Action104 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionCast(ICPPASTCastExpression.op_cast);
+ }
+ }
+
+ //
+ // Rule 106: pm_expression ::= pm_expression .* cast_expression
+ //
+ static final class Action106 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_pmdot);
+ }
+ }
+
+ //
+ // Rule 107: pm_expression ::= pm_expression ->* cast_expression
+ //
+ static final class Action107 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_pmarrow);
+ }
+ }
+
+ //
+ // Rule 109: multiplicative_expression ::= multiplicative_expression * pm_expression
+ //
+ static final class Action109 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_multiply);
+ }
+ }
+
+ //
+ // Rule 110: multiplicative_expression ::= multiplicative_expression / pm_expression
+ //
+ static final class Action110 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_divide);
+ }
+ }
+
+ //
+ // Rule 111: multiplicative_expression ::= multiplicative_expression % pm_expression
+ //
+ static final class Action111 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_modulo);
+ }
+ }
+
+ //
+ // Rule 113: additive_expression ::= additive_expression + multiplicative_expression
+ //
+ static final class Action113 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_plus);
+ }
+ }
+
+ //
+ // Rule 114: additive_expression ::= additive_expression - multiplicative_expression
+ //
+ static final class Action114 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_minus);
+ }
+ }
+
+ //
+ // Rule 116: shift_expression ::= shift_expression << additive_expression
+ //
+ static final class Action116 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_shiftLeft);
+ }
+ }
+
+ //
+ // Rule 117: shift_expression ::= shift_expression >> additive_expression
+ //
+ static final class Action117 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_shiftRight);
+ }
+ }
+
+ //
+ // Rule 119: relational_expression ::= relational_expression < shift_expression
+ //
+ static final class Action119 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_lessThan);
+ }
+ }
+
+ //
+ // Rule 120: relational_expression ::= relational_expression > shift_expression
+ //
+ static final class Action120 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_greaterThan);
+ }
+ }
+
+ //
+ // Rule 121: relational_expression ::= relational_expression <= shift_expression
+ //
+ static final class Action121 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_lessEqual);
+ }
+ }
+
+ //
+ // Rule 122: relational_expression ::= relational_expression >= shift_expression
+ //
+ static final class Action122 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_greaterEqual);
+ }
+ }
+
+ //
+ // Rule 124: equality_expression ::= equality_expression == relational_expression
+ //
+ static final class Action124 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_equals);
+ }
+ }
+
+ //
+ // Rule 125: equality_expression ::= equality_expression != relational_expression
+ //
+ static final class Action125 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_notequals);
+ }
+ }
+
+ //
+ // Rule 127: and_expression ::= and_expression & equality_expression
+ //
+ static final class Action127 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryAnd);
+ }
+ }
+
+ //
+ // Rule 129: exclusive_or_expression ::= exclusive_or_expression ^ and_expression
+ //
+ static final class Action129 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryXor);
+ }
+ }
+
+ //
+ // Rule 131: inclusive_or_expression ::= inclusive_or_expression | exclusive_or_expression
+ //
+ static final class Action131 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryOr);
+ }
+ }
+
+ //
+ // Rule 133: logical_and_expression ::= logical_and_expression && inclusive_or_expression
+ //
+ static final class Action133 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_logicalAnd);
+ }
+ }
+
+ //
+ // Rule 135: logical_or_expression ::= logical_or_expression || logical_and_expression
+ //
+ static final class Action135 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_logicalOr);
+ }
+ }
+
+ //
+ // Rule 137: conditional_expression ::= logical_or_expression ? expression : assignment_expression
+ //
+ static final class Action137 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionConditional();
+ }
+ }
+
+ //
+ // Rule 138: throw_expression ::= throw
+ //
+ static final class Action138 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionThrow(false);
+ }
+ }
+
+ //
+ // Rule 139: throw_expression ::= throw assignment_expression
+ //
+ static final class Action139 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionThrow(true);
+ }
+ }
+
+ //
+ // Rule 142: assignment_expression ::= logical_or_expression = assignment_expression
+ //
+ static final class Action142 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_assign);
+ }
+ }
+
+ //
+ // Rule 143: assignment_expression ::= logical_or_expression *= assignment_expression
+ //
+ static final class Action143 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_multiplyAssign);
+ }
+ }
+
+ //
+ // Rule 144: assignment_expression ::= logical_or_expression /= assignment_expression
+ //
+ static final class Action144 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_divideAssign);
+ }
+ }
+
+ //
+ // Rule 145: assignment_expression ::= logical_or_expression %= assignment_expression
+ //
+ static final class Action145 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_moduloAssign);
+ }
+ }
+
+ //
+ // Rule 146: assignment_expression ::= logical_or_expression += assignment_expression
+ //
+ static final class Action146 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_plusAssign);
+ }
+ }
+
+ //
+ // Rule 147: assignment_expression ::= logical_or_expression -= assignment_expression
+ //
+ static final class Action147 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_minusAssign);
+ }
+ }
+
+ //
+ // Rule 148: assignment_expression ::= logical_or_expression >>= assignment_expression
+ //
+ static final class Action148 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_shiftRightAssign);
+ }
+ }
+
+ //
+ // Rule 149: assignment_expression ::= logical_or_expression <<= assignment_expression
+ //
+ static final class Action149 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_shiftLeftAssign);
+ }
+ }
+
+ //
+ // Rule 150: assignment_expression ::= logical_or_expression &= assignment_expression
+ //
+ static final class Action150 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryAndAssign);
+ }
+ }
+
+ //
+ // Rule 151: assignment_expression ::= logical_or_expression ^= assignment_expression
+ //
+ static final class Action151 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryXorAssign);
+ }
+ }
+
+ //
+ // Rule 152: assignment_expression ::= logical_or_expression |= assignment_expression
+ //
+ static final class Action152 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionBinaryOperator(ICPPASTBinaryExpression.op_binaryOrAssign);
+ }
+ }
+
+ //
+ // Rule 154: expression ::= ERROR_TOKEN
+ //
+ static final class Action154 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionProblem();
+ }
+ }
+
+ //
+ // Rule 155: expression_list ::= <openscope-ast> expression_list_actual
+ //
+ static final class Action155 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeExpressionList();
+ }
+ }
+
+ //
+ // Rule 159: expression_list_opt ::= $Empty
+ //
+ static final class Action159 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 161: expression_opt ::= $Empty
+ //
+ static final class Action161 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 164: constant_expression_opt ::= $Empty
+ //
+ static final class Action164 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 173: statement ::= ERROR_TOKEN
+ //
+ static final class Action173 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementProblem();
+ }
+ }
+
+ //
+ // Rule 174: labeled_statement ::= identifier : statement
+ //
+ static final class Action174 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementLabeled();
+ }
+ }
+
+ //
+ // Rule 175: labeled_statement ::= case constant_expression :
+ //
+ static final class Action175 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementCase();
+ }
+ }
+
+ //
+ // Rule 176: labeled_statement ::= default :
+ //
+ static final class Action176 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementDefault();
+ }
+ }
+
+ //
+ // Rule 177: expression_statement ::= expression ;
+ //
+ static final class Action177 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementExpression();
+ }
+ }
+
+ //
+ // Rule 178: expression_statement ::= ;
+ //
+ static final class Action178 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementNull();
+ }
+ }
+
+ //
+ // Rule 179: compound_statement ::= { <openscope-ast> statement_seq }
+ //
+ static final class Action179 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementCompoundStatement(true);
+ }
+ }
+
+ //
+ // Rule 180: compound_statement ::= { }
+ //
+ static final class Action180 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementCompoundStatement(false);
+ }
+ }
+
+ //
+ // Rule 183: selection_statement ::= if ( condition ) statement
+ //
+ static final class Action183 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementIf(false);
+ }
+ }
+
+ //
+ // Rule 184: selection_statement ::= if ( condition ) statement else statement
+ //
+ static final class Action184 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementIf(true);
+ }
+ }
+
+ //
+ // Rule 185: selection_statement ::= switch ( condition ) statement
+ //
+ static final class Action185 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementSwitch();
+ }
+ }
+
+ //
+ // Rule 187: condition ::= type_specifier_seq declarator = assignment_expression
+ //
+ static final class Action187 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeConditionDeclaration();
+ }
+ }
+
+ //
+ // Rule 188: iteration_statement ::= while ( condition ) statement
+ //
+ static final class Action188 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementWhileLoop();
+ }
+ }
+
+ //
+ // Rule 189: iteration_statement ::= do statement while ( expression ) ;
+ //
+ static final class Action189 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementDoLoop();
+ }
+ }
+
+ //
+ // Rule 190: iteration_statement ::= for ( expression_opt ; expression_opt ; expression_opt ) statement
+ //
+ static final class Action190 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementForLoop();
+ }
+ }
+
+ //
+ // Rule 191: iteration_statement ::= for ( simple_declaration expression_opt ; expression_opt ) statement
+ //
+ static final class Action191 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementForLoop();
+ }
+ }
+
+ //
+ // Rule 192: jump_statement ::= break ;
+ //
+ static final class Action192 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementBreak();
+ }
+ }
+
+ //
+ // Rule 193: jump_statement ::= continue ;
+ //
+ static final class Action193 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementContinue();
+ }
+ }
+
+ //
+ // Rule 194: jump_statement ::= return expression ;
+ //
+ static final class Action194 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementReturn(true);
+ }
+ }
+
+ //
+ // Rule 195: jump_statement ::= return ;
+ //
+ static final class Action195 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementReturn(false);
+ }
+ }
+
+ //
+ // Rule 196: jump_statement ::= goto identifier ;
+ //
+ static final class Action196 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementGoto();
+ }
+ }
+
+ //
+ // Rule 197: declaration_statement ::= block_declaration
+ //
+ static final class Action197 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementDeclaration();
+ }
+ }
+
+ //
+ // Rule 214: simple_declaration ::= declaration_specifiers_opt <openscope-ast> init_declarator_list_opt ;
+ //
+ static final class Action214 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclarationSimple(true);
+ }
+ }
+
+ //
+ // Rule 215: declaration_specifiers ::= <openscope-ast> simple_declaration_specifiers
+ //
+ static final class Action215 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclarationSpecifiersSimple();
+ }
+ }
+
+ //
+ // Rule 216: declaration_specifiers ::= <openscope-ast> class_declaration_specifiers
+ //
+ static final class Action216 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclarationSpecifiersComposite();
+ }
+ }
+
+ //
+ // Rule 217: declaration_specifiers ::= <openscope-ast> elaborated_declaration_specifiers
+ //
+ static final class Action217 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclarationSpecifiersComposite();
+ }
+ }
+
+ //
+ // Rule 218: declaration_specifiers ::= <openscope-ast> enum_declaration_specifiers
+ //
+ static final class Action218 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclarationSpecifiersComposite();
+ }
+ }
+
+ //
+ // Rule 219: declaration_specifiers ::= <openscope-ast> type_name_declaration_specifiers
+ //
+ static final class Action219 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclarationSpecifiersTypeName();
+ }
+ }
+
+ //
+ // Rule 221: declaration_specifiers_opt ::= $Empty
+ //
+ static final class Action221 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 224: no_type_declaration_specifier ::= friend
+ //
+ static final class Action224 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclSpecToken();
+ }
+ }
+
+ //
+ // Rule 225: no_type_declaration_specifier ::= typedef
+ //
+ static final class Action225 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclSpecToken();
+ }
+ }
+
+ //
+ // Rule 258: simple_type_specifier ::= simple_type_specifier_token
+ //
+ static final class Action258 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclSpecToken();
+ }
+ }
+
+ //
+ // Rule 274: type_name_specifier ::= dcolon_opt nested_name_specifier_opt type_name
+ //
+ static final class Action274 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeQualifiedId(false);
+ }
+ }
+
+ //
+ // Rule 275: type_name_specifier ::= dcolon_opt nested_name_specifier template template_id_name
+ //
+ static final class Action275 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeQualifiedId(false);
+ }
+ }
+
+ //
+ // Rule 276: type_name_specifier ::= typename dcolon_opt nested_name_specifier identifier_name
+ //
+ static final class Action276 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeQualifiedId(false);
+ }
+ }
+
+ //
+ // Rule 277: type_name_specifier ::= typename dcolon_opt nested_name_specifier template_opt template_id_name
+ //
+ static final class Action277 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeQualifiedId(true);
+ }
+ }
+
+ //
+ // Rule 278: elaborated_type_specifier ::= class_keyword dcolon_opt nested_name_specifier_opt identifier_name
+ //
+ static final class Action278 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTypeSpecifierElaborated(false);
+ }
+ }
+
+ //
+ // Rule 279: elaborated_type_specifier ::= class_keyword dcolon_opt nested_name_specifier_opt template_opt template_id_name
+ //
+ static final class Action279 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTypeSpecifierElaborated(true);
+ }
+ }
+
+ //
+ // Rule 280: elaborated_type_specifier ::= enum dcolon_opt nested_name_specifier_opt identifier_name
+ //
+ static final class Action280 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTypeSpecifierElaborated(false);
+ }
+ }
+
+ //
+ // Rule 282: enum_specifier ::= enum { <openscope-ast> enumerator_list_opt }
+ //
+ static final class Action282 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTypeSpecifierEnumeration(false);
+ }
+ }
+
+ //
+ // Rule 283: enum_specifier ::= enum identifier { <openscope-ast> enumerator_list_opt }
+ //
+ static final class Action283 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTypeSpecifierEnumeration(true);
+ }
+ }
+
+ //
+ // Rule 288: enumerator_definition ::= enumerator
+ //
+ static final class Action288 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEnumerator(false);
+ }
+ }
+
+ //
+ // Rule 289: enumerator_definition ::= enumerator = constant_expression
+ //
+ static final class Action289 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEnumerator(true);
+ }
+ }
+
+ //
+ // Rule 298: original_namespace_definition ::= namespace identifier_name { <openscope-ast> declaration_seq_opt }
+ //
+ static final class Action298 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNamespaceDefinition(true);
+ }
+ }
+
+ //
+ // Rule 299: extension_namespace_definition ::= namespace original_namespace_name { <openscope-ast> declaration_seq_opt }
+ //
+ static final class Action299 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNamespaceDefinition(true);
+ }
+ }
+
+ //
+ // Rule 300: unnamed_namespace_definition ::= namespace { <openscope-ast> declaration_seq_opt }
+ //
+ static final class Action300 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNamespaceDefinition(false);
+ }
+ }
+
+ //
+ // Rule 302: namespace_alias_definition ::= namespace identifier = dcolon_opt nested_name_specifier_opt namespace_name ;
+ //
+ static final class Action302 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeNamespaceAliasDefinition();
+ }
+ }
+
+ //
+ // Rule 303: using_declaration ::= using typename_opt dcolon_opt nested_name_specifier_opt unqualified_id_name ;
+ //
+ static final class Action303 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeUsingDeclaration();
+ }
+ }
+
+ //
+ // Rule 304: typename_opt ::= typename
+ //
+ static final class Action304 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePlaceHolder();
+ }
+ }
+
+ //
+ // Rule 305: typename_opt ::= $Empty
+ //
+ static final class Action305 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 306: using_directive ::= using namespace dcolon_opt nested_name_specifier_opt namespace_name ;
+ //
+ static final class Action306 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeUsingDirective();
+ }
+ }
+
+ //
+ // Rule 307: asm_definition ::= asm ( stringlit ) ;
+ //
+ static final class Action307 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclarationASM();
+ }
+ }
+
+ //
+ // Rule 308: linkage_specification ::= extern stringlit { <openscope-ast> declaration_seq_opt }
+ //
+ static final class Action308 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeLinkageSpecification();
+ }
+ }
+
+ //
+ // Rule 309: linkage_specification ::= extern stringlit <openscope-ast> declaration
+ //
+ static final class Action309 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeLinkageSpecification();
+ }
+ }
+
+ //
+ // Rule 315: init_declarator ::= declarator initializer
+ //
+ static final class Action315 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclaratorWithInitializer();
+ }
+ }
+
+ //
+ // Rule 316: declarator ::= <openscope-ast> ptr_operator_seq_opt direct_declarator
+ //
+ static final class Action316 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclaratorWithPointer();
+ }
+ }
+
+ //
+ // Rule 320: basic_direct_declarator ::= declarator_id_name
+ //
+ static final class Action320 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDirectDeclaratorIdentifier();
+ }
+ }
+
+ //
+ // Rule 321: basic_direct_declarator ::= ( declarator )
+ //
+ static final class Action321 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDirectDeclaratorBracketed();
+ }
+ }
+
+ //
+ // Rule 322: function_direct_declarator ::= basic_direct_declarator ( <openscope-ast> parameter_declaration_clause ) <openscope-ast> cv_qualifier_seq_opt <openscope-ast> exception_specification_opt
+ //
+ static final class Action322 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDirectDeclaratorFunctionDeclarator();
+ }
+ }
+
+ //
+ // Rule 323: array_direct_declarator ::= array_direct_declarator array_modifier
+ //
+ static final class Action323 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDirectDeclaratorArrayDeclarator();
+ }
+ }
+
+ //
+ // Rule 324: array_direct_declarator ::= basic_direct_declarator array_modifier
+ //
+ static final class Action324 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDirectDeclaratorArrayDeclarator();
+ }
+ }
+
+ //
+ // Rule 325: array_modifier ::= [ constant_expression ]
+ //
+ static final class Action325 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDirectDeclaratorArrayModifier(true);
+ }
+ }
+
+ //
+ // Rule 326: array_modifier ::= [ ]
+ //
+ static final class Action326 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDirectDeclaratorArrayModifier(false);
+ }
+ }
+
+ //
+ // Rule 327: ptr_operator ::= * <openscope-ast> cv_qualifier_seq_opt
+ //
+ static final class Action327 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePointer();
+ }
+ }
+
+ //
+ // Rule 328: ptr_operator ::= &
+ //
+ static final class Action328 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeReferenceOperator();
+ }
+ }
+
+ //
+ // Rule 329: ptr_operator ::= dcolon_opt nested_name_specifier * <openscope-ast> cv_qualifier_seq_opt
+ //
+ static final class Action329 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePointerToMember();
+ }
+ }
+
+ //
+ // Rule 337: cv_qualifier ::= const
+ //
+ static final class Action337 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclSpecToken();
+ }
+ }
+
+ //
+ // Rule 338: cv_qualifier ::= volatile
+ //
+ static final class Action338 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeDeclSpecToken();
+ }
+ }
+
+ //
+ // Rule 340: declarator_id_name ::= dcolon_opt nested_name_specifier_opt type_name
+ //
+ static final class Action340 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeQualifiedId(false);
+ }
+ }
+
+ //
+ // Rule 341: type_id ::= type_specifier_seq
+ //
+ static final class Action341 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTypeId(false);
+ }
+ }
+
+ //
+ // Rule 342: type_id ::= type_specifier_seq abstract_declarator
+ //
+ static final class Action342 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTypeId(true);
+ }
+ }
+
+ //
+ // Rule 354: parameter_declaration_clause ::= parameter_declaration_list_opt ...
+ //
+ static final class Action354 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePlaceHolder();
+ }
+ }
+
+ //
+ // Rule 355: parameter_declaration_clause ::= parameter_declaration_list_opt
+ //
+ static final class Action355 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 356: parameter_declaration_clause ::= parameter_declaration_list , ...
+ //
+ static final class Action356 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePlaceHolder();
+ }
+ }
+
+ //
+ // Rule 369: initializer ::= ( expression_list )
+ //
+ static final class Action369 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeInitializerConstructor();
+ }
+ }
+
+ //
+ // Rule 370: initializer_clause ::= assignment_expression
+ //
+ static final class Action370 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeInitializer();
+ }
+ }
+
+ //
+ // Rule 371: initializer_clause ::= { <openscope-ast> initializer_list , }
+ //
+ static final class Action371 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeInitializerList();
+ }
+ }
+
+ //
+ // Rule 372: initializer_clause ::= { <openscope-ast> initializer_list }
+ //
+ static final class Action372 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeInitializerList();
+ }
+ }
+
+ //
+ // Rule 373: initializer_clause ::= { <openscope-ast> }
+ //
+ static final class Action373 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeInitializerList();
+ }
+ }
+
+ //
+ // Rule 378: class_specifier ::= class_head { <openscope-ast> member_declaration_list_opt }
+ //
+ static final class Action378 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeClassSpecifier();
+ }
+ }
+
+ //
+ // Rule 379: class_head ::= class_keyword identifier_name_opt <openscope-ast> base_clause_opt
+ //
+ static final class Action379 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeClassHead(false);
+ }
+ }
+
+ //
+ // Rule 380: class_head ::= class_keyword template_id_name <openscope-ast> base_clause_opt
+ //
+ static final class Action380 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeClassHead(false);
+ }
+ }
+
+ //
+ // Rule 381: class_head ::= class_keyword nested_name_specifier identifier_name <openscope-ast> base_clause_opt
+ //
+ static final class Action381 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeClassHead(true);
+ }
+ }
+
+ //
+ // Rule 382: class_head ::= class_keyword nested_name_specifier template_id_name <openscope-ast> base_clause_opt
+ //
+ static final class Action382 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeClassHead(true);
+ }
+ }
+
+ //
+ // Rule 386: identifier_name_opt ::= $Empty
+ //
+ static final class Action386 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 390: visibility_label ::= access_specifier_keyword :
+ //
+ static final class Action390 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeVisibilityLabel();
+ }
+ }
+
+ //
+ // Rule 416: base_specifier ::= dcolon_opt nested_name_specifier_opt class_name
+ //
+ static final class Action416 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeBaseSpecifier(false);
+ }
+ }
+
+ //
+ // Rule 417: base_specifier ::= virtual_opt access_specifier_keyword virtual_opt dcolon_opt nested_name_specifier_opt class_name
+ //
+ static final class Action417 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeBaseSpecifier(true);
+ }
+ }
+
+ //
+ // Rule 418: virtual_opt ::= virtual
+ //
+ static final class Action418 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePlaceHolder();
+ }
+ }
+
+ //
+ // Rule 419: virtual_opt ::= $Empty
+ //
+ static final class Action419 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 425: conversion_function_id_name ::= operator conversion_type_id
+ //
+ static final class Action425 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeConversionName();
+ }
+ }
+
+ //
+ // Rule 439: operator_function_id_name ::= operator_id_name < <openscope-ast> template_argument_list_opt >
+ //
+ static final class Action439 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTemplateId();
+ }
+ }
+
+ //
+ // Rule 440: operator_id_name ::= operator overloadable_operator
+ //
+ static final class Action440 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeOperatorName();
+ }
+ }
+
+ //
+ // Rule 483: template_declaration ::= export_opt template < template_parameter_list > declaration
+ //
+ static final class Action483 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTemplateDeclaration();
+ }
+ }
+
+ //
+ // Rule 484: export_opt ::= export
+ //
+ static final class Action484 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumePlaceHolder();
+ }
+ }
+
+ //
+ // Rule 485: export_opt ::= $Empty
+ //
+ static final class Action485 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeEmpty();
+ }
+ }
+
+ //
+ // Rule 496: template_id_name ::= template_identifier < <openscope-ast> template_argument_list_opt >
+ //
+ static final class Action496 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTemplateId();
+ }
+ }
+
+ //
+ // Rule 505: explicit_instantiation ::= template declaration
+ //
+ static final class Action505 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTemplateExplicitInstantiation();
+ }
+ }
+
+ //
+ // Rule 506: explicit_specialization ::= template < > declaration
+ //
+ static final class Action506 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeTemplateExplicitSpecialization();
+ }
+ }
+
+ //
+ // Rule 507: try_block ::= try compound_statement <openscope-ast> handler_seq
+ //
+ static final class Action507 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementTryBlock();
+ }
+ }
+
+ //
+ // Rule 511: handler ::= catch ( exception_declaration ) compound_statement
+ //
+ static final class Action511 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementCatchHandler(false);
+ }
+ }
+
+ //
+ // Rule 512: handler ::= catch ( ... ) compound_statement
+ //
+ static final class Action512 extends DeclaredAction< CPPParserAction , Object > {
+
+ public void doFinal(ITrialUndoActionProvider< Object > provider, CPPParserAction action) { action.builder.
+ consumeStatementCatchHandler(true);
+ }
+ }
+
+}
+
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParserAction.java
new file mode 100644
index 00000000000..2297dafc14d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParserAction.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.lrparser.cpp;
+
+import org.eclipse.cdt.core.dom.lrparser.action.cpp.CPPBuildASTParserAction;
+
+class CPPParserAction {
+
+ public CPPBuildASTParserAction builder;
+
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParserprs.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParserprs.java
new file mode 100644
index 00000000000..aad6ab5d68d
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParserprs.java
@@ -0,0 +1,2882 @@
+/*******************************************************************************
+* Copyright (c) 2006, 2008 IBM Corporation and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl_v10.html
+*
+* Contributors:
+* IBM Corporation - initial API and implementation
+*********************************************************************************/
+
+// This file was generated by LPG
+
+package org.eclipse.cdt.internal.core.dom.lrparser.cpp;
+
+public class CPPParserprs implements lpg.lpgjavaruntime.ParseTable, CPPParsersym {
+
+ public interface IsKeyword {
+ public final static byte isKeyword[] = {0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0
+ };
+ };
+ public final static byte isKeyword[] = IsKeyword.isKeyword;
+ public final boolean isKeyword(int index) { return isKeyword[index] != 0; }
+
+ public interface BaseCheck {
+ public final static short baseCheck[] = {0,
+ 0,0,0,0,0,1,1,1,1,1,
+ 0,1,1,1,1,1,1,1,1,1,
+ 3,1,1,1,1,1,1,1,2,1,
+ 1,0,1,0,4,2,2,2,3,2,
+ 3,2,2,1,0,1,1,1,4,4,
+ 4,8,8,3,3,4,4,3,3,2,
+ 2,7,7,7,7,4,4,6,7,4,
+ 1,1,1,2,2,2,2,2,2,2,
+ 2,2,4,7,7,3,1,0,1,2,
+ 2,1,2,3,4,1,0,3,1,0,
+ 3,5,1,4,1,3,3,1,3,3,
+ 3,1,3,3,1,3,3,1,3,3,
+ 3,3,1,3,3,1,3,1,3,1,
+ 3,1,3,1,3,1,5,1,2,1,
+ 1,3,3,3,3,3,3,3,3,3,
+ 3,3,1,1,2,1,3,1,0,1,
+ 0,1,1,0,1,1,1,1,1,1,
+ 1,1,1,3,3,2,2,1,4,2,
+ 1,2,5,7,5,1,4,5,7,9,
+ 8,2,2,3,2,3,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 2,1,0,4,2,2,2,2,2,1,
+ 0,1,1,1,1,1,2,1,2,2,
+ 2,1,2,2,1,2,2,1,2,2,
+ 1,2,2,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,3,4,4,5,4,5,4,
+ 1,5,6,1,3,1,0,1,3,1,
+ 1,1,1,1,1,1,1,6,6,5,
+ 1,7,6,1,0,6,5,6,4,1,
+ 3,1,0,1,2,3,1,1,1,1,
+ 3,9,2,2,3,2,3,1,5,1,
+ 2,1,0,2,1,0,1,1,1,3,
+ 1,2,1,2,2,1,1,0,9,4,
+ 3,1,0,2,1,3,1,3,1,0,
+ 2,4,2,4,4,3,1,2,3,1,
+ 5,4,3,1,3,1,1,5,4,4,
+ 5,5,1,0,1,0,1,1,1,2,
+ 3,2,2,1,5,1,1,1,1,2,
+ 1,0,1,3,1,2,2,3,2,2,
+ 2,1,0,1,3,3,6,1,0,1,
+ 1,1,1,0,2,2,2,1,0,2,
+ 1,0,1,3,4,3,1,1,5,2,
+ 1,1,3,3,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 2,2,6,1,0,1,3,1,1,2,
+ 4,2,4,6,8,5,1,1,3,1,
+ 0,1,1,1,2,4,4,4,1,2,
+ 5,5,2,2,1,4,3,1,0,1,
+ 3,-237,0,0,0,0,-77,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-41,0,0,
+ 0,0,-2,0,0,0,0,-53,0,0,
+ 0,0,0,0,0,0,-3,0,0,-111,
+ 0,0,-405,0,0,0,0,-118,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-80,0,
+ 0,-10,0,0,0,0,0,0,-447,0,
+ 0,0,0,0,0,0,-5,-67,0,0,
+ -65,0,0,0,-23,-6,0,0,0,0,
+ 0,0,0,-357,0,0,0,0,0,-8,
+ -107,0,0,0,0,0,0,-121,0,0,
+ -13,0,0,0,0,0,0,0,0,-109,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -140,0,0,0,0,0,-244,0,-189,0,
+ 0,0,0,0,0,0,0,-12,-198,0,
+ 0,0,0,0,0,-250,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-85,0,0,0,
+ 0,0,0,0,-14,0,0,0,0,0,
+ 0,0,0,-119,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-210,0,0,
+ 0,0,-102,0,-253,0,0,0,0,-86,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -18,0,0,-19,0,-26,0,0,0,0,
+ 0,0,0,-94,-27,0,0,0,0,0,
+ 0,0,-269,0,0,0,0,0,0,-264,
+ 0,0,0,0,0,0,0,0,-43,0,
+ 0,-136,-317,0,0,0,0,-20,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-248,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-404,0,0,0,-30,0,0,-95,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-32,0,0,
+ 0,0,0,0,-92,0,0,0,-146,0,
+ 0,0,0,0,0,0,-9,-28,0,0,
+ 0,0,0,0,-195,0,0,0,0,-150,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-33,0,0,0,0,
+ -17,0,0,0,0,0,0,0,-93,0,
+ -46,-22,0,0,-24,0,0,0,0,-137,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-98,0,0,-184,0,
+ -305,0,0,0,0,-181,0,0,0,0,
+ -141,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-31,0,-78,0,0,
+ 0,0,0,0,0,0,0,0,0,-217,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-38,0,0,-34,0,
+ 0,0,0,0,0,0,0,-45,0,0,
+ 0,0,-207,0,0,0,0,-218,0,0,
+ 0,0,-48,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-56,0,0,0,0,0,0,
+ 0,0,0,-410,0,0,-35,-468,-434,-58,
+ 0,0,0,0,0,-220,0,0,0,0,
+ -265,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-108,0,0,0,0,-439,0,0,0,
+ 0,-292,0,0,0,0,-59,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -239,0,0,0,0,0,0,-105,-84,0,
+ -422,-359,0,0,0,0,-60,0,0,0,
+ 0,0,0,0,0,-293,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-36,0,-454,-246,0,0,0,-66,0,
+ 0,0,0,-294,0,0,0,0,-482,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-50,0,0,0,0,0,
+ -75,0,-321,-52,0,0,-76,0,0,0,
+ 0,-295,0,0,0,0,-81,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-54,0,0,
+ 0,0,0,0,0,0,0,-57,0,-83,
+ -89,0,0,0,0,0,0,0,0,-296,
+ 0,0,0,0,-490,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-192,0,0,-193,0,
+ -61,0,0,0,0,0,-63,0,-90,0,
+ -71,0,0,0,0,0,0,-297,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-316,0,0,0,0,-69,0,
+ 0,0,0,0,-70,0,-435,0,0,0,
+ 0,0,-112,0,0,-298,0,0,0,0,
+ -469,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-100,0,0,-97,0,0,0,0,0,
+ 0,0,0,0,-437,0,0,-451,0,0,
+ -124,0,0,-299,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-101,
+ 0,0,0,0,0,0,0,0,0,-460,
+ 0,0,-106,-138,-125,0,0,0,0,0,
+ 0,-300,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-113,0,0,
+ -126,0,-127,0,0,0,0,0,-144,0,
+ -151,-187,-157,0,-129,0,0,0,0,-301,
+ 0,0,0,0,-148,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-120,0,0,-130,0,
+ 0,0,0,0,0,0,-183,-211,-142,-213,
+ -333,0,-149,0,0,0,0,-302,0,0,
+ 0,0,-219,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-221,-226,-424,-234,-143,0,
+ 0,0,-235,0,0,-342,0,0,0,0,
+ -249,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-185,0,0,0,0,0,0,0,0,
+ 0,0,-236,-307,-336,-242,-152,0,-241,0,
+ -147,0,0,-420,0,0,0,0,-311,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-438,0,0,0,0,0,
+ -403,-318,-153,-329,-154,0,-261,0,-386,0,
+ 0,-455,0,0,0,0,-262,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-155,-330,
+ -411,-394,-103,0,-156,0,0,0,0,-224,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-315,0,0,0,0,
+ -158,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-453,0,0,0,0,-421,-170,-171,0,
+ 0,0,0,0,0,-110,-172,-350,0,-383,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-173,0,
+ -338,0,0,0,0,-384,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-251,0,0,0,-381,0,0,0,0,
+ 0,0,0,0,0,0,0,-306,-199,-486,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-174,0,0,-175,0,
+ 0,0,0,0,0,-304,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-208,0,0,0,0,0,0,0,-161,
+ 0,0,0,0,-388,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-291,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-414,0,0,-176,0,
+ 0,0,-289,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-209,0,
+ 0,-314,0,-290,0,0,0,0,-177,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-7,0,0,0,0,-343,0,0,
+ -163,0,0,0,0,-178,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-51,-398,0,-419,0,0,-179,0,
+ -180,-430,0,0,0,0,0,-286,0,0,
+ 0,0,-182,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-270,0,0,0,0,
+ 0,-188,-196,0,0,0,0,0,0,-320,
+ -436,0,0,0,0,0,0,-42,-200,-448,
+ 0,0,0,0,0,-201,-458,-202,-287,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -288,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-1,0,0,-15,
+ -204,0,-280,0,0,0,0,-104,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-68,-426,0,
+ -205,0,0,0,0,-87,0,0,0,-385,
+ -353,-96,-361,0,0,-206,0,0,-344,0,
+ -345,-135,0,0,0,0,0,0,-16,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-351,0,0,0,0,0,0,0,
+ 0,0,0,-212,0,-214,-356,0,0,0,
+ 0,0,0,0,0,0,-134,0,0,0,
+ -74,-355,-233,0,0,0,0,0,0,0,
+ -133,0,-360,-480,0,0,0,0,-309,0,
+ -223,0,0,0,-393,0,-487,0,0,0,
+ -313,-49,0,0,0,-389,0,0,0,0,
+ 0,0,-47,0,-115,0,0,0,0,0,
+ 0,0,0,0,-225,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-227,-228,-495,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-229,0,0,-231,-116,0,
+ 0,0,0,0,0,0,-232,0,0,0,
+ 0,0,0,0,-390,0,0,0,0,0,
+ 0,-238,-392,-240,0,0,0,0,0,0,
+ 0,0,0,0,-243,-245,0,-21,0,0,
+ 0,0,-252,0,-267,0,0,0,-268,0,
+ -308,0,0,0,0,0,0,0,0,-396,
+ 0,0,0,0,0,0,0,-310,0,0,
+ 0,0,0,0,0,0,0,-319,-322,0,
+ 0,0,0,0,0,-327,0,0,-461,0,
+ 0,0,-332,0,0,-335,0,0,0,-281,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-282,0,0,0,0,-339,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-283,
+ 0,0,0,0,-400,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-132,-387,0,0,0,0,
+ -340,-341,-128,-346,-401,0,0,-416,-145,0,
+ 0,0,-418,0,0,0,-347,-476,-446,-348,
+ 0,-391,0,-459,0,-349,0,0,0,-362,
+ -363,0,0,0,-222,0,-462,0,0,0,
+ -364,0,0,0,-247,0,-365,0,0,0,
+ 0,0,0,0,0,-463,0,0,-464,-366,
+ 0,0,0,0,0,0,0,0,-367,-368,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-369,-370,0,0,0,-371,0,
+ 0,0,0,0,-372,-373,0,0,0,0,
+ 0,0,0,0,0,0,0,-374,-375,0,
+ -376,-377,0,-378,0,0,0,0,0,0,
+ 0,0,-284,0,0,0,0,-379,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-285,0,0,0,
+ 0,-380,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -4,0,-395,-406,-407,0,-275,0,0,0,
+ 0,-465,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-431,
+ -478,-11,0,0,0,-194,0,-483,0,0,
+ -408,-409,0,-423,-425,-428,-472,-444,0,-484,
+ 0,0,-492,0,-494,0,0,0,0,0,
+ -445,0,-37,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-450,0,0,0,0,-457,0,0,0,
+ 0,0,-456,-39,0,0,0,-470,0,-499,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-473,0,0,0,0,-474,-479,0,0,
+ 0,0,0,0,-114,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-481,0,0,-489,0,-493,0,0,
+ 0,0,0,0,0,-122,0,0,0,0,
+ 0,-399,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -230,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-402,0,0,-260,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-449,0,0,0,0,0,0,0,
+ -271,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-190,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-276,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-323,0,0,0,-331,0,0,0,0,
+ 0,-272,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-466,0,0,0,0,0,
+ 0,0,-475,0,0,0,0,0,0,0,
+ 0,-427,-488,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -203,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-40,0,0,0,
+ 0,0,-123,0,-429,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-433,0,0,0,0,0,
+ 0,0,0,-467,-485,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-382,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-88,0,
+ 0,0,0,0,0,0,0,-477,0,-79,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-491,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -303,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -497,0,0,0,-432,0,0,0,0,0,
+ 0,-64,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-440,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-441,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-277,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -278,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-279,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-25,0,0,0,0,0,
+ 0,0,-162,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-164,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -165,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -166,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-167,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-168,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-169,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-263,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-273,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-274,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-352,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-412,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-44,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,-159,0,0,0,0,0,0,
+ 0,0,-442,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-254,0,0,0,0,
+ 0,0,0,0,0,0,0,-443,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-197,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-266,0,0,0,0,0,0,0,0,
+ 0,0,0,-471,0,0,0,0,0,0,
+ 0,0,0,-324,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-325,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -328,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-99,0,0,0,0,0,
+ 0,0,0,0,0,0,-496,0,0,0,
+ -139,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-131,0,0,0,
+ 0,-498,0,0,0,0,0,0,0,-191,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-215,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-216,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-255,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -256,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-257,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,-258,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-337,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,-354,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-413,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-415,-29,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -500,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,-55,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-62,0,
+ 0,0,0,0,0,0,0,-72,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-73,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-82,
+ 0,0,0,0,0,0,0,0,-91,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,-117,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -312,0,0,0,0,0,0,0,0,-334,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,-358,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,-452,0,0,0,0,0,0,0,0,
+ -160,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-186,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -259,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,-326,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ -397,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,-417,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0
+ };
+ };
+ public final static short baseCheck[] = BaseCheck.baseCheck;
+ public final int baseCheck(int index) { return baseCheck[index]; }
+ public final static short rhs[] = baseCheck;
+ public final int rhs(int index) { return rhs[index]; };
+
+ public interface BaseAction {
+ public final static char baseAction[] = {
+ 169,5,194,195,196,123,79,31,66,39,
+ 169,169,14,14,14,14,14,14,14,14,
+ 15,15,15,12,12,10,10,10,10,10,
+ 3,69,69,4,4,13,13,13,13,60,
+ 60,124,124,125,67,67,54,54,16,16,
+ 16,16,16,16,16,16,16,16,16,16,
+ 16,16,16,16,16,16,16,16,126,126,
+ 126,17,17,17,17,17,17,17,17,17,
+ 17,17,17,17,18,18,173,170,170,171,
+ 171,174,128,128,175,175,172,172,129,127,
+ 127,19,19,20,20,21,21,21,22,22,
+ 22,22,23,23,23,24,24,24,25,25,
+ 25,25,25,27,27,27,28,28,30,30,
+ 32,32,33,33,34,34,35,35,47,47,
+ 46,46,46,46,46,46,46,46,46,46,
+ 46,46,46,37,37,26,130,130,96,96,
+ 99,99,95,176,176,80,80,80,80,80,
+ 80,80,80,80,81,81,81,82,82,62,
+ 62,177,177,83,83,83,110,110,84,84,
+ 84,84,85,85,85,85,85,86,70,70,
+ 70,70,70,70,70,56,56,56,56,56,
+ 98,98,106,106,53,38,38,38,38,38,
+ 48,48,92,92,92,92,137,137,132,132,
+ 132,132,133,133,133,134,134,134,135,135,
+ 135,136,136,136,93,93,93,93,93,94,
+ 94,94,90,45,45,45,45,45,6,7,
+ 7,7,7,7,7,7,7,7,7,7,
+ 89,89,89,111,111,111,111,111,41,41,
+ 41,91,42,42,139,139,138,138,112,112,
+ 113,50,50,49,74,74,75,75,77,78,
+ 76,52,58,51,140,140,59,57,73,73,
+ 141,141,131,131,114,114,88,179,179,179,
+ 180,180,181,182,182,145,145,68,68,68,
+ 146,146,142,142,101,100,100,36,36,183,
+ 183,61,61,55,55,102,102,147,147,103,
+ 103,103,104,104,143,143,143,149,149,148,
+ 148,97,97,97,97,63,63,150,178,178,
+ 116,116,116,116,184,184,29,29,40,44,
+ 44,44,44,105,105,186,186,43,43,43,
+ 152,153,153,153,153,153,153,153,153,188,
+ 188,185,185,187,187,154,154,154,154,155,
+ 156,108,107,107,189,189,157,157,118,118,
+ 117,117,117,197,197,11,190,159,158,158,
+ 119,115,115,160,160,161,162,162,8,8,
+ 9,164,164,164,164,164,164,164,164,164,
+ 164,164,164,164,164,164,164,164,164,164,
+ 164,164,164,164,164,164,164,164,164,164,
+ 164,164,164,164,164,164,164,164,164,164,
+ 164,164,164,64,65,65,165,165,120,120,
+ 121,121,121,121,121,121,1,2,166,166,
+ 163,163,122,122,122,71,72,87,151,167,
+ 167,109,109,191,191,191,168,168,144,144,
+ 192,192,1151,2695,816,2699,4820,1475,2743,258,
+ 26,1431,23,27,22,24,20,48,1998,103,
+ 72,73,105,1999,2039,2007,2129,2126,1711,2259,
+ 2219,270,2319,763,2296,2321,2333,140,1025,1562,
+ 816,1610,232,235,238,2688,814,49,156,141,
+ 1609,275,816,2793,28,816,25,4891,1619,1961,
+ 258,26,1431,23,27,22,24,20,48,1998,
+ 103,72,73,105,1999,2039,2007,2129,2126,908,
+ 2259,2219,1673,2319,2825,2296,2321,2333,140,2788,
+ 367,273,272,271,226,222,223,1009,838,370,
+ 141,1413,377,816,376,1342,75,291,1718,4669,
+ 292,2509,1581,241,494,28,816,25,4976,371,
+ 159,1547,26,1431,23,27,57,24,983,1533,
+ 270,242,2693,2283,1001,811,858,1012,1015,3785,
+ 1628,28,816,25,4891,180,2451,258,26,1431,
+ 23,27,2481,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,3530,2259,2219,375,
+ 2319,135,2296,2321,2333,140,257,135,365,1259,
+ 254,256,255,2688,814,343,502,141,1554,1547,
+ 274,272,271,3063,2450,3391,1628,28,816,25,
+ 4891,503,2451,258,26,1431,23,27,2481,24,
+ 20,48,1998,103,72,73,105,1999,2039,2007,
+ 2129,2126,1332,2259,2219,489,2319,1478,2296,2321,
+ 2333,140,257,284,2379,997,254,256,255,2688,
+ 814,343,502,141,752,28,816,25,487,488,
+ 482,3391,26,1431,1720,27,325,503,1619,2099,
+ 2386,1541,498,410,3098,2721,28,816,25,4891,
+ 1268,1961,258,26,1431,23,27,22,24,20,
+ 48,1998,103,72,73,105,1999,2039,2007,2129,
+ 2126,1762,2259,2219,1618,2319,1138,2296,2321,2333,
+ 140,284,2379,2388,75,861,2496,291,1862,970,
+ 292,370,141,888,28,816,25,4850,498,1332,
+ 1961,26,1431,23,27,55,24,2252,2386,324,
+ 1723,373,1607,1908,28,816,25,4891,2122,2451,
+ 258,26,1431,23,27,2481,24,20,48,1998,
+ 103,72,73,105,1999,2039,2007,2129,2126,2832,
+ 2259,2219,2496,2319,135,2296,2321,2333,140,257,
+ 379,412,323,254,256,255,2688,814,343,502,
+ 141,374,2274,234,222,223,221,2283,3391,2865,
+ 28,816,25,4891,503,1961,258,26,1431,23,
+ 27,22,24,20,48,1998,103,72,73,105,
+ 1999,2039,2007,2129,2126,324,2259,2219,1679,2319,
+ 3530,2296,2321,2333,140,584,38,816,36,1551,
+ 237,222,223,37,1431,370,141,1141,330,59,
+ 996,509,3642,444,1279,1609,279,816,431,2288,
+ 3056,28,816,25,4891,499,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,1681,2259,2219,358,
+ 2319,3704,2296,2321,2333,140,938,230,258,75,
+ 4553,907,2197,87,2603,2717,156,141,2082,1816,
+ 3017,28,816,25,4891,368,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,1267,2259,2219,1267,
+ 2319,1267,2296,2321,2686,162,2677,28,816,25,
+ 4891,838,1961,258,26,1431,23,27,22,24,
+ 20,48,1998,103,72,73,105,1999,2039,2007,
+ 2129,2126,1049,2259,2219,1049,2319,1049,2296,2321,
+ 2333,140,481,231,222,223,75,1685,1475,326,
+ 2693,2478,139,141,240,222,223,243,222,223,
+ 3056,28,816,25,4891,697,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,75,2259,2219,1278,
+ 2319,2561,2296,2321,2333,140,327,335,1699,334,
+ 335,329,335,1609,277,816,364,141,3056,28,
+ 816,25,4891,1336,1961,258,26,1431,23,27,
+ 22,24,20,48,1998,103,72,73,105,1999,
+ 2039,2007,2129,2126,416,2259,2219,214,2319,315,
+ 2296,2321,2333,140,1609,3048,816,330,2421,1970,
+ 1405,4678,276,1625,362,141,3130,28,816,25,
+ 4891,2269,1961,258,26,1431,23,27,22,24,
+ 20,48,1998,103,72,73,105,1999,2039,2007,
+ 2129,2126,1549,2259,2219,280,2319,1267,2296,2321,
+ 2686,162,3056,28,816,25,4891,1136,1961,258,
+ 26,1431,23,27,22,24,20,48,1998,103,
+ 72,73,105,1999,2039,2007,2129,2126,1620,2259,
+ 2219,1711,2319,1049,2296,2321,2333,140,410,1711,
+ 2082,2768,494,28,816,25,4976,1713,152,141,
+ 26,1431,23,27,56,24,3056,28,816,25,
+ 4891,163,1961,258,26,1431,23,27,22,24,
+ 20,48,1998,103,72,73,105,1999,2039,2007,
+ 2129,2126,1911,2259,2219,85,2319,99,2296,2321,
+ 2333,140,330,1815,1267,1734,4708,2739,335,1487,
+ 2283,367,151,141,3056,28,816,25,4891,2916,
+ 1961,258,26,1431,23,27,22,24,20,48,
+ 1998,103,72,73,105,1999,2039,2007,2129,2126,
+ 1049,2259,2219,3530,2319,75,2296,2321,2333,140,
+ 1046,849,2370,1734,75,380,412,1415,2283,4265,
+ 150,141,3056,28,816,25,4891,1418,1961,258,
+ 26,1431,23,27,22,24,20,48,1998,103,
+ 72,73,105,1999,2039,2007,2129,2126,75,2259,
+ 2219,3530,2319,783,2296,2321,2333,140,502,852,
+ 496,1480,357,1278,2848,335,406,407,149,141,
+ 3056,28,816,25,4891,2916,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,410,2259,2219,410,
+ 2319,75,2296,2321,2333,140,641,75,2041,1481,
+ 357,330,660,2780,2831,4779,148,141,3056,28,
+ 816,25,4891,322,1961,258,26,1431,23,27,
+ 22,24,20,48,1998,103,72,73,105,1999,
+ 2039,2007,2129,2126,1964,2259,2219,518,2319,75,
+ 2296,2321,2333,140,2605,75,2596,2324,275,816,
+ 2649,2780,2831,1699,147,141,3056,28,816,25,
+ 4891,2421,1961,258,26,1431,23,27,22,24,
+ 20,48,1998,103,72,73,105,1999,2039,2007,
+ 2129,2126,75,2259,2219,1542,2319,1466,2296,2321,
+ 2333,140,307,382,412,1711,381,412,2324,3117,
+ 816,1543,146,141,3056,28,816,25,4891,349,
+ 1961,258,26,1431,23,27,22,24,20,48,
+ 1998,103,72,73,105,1999,2039,2007,2129,2126,
+ 75,2259,2219,518,2319,1469,2296,2321,2333,140,
+ 1609,3143,816,75,75,1878,285,2379,709,1335,
+ 145,141,3056,28,816,25,4891,512,1961,258,
+ 26,1431,23,27,22,24,20,48,1998,103,
+ 72,73,105,1999,2039,2007,2129,2126,1725,2259,
+ 2219,1951,2319,1953,2296,2321,2333,140,84,75,
+ 99,75,1832,330,716,1337,785,4921,144,141,
+ 3056,28,816,25,4891,838,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,1725,2259,2219,1344,
+ 2319,393,2296,2321,2333,140,321,75,1699,1959,
+ 1699,330,1051,838,300,4961,143,141,3056,28,
+ 816,25,4891,838,1961,258,26,1431,23,27,
+ 22,24,20,48,1998,103,72,73,105,1999,
+ 2039,2007,2129,2126,369,2259,2219,306,2319,303,
+ 2296,2321,2333,140,351,75,1699,330,1699,1962,
+ 1383,4882,308,1699,142,141,3056,28,816,25,
+ 4891,135,1961,258,26,1431,23,27,22,24,
+ 20,48,1998,103,72,73,105,1999,2039,2007,
+ 2129,2126,1725,2259,2219,177,2319,193,2296,2321,
+ 2333,140,192,75,1794,75,1615,1014,3326,838,
+ 3162,2905,157,141,3056,28,816,25,4891,760,
+ 1961,258,26,1431,23,27,22,24,20,48,
+ 1998,103,72,73,105,1999,2039,2007,2129,2126,
+ 435,2259,2219,391,2319,1711,2296,2321,2333,140,
+ 443,75,1699,2121,1699,2123,1237,838,378,2270,
+ 137,141,3243,28,816,25,4891,838,1961,258,
+ 26,1431,23,27,22,24,20,48,1998,103,
+ 72,73,105,1999,2039,2007,2129,2126,4038,2259,
+ 2219,302,2319,196,2296,2321,2333,140,21,2124,
+ 1699,1549,1699,1012,3061,2125,278,511,187,141,
+ 3322,28,816,25,4891,510,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,1869,2259,2219,194,
+ 2319,3030,2296,2321,2686,162,3322,28,816,25,
+ 4891,1347,1961,258,26,1431,23,27,22,24,
+ 20,48,1998,103,72,73,105,1999,2039,2007,
+ 2129,2126,965,2259,2219,440,2319,1767,2296,2321,
+ 2686,162,580,28,816,25,4976,1699,1736,1616,
+ 26,1431,23,27,495,24,1482,737,1805,276,
+ 3322,28,816,25,4891,2729,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,395,2259,2219,154,
+ 2319,838,2296,2321,2686,162,3361,28,816,25,
+ 4891,289,1961,258,26,1431,23,27,22,24,
+ 20,48,1998,103,72,73,105,1999,2039,2007,
+ 2129,2126,1861,2259,2219,1153,2319,1194,2296,2321,
+ 2686,162,752,28,816,25,752,28,816,25,
+ 26,1431,35,27,26,1431,1997,27,2269,1725,
+ 3400,28,816,25,4891,408,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,938,2259,2219,668,
+ 2319,1911,2296,2321,2686,162,3322,28,816,25,
+ 4891,410,1961,258,26,1431,23,27,22,24,
+ 20,48,1998,103,72,73,105,1999,2039,2007,
+ 2129,2126,1725,2259,2219,282,2319,2086,2296,2982,
+ 3283,28,816,25,4891,1475,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,82,72,73,
+ 3322,28,816,25,4891,2630,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2129,2126,75,2259,2219,885,
+ 2319,609,2944,3322,28,816,25,4891,299,1961,
+ 258,26,1431,23,27,22,24,20,48,1998,
+ 103,72,73,105,1999,2039,2007,2129,2126,1725,
+ 2259,2219,1725,2941,3322,28,816,25,4891,910,
+ 1961,258,26,1431,23,27,22,24,20,48,
+ 1998,103,72,73,105,1999,2039,2007,2129,2126,
+ 3045,2259,2942,3439,377,816,376,4600,1340,228,
+ 258,3322,2695,816,2699,4891,1728,1961,258,26,
+ 1431,23,27,22,24,20,48,1998,103,72,
+ 73,80,270,322,1828,298,1803,2592,283,1733,
+ 29,1861,1699,232,235,238,2688,814,3322,28,
+ 816,25,4891,945,1961,258,26,1431,23,27,
+ 22,24,20,48,1998,103,72,73,105,1999,
+ 2039,2007,2129,2126,372,2926,1702,28,816,25,
+ 4850,3087,582,1717,26,1431,23,27,54,24,
+ 135,1740,273,272,271,226,222,223,328,2173,
+ 900,331,4740,2082,2592,2082,2194,1699,2196,3322,
+ 28,816,25,4891,241,1961,258,26,1431,23,
+ 27,22,24,20,48,1998,103,72,73,105,
+ 1999,2039,2007,2129,2938,1001,811,858,1012,1015,
+ 3785,3322,28,816,25,4891,3118,1961,258,26,
+ 1431,23,27,22,24,20,48,1998,103,72,
+ 73,105,1999,2039,2007,2129,2939,3980,3047,350,
+ 1193,1721,2283,3322,28,816,25,4891,1275,1961,
+ 258,26,1431,23,27,22,24,20,48,1998,
+ 103,72,73,105,1999,2039,2007,2899,4066,75,
+ 510,1199,58,2283,1334,220,1025,377,816,376,
+ 1409,135,75,135,4811,626,2198,2603,208,838,
+ 205,838,1950,198,206,207,209,970,91,64,
+ 199,200,617,2592,2603,29,220,210,201,202,
+ 203,204,294,295,296,297,626,4143,158,208,
+ 67,205,66,838,198,206,207,209,430,1397,
+ 1430,199,200,617,1835,3032,1338,838,210,201,
+ 202,203,204,294,295,296,297,1025,377,816,
+ 376,4121,75,1977,51,548,2283,970,970,431,
+ 4059,414,49,838,1699,4740,3125,330,83,1204,
+ 1011,2193,39,2363,1658,2027,436,135,2838,153,
+ 970,1622,674,377,816,376,838,1011,1819,220,
+ 1910,366,195,236,50,4198,311,2592,1829,626,
+ 2283,153,208,189,205,2199,553,198,206,207,
+ 209,46,160,310,199,200,617,2479,1836,1852,
+ 135,210,201,202,203,204,294,295,296,297,
+ 1148,291,47,220,292,1866,1184,415,1869,4220,
+ 1163,4080,1565,626,2283,2313,208,1840,205,3125,
+ 4143,198,206,207,209,838,94,1706,199,200,
+ 617,330,1873,838,2912,210,201,202,203,204,
+ 294,295,296,297,2322,1956,1614,220,896,1428,
+ 816,1200,4645,2200,548,1678,3362,626,431,1793,
+ 208,2718,205,3125,3425,198,206,207,209,95,
+ 838,2162,199,200,617,41,2363,46,2767,210,
+ 201,202,203,204,294,295,296,297,2908,2765,
+ 366,434,1397,1430,406,407,2171,291,47,75,
+ 292,3465,1184,1966,1349,4080,2195,3125,558,2313,
+ 3322,28,816,25,4891,2249,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2900,3322,28,816,25,4891,
+ 2075,1961,258,26,1431,23,27,22,24,20,
+ 48,1998,103,72,73,105,1999,2039,2007,2914,
+ 3322,28,816,25,4891,838,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 105,1999,2039,2007,2915,87,1025,377,816,376,
+ 522,2770,2780,937,2781,838,1575,2592,838,1413,
+ 377,816,376,892,377,816,376,2782,75,838,
+ 2783,153,3929,1445,838,416,2784,2603,253,258,
+ 499,1617,1766,220,178,1,1855,838,270,86,
+ 522,1737,270,1813,1418,408,208,1751,205,2592,
+ 1198,197,206,207,209,2574,838,167,257,838,
+ 1754,153,254,256,255,2688,814,344,65,1469,
+ 1538,4297,1766,220,178,181,165,166,168,169,
+ 170,171,172,1813,1757,1760,208,64,205,1397,
+ 63,197,206,207,209,1466,1715,167,340,272,
+ 271,179,3082,272,271,1733,1709,1675,943,946,
+ 3046,1870,1969,2875,1973,182,165,166,168,169,
+ 170,171,172,3322,28,816,25,4891,2766,1961,
+ 258,26,1431,23,27,22,24,20,48,1998,
+ 103,72,73,105,1999,2039,2919,3322,28,816,
+ 25,4891,2073,1961,258,26,1431,23,27,22,
+ 24,20,48,1998,103,72,73,105,1999,2039,
+ 2925,4037,2865,2072,2190,2248,2283,3322,28,816,
+ 25,4891,838,1961,258,26,1431,23,27,22,
+ 24,20,48,1998,103,72,73,105,1999,2860,
+ 2077,838,4011,427,428,970,1409,2283,838,220,
+ 4811,2271,2321,62,2906,2785,2786,666,2371,626,
+ 838,2592,208,838,205,838,153,198,206,207,
+ 209,2372,3568,4275,199,200,617,160,2283,53,
+ 220,505,201,202,203,204,294,295,296,297,
+ 626,52,2272,208,3631,205,98,2127,198,206,
+ 207,209,970,2671,4295,199,200,617,2789,2283,
+ 1205,220,211,201,202,203,204,294,295,296,
+ 297,626,2418,153,208,3047,205,2422,2202,198,
+ 206,207,209,970,160,4143,199,200,617,2387,
+ 2283,516,220,309,201,202,203,204,294,295,
+ 296,297,626,2471,153,208,2468,205,2521,5298,
+ 198,206,207,209,1829,160,4305,199,200,617,
+ 5298,2283,1607,220,506,201,202,203,204,294,
+ 295,296,297,626,5298,93,208,5298,205,5298,
+ 5298,198,206,207,209,5298,3031,5298,199,200,
+ 617,5298,5298,414,220,211,201,202,203,204,
+ 294,295,296,297,626,5298,5298,208,5298,205,
+ 5298,173,198,206,207,209,522,3053,5298,199,
+ 200,617,5298,5298,5298,2718,483,201,202,203,
+ 204,294,295,296,297,5298,3610,153,5298,1950,
+ 2592,2603,253,258,970,5298,5298,5298,1766,220,
+ 178,5298,5298,1413,377,816,376,5298,5298,1813,
+ 5298,1950,208,5298,205,158,970,197,206,207,
+ 209,509,257,167,5298,5298,254,256,255,2688,
+ 814,344,270,5298,1676,5298,5298,158,5298,2603,
+ 5298,2736,165,166,168,169,170,171,172,3322,
+ 28,816,25,4891,4297,1961,258,26,1431,23,
+ 27,22,24,20,48,1998,103,72,73,105,
+ 1999,2861,259,392,513,5298,2913,522,5298,2371,
+ 5298,2603,2277,5298,5298,2533,5298,970,514,1709,
+ 1675,5298,70,272,271,1950,5298,5298,153,5298,
+ 970,5298,5298,1025,377,816,376,2573,153,1766,
+ 220,178,345,1413,377,816,376,522,5298,2493,
+ 1813,158,2579,208,5298,205,5298,5298,197,206,
+ 207,209,417,5298,167,5298,5298,5298,153,2701,
+ 5298,3685,270,5298,5298,2592,5298,253,258,1766,
+ 220,178,174,165,166,168,169,170,171,172,
+ 1813,5298,5298,208,1011,205,5298,983,197,206,
+ 207,209,2283,1671,167,431,5298,257,2283,5298,
+ 522,254,256,255,2688,814,344,5298,403,5298,
+ 310,3038,185,165,166,168,169,170,171,172,
+ 5298,153,68,272,271,3530,5298,1148,5298,4297,
+ 5298,3530,1766,220,178,517,5298,1163,5298,5298,
+ 522,1814,5298,1813,1950,1950,208,5298,205,970,
+ 970,197,206,207,209,5298,5298,167,5298,5298,
+ 5298,153,1471,342,1709,1675,5298,2603,5298,5298,
+ 158,158,1766,220,178,3093,165,166,168,169,
+ 170,171,172,1813,489,5298,208,5298,205,976,
+ 489,197,206,207,209,253,258,167,603,5298,
+ 839,5298,5298,522,2592,2603,5298,486,488,5298,
+ 5298,5298,5298,486,488,188,165,166,168,169,
+ 170,171,172,5298,153,257,5298,5298,5298,254,
+ 256,255,2688,814,343,1766,220,178,689,5298,
+ 3050,3055,5298,522,4281,5298,1813,5298,5298,208,
+ 1281,205,1381,5298,197,206,207,209,2546,5298,
+ 167,2327,5298,5298,153,5298,970,2701,4297,5298,
+ 5298,5298,5298,5298,5298,1766,220,178,184,165,
+ 166,168,169,170,171,172,1813,153,1663,208,
+ 5298,205,5298,5298,197,206,207,209,2958,5298,
+ 167,775,347,1709,1675,2377,522,5298,5298,5298,
+ 970,5298,674,377,816,376,404,5298,191,165,
+ 166,168,169,170,171,172,5298,153,5298,5298,
+ 2427,153,5298,5298,5298,970,5298,5298,1766,220,
+ 178,46,2854,2477,5298,5298,5298,1661,970,1813,
+ 5298,5298,208,440,205,5298,153,197,206,207,
+ 209,291,47,167,292,5298,1184,2867,5298,153,
+ 5298,5298,2006,5298,5298,5298,5298,5298,5298,425,
+ 2886,190,165,166,168,169,170,171,172,3322,
+ 28,816,25,4891,5298,1961,258,26,1431,23,
+ 27,22,24,20,48,1998,103,72,73,105,
+ 2871,3322,28,816,25,4891,5298,1961,258,26,
+ 1431,23,27,22,24,20,48,1998,103,72,
+ 73,105,2877,3322,28,816,25,4891,5298,1961,
+ 258,26,1431,23,27,22,24,20,48,1998,
+ 103,72,73,105,2890,3461,377,816,376,4600,
+ 5298,229,258,3322,28,816,25,4891,5298,1961,
+ 258,26,1431,23,27,22,24,20,48,1998,
+ 103,72,73,81,270,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,233,236,239,2688,814,
+ 3322,28,816,25,4891,5298,1961,258,26,1431,
+ 23,27,22,24,20,48,1998,103,72,73,
+ 79,3322,28,816,25,4891,5298,1961,258,26,
+ 1431,23,27,22,24,20,48,1998,103,72,
+ 73,78,5298,5298,273,272,271,227,222,223,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,3322,28,816,25,4891,242,1961,258,26,
+ 1431,23,27,22,24,20,48,1998,103,72,
+ 73,77,3322,28,816,25,4891,5298,1961,258,
+ 26,1431,23,27,22,24,20,48,1998,103,
+ 72,73,76,3322,28,816,25,4891,5298,1961,
+ 258,26,1431,23,27,22,24,20,48,1998,
+ 103,72,73,75,3322,28,816,25,4891,5298,
+ 1961,258,26,1431,23,27,22,24,20,48,
+ 1998,103,72,73,74,3169,28,816,25,4891,
+ 5298,1961,258,26,1431,23,27,22,24,20,
+ 48,1998,103,72,73,101,3322,28,816,25,
+ 4891,5298,1961,258,26,1431,23,27,22,24,
+ 20,48,1998,103,72,73,107,3322,28,816,
+ 25,4891,5298,1961,258,26,1431,23,27,22,
+ 24,20,48,1998,103,72,73,106,3322,28,
+ 816,25,4891,5298,1961,258,26,1431,23,27,
+ 22,24,20,48,1998,103,72,73,104,3322,
+ 28,816,25,4891,5298,1961,258,26,1431,23,
+ 27,22,24,20,48,1998,103,72,73,102,
+ 150,28,816,25,4749,5298,5298,5298,26,1431,
+ 23,27,339,24,1214,5298,5298,5298,5298,970,
+ 253,258,5298,2527,5298,5298,5298,5298,970,5298,
+ 5298,5298,5298,5298,5298,5298,1283,5298,5298,5298,
+ 153,970,253,258,5298,5298,5298,5298,2577,153,
+ 257,1877,5298,970,254,256,255,2688,814,343,
+ 2889,5298,153,674,377,816,376,5298,5298,3391,
+ 5298,5298,257,2501,153,1867,254,256,255,2688,
+ 814,343,1352,5298,5298,3012,5298,970,253,258,
+ 5298,3391,46,5298,2627,5298,5298,2499,5298,970,
+ 5298,5298,5298,5298,1421,5298,5298,5298,153,970,
+ 253,258,291,47,5298,292,5298,43,257,1877,
+ 153,5298,254,256,255,2688,814,343,5298,1490,
+ 153,2587,5298,5298,970,253,258,3391,5298,5298,
+ 257,186,5298,2547,254,256,255,2688,814,343,
+ 5298,1559,5298,5298,5298,153,970,253,258,2852,
+ 5298,5298,5298,5298,5298,257,186,5298,5298,254,
+ 256,255,2688,814,343,5298,5298,153,5298,316,
+ 790,318,747,320,2852,1684,5298,257,186,4906,
+ 2283,254,256,255,2688,814,343,1413,377,816,
+ 376,3767,5298,5298,5298,2592,2852,253,258,5298,
+ 5298,5298,5298,5298,2665,5298,5298,870,5298,5298,
+ 5298,2592,3591,220,5298,5298,270,5298,253,258,
+ 3958,5298,5298,3284,4906,2283,396,257,5298,2673,
+ 5298,254,256,255,2688,814,344,5298,1672,397,
+ 617,5298,5298,517,5298,5298,5298,5298,257,5298,
+ 5298,2710,254,256,255,2688,814,343,220,2875,
+ 5298,5298,5298,3889,5298,5298,5298,3391,3284,253,
+ 258,396,5298,520,5298,4297,69,272,271,5298,
+ 5298,5298,5298,1672,397,617,5298,5298,5298,5298,
+ 3889,5298,2362,5298,5298,5298,253,258,5298,257,
+ 5298,5298,5298,254,256,255,2688,814,343,347,
+ 1709,1675,5298,5298,5298,5298,5298,5298,3391,5298,
+ 5298,5298,5298,5298,493,5298,257,398,399,5298,
+ 254,256,255,2688,814,343,5298,2362,5298,5298,
+ 3889,5298,5298,5298,5298,3391,253,258,5298,426,
+ 428,491,5298,5298,345,5298,5298,5298,5298,5298,
+ 1802,5298,5298,4310,5298,5298,5298,5298,5298,5298,
+ 5298,3889,398,400,5298,5298,257,253,258,5298,
+ 254,256,255,2688,814,343,5298,5298,5298,5298,
+ 5298,5298,5298,3889,5298,3391,5298,5298,5298,253,
+ 258,2834,5298,5298,3100,5298,5298,257,5298,5298,
+ 5298,254,256,255,2688,814,343,3889,5298,5298,
+ 5298,5298,5298,253,258,5298,3391,5298,5298,257,
+ 5298,5298,2847,254,256,255,2688,814,343,3828,
+ 5298,5298,5298,5298,5298,253,258,5298,3391,5298,
+ 5298,5298,5298,257,2850,5298,5298,254,256,255,
+ 2688,814,343,3847,5298,5298,5298,5298,5298,253,
+ 258,5298,3391,5298,5298,257,5298,5298,2856,254,
+ 256,255,2688,814,343,3889,5298,5298,5298,5298,
+ 5298,253,258,5298,3236,5298,5298,5298,5298,257,
+ 5298,5298,5298,254,256,255,2688,814,343,3786,
+ 672,377,816,376,2380,253,258,5298,4599,5298,
+ 5298,257,5298,5298,5298,254,256,255,2688,814,
+ 343,3889,5298,5298,5298,5298,5298,253,258,46,
+ 3391,5298,5298,5298,5298,257,2849,5298,5298,254,
+ 256,255,2688,814,344,1032,377,816,376,291,
+ 47,5298,292,5298,1184,5298,5298,257,5298,5298,
+ 1339,254,256,255,2688,814,343,621,5298,672,
+ 377,816,376,5298,46,5298,3391,5298,1473,377,
+ 816,376,521,5298,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,291,47,5298,292,46,1184,
+ 5298,5298,5298,5298,5298,44,5298,46,1032,377,
+ 816,376,1913,5298,5298,5298,5298,5298,291,47,
+ 2835,292,5298,1184,2216,5298,5298,291,47,44,
+ 292,5298,1184,5298,5298,5298,1232,46,44,5298,
+ 672,377,816,376,5298,578,5298,5298,5298,672,
+ 377,816,376,5298,5298,5298,5298,291,47,5298,
+ 292,5298,1184,5298,5298,5298,5298,5298,44,46,
+ 5298,5298,5298,90,5298,764,5298,5298,46,1611,
+ 377,816,376,5298,5298,5298,5298,5298,5298,291,
+ 47,5298,292,5298,1184,5298,5298,5298,291,47,
+ 44,292,5298,1184,5298,5298,5298,2557,46,949,
+ 5298,672,377,816,376,5298,2839,5298,5298,5298,
+ 1027,377,816,376,5298,5298,5298,5298,291,47,
+ 5298,292,5298,1184,5298,5298,5298,5298,5298,44,
+ 46,5298,5298,5298,5298,5298,778,5298,5298,46,
+ 1032,377,816,376,5298,5298,5298,5298,5298,5298,
+ 291,47,5298,292,5298,1184,5298,5298,5298,291,
+ 47,44,292,5298,1184,5298,5298,5298,2826,46,
+ 2314,5298,672,377,816,376,5298,621,5298,5298,
+ 5298,886,377,816,376,5298,5298,5298,5298,291,
+ 47,5298,292,5298,1184,5298,674,377,816,376,
+ 2316,46,5298,5298,5298,5298,5298,2843,5298,5298,
+ 46,674,377,816,376,5298,5298,5298,5298,5298,
+ 5298,291,47,5298,292,46,1184,5298,5298,5298,
+ 291,47,44,292,5298,1184,5298,5298,1088,3353,
+ 46,1211,5298,522,5298,291,47,5298,292,5298,
+ 1184,674,377,816,376,5298,2098,5298,5298,5298,
+ 291,47,5298,292,153,1184,674,377,816,376,
+ 5298,2008,5298,5298,5298,160,220,5298,5298,5298,
+ 46,5298,5298,5298,5298,5298,1813,5298,5298,5298,
+ 5298,2585,5298,5298,5298,46,5298,5298,5298,5298,
+ 291,47,5298,292,5298,1184,5298,5298,5298,5298,
+ 5298,1199,5298,5298,5298,291,47,5298,292,5298,
+ 1184,5298,5298,5298,5298,5298,1211,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,1912,5298,0,
+ 485,3001,0,1,221,0,825,34,0,1,
+ 5626,0,1,1375,0,1,5331,333,0,1,
+ 333,0,1,34,333,0,1247,34,0,1287,
+ 34,0,30,281,252,0,30,497,281,252,
+ 0,1247,45,0,30,293,0,1,527,0,
+ 1,1098,0,34,5735,0,1479,34,0,5331,
+ 333,0,34,333,0,5331,332,0,34,332,
+ 0,30,293,301,0,1,5331,0,1,353,
+ 2833,0,1,34,0,1624,317,0,438,1669,
+ 0,30,497,0,1479,33,0,1,5331,221,
+ 0,1,34,221,0,5328,32,0,40,5329,
+ 0,40,32,0,353,2833,0,1,221,2615,
+ 0,5307,221,0,5626,429,0,1375,429,0,
+ 442,884,0,441,1781,0,44,32,0,1,
+ 5567,0,1,5566,0,1,5565,0,1,5564,
+ 0,1,5563,0,1,5562,0,1,5561,0,
+ 1,5560,0,1,5559,0,1,5558,0,1,
+ 5557,0,2775,123,0,5307,394,0,1,5681,
+ 0,3239,253,0,22,504,0,293,301,0,
+ 154,173,0,2562,88,0,377,28,0,376,
+ 25,0,34,2486,0,5329,42,0,32,42,
+ 0,221,161,0,228,3239,0,2775,125,0,
+ 2775,124,0,1,89,0,13,409,0,5328,
+ 5,32,0,5795,31,0,183,3528,0,5626,
+ 92,0,1375,92,0,277,3345,0
+ };
+ };
+ public final static char baseAction[] = BaseAction.baseAction;
+ public final int baseAction(int index) { return baseAction[index]; }
+ public final static char lhs[] = baseAction;
+ public final int lhs(int index) { return lhs[index]; };
+
+ public interface TermCheck {
+ public final static byte termCheck[] = {0,
+ 0,1,2,3,4,5,6,7,8,9,
+ 10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,
+ 30,31,32,33,34,35,36,37,38,39,
+ 40,41,42,43,44,45,46,47,0,49,
+ 50,51,52,53,54,55,56,57,58,59,
+ 60,61,62,0,1,2,3,4,5,6,
+ 7,71,24,73,0,75,76,77,78,79,
+ 80,81,82,83,84,85,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,40,41,42,43,
+ 44,45,46,47,0,49,50,51,52,53,
+ 54,55,56,57,58,59,60,61,62,0,
+ 1,2,3,0,0,6,7,4,0,73,
+ 2,75,76,77,78,79,80,81,82,83,
+ 84,85,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,
+ 18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,
+ 38,39,40,41,42,43,44,45,46,47,
+ 0,49,50,51,52,53,54,55,56,57,
+ 58,59,60,61,62,0,1,0,3,4,
+ 5,0,89,90,24,73,112,75,76,77,
+ 78,79,80,81,82,83,84,85,0,1,
+ 2,3,4,5,6,7,8,9,10,11,
+ 12,13,14,15,16,17,18,19,20,21,
+ 22,23,24,25,26,27,28,29,30,31,
+ 32,33,34,35,36,37,38,39,40,41,
+ 42,43,44,45,46,47,65,49,50,51,
+ 52,53,54,55,56,57,58,59,60,61,
+ 62,0,1,0,3,4,5,0,1,0,
+ 3,73,3,75,76,77,78,79,80,81,
+ 82,83,84,85,0,1,2,3,4,5,
+ 6,7,8,9,10,11,12,13,14,15,
+ 16,17,18,19,20,21,22,23,24,25,
+ 26,27,28,29,30,31,32,33,34,35,
+ 36,37,38,39,40,41,42,43,44,45,
+ 46,47,69,49,50,51,52,53,54,55,
+ 56,57,58,59,60,61,62,0,1,0,
+ 3,4,5,0,1,0,3,73,3,75,
+ 76,77,78,79,80,81,82,83,84,85,
+ 0,1,2,3,4,5,6,7,8,9,
+ 10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,
+ 30,31,32,33,34,35,36,37,38,39,
+ 40,41,42,43,44,45,46,47,69,49,
+ 50,51,52,53,54,55,56,57,58,59,
+ 60,61,62,0,1,0,3,2,0,6,
+ 7,0,4,73,3,75,76,77,78,79,
+ 80,81,82,83,84,85,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,40,41,42,43,
+ 44,45,46,47,0,49,50,51,52,53,
+ 54,55,56,57,58,59,60,61,62,0,
+ 1,0,3,0,1,6,7,89,90,73,
+ 7,75,76,77,78,79,80,81,82,83,
+ 84,85,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,
+ 18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,
+ 38,39,40,41,42,43,44,45,46,47,
+ 69,49,50,51,52,53,54,55,56,57,
+ 58,59,60,61,62,0,1,0,3,4,
+ 5,0,1,0,1,73,0,75,76,77,
+ 78,79,80,81,82,83,84,85,0,1,
+ 2,3,4,5,6,7,8,9,10,11,
+ 12,13,14,15,16,17,18,19,20,21,
+ 22,23,24,25,26,27,28,29,30,31,
+ 32,33,34,35,36,37,38,39,40,41,
+ 42,43,44,45,46,47,0,49,50,51,
+ 52,53,54,55,56,57,58,59,60,61,
+ 62,0,1,86,87,19,20,6,7,0,
+ 0,73,0,75,76,77,78,79,80,81,
+ 82,83,84,85,0,1,2,3,4,5,
+ 6,7,8,9,10,11,12,13,14,15,
+ 16,17,18,19,20,21,22,23,24,25,
+ 26,27,28,29,30,31,32,33,34,35,
+ 36,37,38,39,40,41,42,43,44,45,
+ 46,47,0,49,50,51,52,53,54,55,
+ 56,57,58,59,60,61,62,0,0,1,
+ 2,3,4,5,6,7,24,73,0,75,
+ 76,77,78,79,80,81,82,83,84,85,
+ 0,1,2,3,4,5,6,7,0,0,
+ 1,2,3,4,5,116,117,118,0,19,
+ 20,119,22,23,0,0,1,0,1,5,
+ 3,0,1,6,7,0,1,6,3,0,
+ 40,63,3,4,5,45,0,0,2,0,
+ 50,74,52,65,66,55,56,57,58,59,
+ 60,61,62,63,64,65,66,42,43,69,
+ 70,71,63,73,74,48,0,0,2,3,
+ 4,5,0,48,0,0,86,87,88,89,
+ 90,91,92,93,94,95,96,97,98,99,
+ 100,101,102,103,104,105,106,107,108,109,
+ 110,111,112,113,114,0,70,2,71,4,
+ 5,6,0,8,9,10,11,12,13,14,
+ 15,16,17,18,19,20,0,22,23,63,
+ 25,64,65,21,95,96,64,65,0,64,
+ 65,0,1,0,70,2,41,42,43,44,
+ 0,46,47,41,0,1,0,1,91,92,
+ 48,0,1,91,92,0,91,92,63,64,
+ 65,66,67,68,100,70,102,103,104,105,
+ 106,107,108,109,110,111,48,113,0,48,
+ 64,86,87,88,89,90,91,92,42,43,
+ 95,96,97,98,99,100,101,102,103,104,
+ 105,106,107,108,109,110,111,0,1,2,
+ 3,4,5,6,7,8,9,10,11,12,
+ 13,14,15,16,17,18,19,20,21,22,
+ 23,24,25,26,27,28,29,30,31,32,
+ 33,34,35,36,37,38,39,40,41,42,
+ 43,44,45,46,47,0,49,0,3,52,
+ 0,1,55,56,57,58,59,60,61,62,
+ 0,1,2,3,4,5,6,7,8,9,
+ 10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,
+ 30,31,32,33,34,35,36,37,38,39,
+ 50,41,0,0,44,45,46,47,0,64,
+ 0,64,52,0,0,55,56,57,58,59,
+ 60,61,62,0,1,2,3,4,5,6,
+ 7,8,9,10,11,12,13,14,15,16,
+ 17,18,19,20,21,22,23,24,25,26,
+ 27,28,29,30,31,32,33,34,35,36,
+ 37,38,39,50,41,42,43,44,0,46,
+ 47,69,49,65,66,73,0,0,0,2,
+ 66,3,69,70,0,1,73,0,74,21,
+ 67,68,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,
+ 18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,
+ 38,39,48,41,42,43,44,50,46,47,
+ 63,49,64,67,68,0,0,0,2,0,
+ 0,0,1,0,3,2,0,70,2,67,
+ 68,0,1,2,3,4,5,6,7,8,
+ 9,10,11,12,13,14,15,16,17,18,
+ 19,20,21,22,23,24,25,26,27,28,
+ 29,30,31,32,33,34,35,36,37,38,
+ 39,50,41,42,43,44,0,46,47,63,
+ 49,66,65,66,0,66,63,3,0,1,
+ 71,3,0,1,0,19,20,0,67,68,
+ 0,1,2,3,4,5,6,7,8,9,
+ 10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,
+ 30,31,32,33,34,35,36,37,38,39,
+ 52,41,42,43,44,0,46,47,0,49,
+ 0,1,0,1,0,1,0,0,64,0,
+ 0,0,1,66,19,20,0,67,68,0,
+ 1,2,3,4,5,6,7,8,9,10,
+ 11,12,13,14,15,16,17,18,19,20,
+ 21,22,23,24,25,26,27,28,29,30,
+ 31,32,33,34,35,36,37,38,39,48,
+ 41,42,43,44,48,46,47,0,49,69,
+ 63,0,0,64,64,4,0,1,0,1,
+ 0,1,0,0,86,87,67,68,0,1,
+ 2,3,4,5,6,7,8,9,10,11,
+ 12,13,14,15,16,17,18,19,20,21,
+ 22,23,24,25,26,27,28,29,30,31,
+ 32,33,34,35,36,37,38,39,48,41,
+ 42,43,44,50,46,47,0,49,0,1,
+ 0,1,70,0,0,0,0,0,0,1,
+ 4,0,1,86,87,67,68,0,1,2,
+ 3,4,5,6,7,8,9,10,11,12,
+ 13,14,15,16,17,18,19,20,21,22,
+ 23,24,25,26,27,28,29,30,31,32,
+ 33,34,35,36,37,38,39,50,41,48,
+ 0,44,0,46,47,0,1,0,0,2,
+ 0,4,5,0,1,2,3,4,5,6,
+ 7,21,65,21,67,68,19,20,0,22,
+ 23,0,1,88,3,89,90,6,7,94,
+ 0,41,0,100,0,40,0,40,48,3,
+ 0,115,2,40,0,53,113,0,50,115,
+ 50,48,0,0,51,0,0,2,40,0,
+ 63,64,65,66,69,0,69,70,71,48,
+ 0,74,69,0,71,72,0,22,23,0,
+ 50,0,50,86,87,88,89,90,91,92,
+ 93,94,95,96,97,98,99,100,101,102,
+ 103,104,105,106,107,108,109,110,111,112,
+ 113,114,0,0,2,71,4,5,63,116,
+ 117,118,0,1,0,1,45,74,6,95,
+ 96,19,20,52,22,23,55,56,57,58,
+ 59,60,61,62,88,98,93,0,1,97,
+ 94,0,40,40,0,0,101,2,88,0,
+ 1,88,86,87,94,86,87,94,0,114,
+ 48,0,48,2,115,63,64,65,66,66,
+ 0,69,70,71,0,0,74,2,0,0,
+ 2,40,0,1,40,48,0,0,86,87,
+ 88,89,90,91,92,93,94,95,96,97,
+ 98,99,100,101,102,103,104,105,106,107,
+ 108,109,110,111,112,113,114,0,1,2,
+ 3,4,5,6,7,8,9,10,11,12,
+ 13,14,15,16,17,18,19,20,21,22,
+ 23,24,25,26,27,28,29,30,31,32,
+ 33,34,35,36,37,38,39,70,41,0,
+ 0,44,0,46,47,0,0,2,0,99,
+ 0,0,2,0,1,0,97,2,0,0,
+ 1,0,0,5,67,68,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,40,48,42,43,
+ 70,63,70,74,63,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,40,0,42,43,
+ 98,0,0,2,0,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,40,0,42,43,
+ 0,0,0,0,0,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,45,93,42,43,
+ 0,99,0,52,0,49,55,56,57,58,
+ 59,60,61,62,64,0,64,64,64,0,
+ 0,2,0,0,0,0,0,0,0,0,
+ 74,0,1,2,3,4,5,6,7,8,
+ 9,10,11,12,13,14,15,16,17,18,
+ 19,20,21,22,23,24,25,26,27,28,
+ 29,30,31,32,33,34,35,36,37,38,
+ 39,45,70,42,43,75,0,0,52,2,
+ 49,55,56,57,58,59,60,61,62,66,
+ 65,69,0,66,70,66,0,69,0,0,
+ 0,0,2,0,3,74,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,48,0,42,43,
+ 0,52,2,0,1,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,93,0,42,43,
+ 0,0,2,2,0,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,0,0,42,43,
+ 0,0,2,6,3,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,0,0,42,43,
+ 0,0,2,6,0,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,0,0,42,43,
+ 0,0,2,0,0,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,0,0,42,43,
+ 0,0,0,0,0,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,0,0,42,43,
+ 0,0,0,0,0,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,0,0,42,43,
+ 0,0,0,0,0,49,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,39,0,0,42,43,
+ 0,1,2,3,4,5,6,7,8,9,
+ 10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,
+ 30,31,32,33,34,35,36,37,38,39,
+ 0,45,0,0,0,0,0,0,52,0,
+ 50,55,56,57,58,59,60,61,62,0,
+ 0,0,0,0,0,0,69,0,0,0,
+ 120,71,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,
+ 18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,
+ 38,39,66,69,69,66,0,70,0,0,
+ 0,0,50,0,65,65,65,65,65,0,
+ 63,63,0,64,70,70,0,0,0,0,
+ 0,0,0,71,0,1,2,3,4,5,
+ 6,7,8,9,10,11,12,13,14,15,
+ 16,17,18,19,20,21,22,23,24,25,
+ 26,27,28,29,30,31,32,33,34,35,
+ 36,37,38,39,0,0,2,0,4,5,
+ 6,0,0,0,50,0,0,0,69,0,
+ 0,0,0,19,20,0,22,23,0,25,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,40,42,43,41,0,
+ 0,40,40,0,39,0,0,0,0,0,
+ 0,0,0,0,0,0,0,63,64,65,
+ 66,66,0,0,70,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 86,87,88,89,90,91,92,0,0,95,
+ 96,97,98,99,100,101,102,103,104,105,
+ 106,107,108,109,110,111,0,1,2,3,
+ 4,5,6,7,8,9,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,
+ 24,25,26,27,28,29,30,31,32,33,
+ 34,35,36,37,38,0,1,2,3,4,
+ 5,6,7,8,9,10,11,12,13,14,
+ 15,16,17,18,19,20,21,22,23,24,
+ 25,26,27,28,29,30,31,32,33,34,
+ 35,36,37,38,39,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,112,0,
+ 1,2,3,4,5,6,7,8,9,10,
+ 11,12,13,14,15,16,17,18,19,20,
+ 21,22,23,24,25,26,27,28,29,30,
+ 31,32,33,34,35,36,37,38,0,1,
+ 2,3,4,5,6,7,8,9,10,11,
+ 12,13,14,15,16,17,18,19,20,21,
+ 22,23,24,25,26,27,28,29,30,31,
+ 32,33,34,35,36,37,38,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,63,0,0,0,0,0,0,0,0,
+ 0,112,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,
+ 18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,
+ 38,39,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,
+ 18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,
+ 38,0,1,2,3,4,5,6,7,8,
+ 9,10,11,12,13,14,15,16,17,18,
+ 19,20,21,22,23,24,25,26,27,28,
+ 29,30,31,32,33,34,35,36,37,38,
+ 0,1,2,3,4,5,6,7,8,9,
+ 10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,
+ 30,31,32,33,34,35,36,37,38,0,
+ 1,2,3,4,5,6,7,8,9,10,
+ 11,12,13,14,15,16,17,18,19,20,
+ 21,22,23,24,25,26,27,28,29,30,
+ 31,32,33,34,35,36,37,38,0,1,
+ 0,3,0,0,0,0,8,9,10,11,
+ 12,13,14,15,16,17,18,0,0,21,
+ 0,1,0,3,0,0,0,0,8,9,
+ 10,11,12,13,14,15,16,17,18,41,
+ 0,21,44,45,46,47,0,0,0,0,
+ 52,0,0,55,56,57,58,59,60,61,
+ 62,41,0,0,44,45,46,47,0,0,
+ 0,0,52,0,0,55,56,57,58,59,
+ 60,61,62,0,1,2,3,4,5,6,
+ 7,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,40,0,0,0,0,45,0,
+ 0,0,0,0,0,52,0,0,55,56,
+ 57,58,59,60,61,62,63,0,65,66,
+ 0,0,69,70,0,0,0,74,8,9,
+ 10,11,12,13,14,15,16,17,18,0,
+ 1,2,3,4,5,0,93,8,9,10,
+ 11,12,13,14,15,16,17,18,0,0,
+ 0,41,0,0,44,0,46,47,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 41,0,0,44,0,46,47,67,68,0,
+ 0,0,0,0,74,0,0,0,0,0,
+ 0,0,63,0,0,0,67,68,0,0,
+ 0,0,0,74,0,1,2,3,4,5,
+ 0,0,8,9,10,11,12,13,14,15,
+ 16,17,18,0,0,0,0,0,0,0,
+ 0,8,9,10,11,12,13,14,15,16,
+ 17,18,0,0,0,41,0,0,44,0,
+ 46,47,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,63,45,0,
+ 0,67,68,0,0,52,0,0,55,56,
+ 57,58,59,60,61,62,0,1,0,3,
+ 4,5,0,0,8,9,10,11,12,13,
+ 14,15,16,17,18,0,1,0,3,4,
+ 5,0,0,8,9,10,11,12,13,14,
+ 15,16,17,18,0,0,0,41,0,0,
+ 44,0,46,47,0,0,0,0,0,0,
+ 0,0,0,0,0,0,41,0,0,44,
+ 0,46,47,67,68,8,9,10,11,12,
+ 13,14,15,16,17,18,0,0,2,0,
+ 0,0,67,68,8,9,10,11,12,13,
+ 14,15,16,17,18,0,0,0,41,0,
+ 0,44,0,46,47,0,0,0,0,0,
+ 0,0,0,0,0,0,0,41,0,0,
+ 44,0,46,47,67,68,8,9,10,11,
+ 12,13,14,15,16,17,18,0,0,0,
+ 0,0,0,67,68,0,0,0,0,0,
+ 93,0,0,0,0,0,0,0,0,41,
+ 0,0,44,0,46,47,8,9,10,11,
+ 12,13,14,15,16,17,18,0,0,0,
+ 0,0,0,0,0,67,68,0,1,2,
+ 3,4,5,6,7,0,0,0,0,41,
+ 0,0,44,0,46,47,0,0,0,0,
+ 1,2,3,4,5,6,7,0,0,0,
+ 0,0,0,0,0,67,68,40,0,0,
+ 0,0,0,0,0,48,0,0,51,0,
+ 0,1,2,3,4,5,6,7,0,40,
+ 0,0,0,0,45,0,69,48,71,72,
+ 51,0,53,54,0,0,0,1,2,3,
+ 4,5,6,7,0,0,0,0,0,0,
+ 40,72,0,0,0,45,0,0,48,0,
+ 0,51,0,53,54,0,1,2,3,4,
+ 5,6,7,116,117,118,40,0,0,0,
+ 0,45,72,0,48,0,0,51,0,53,
+ 54,0,0,0,0,0,0,0,119,0,
+ 64,0,0,0,0,40,0,0,72,0,
+ 45,0,0,48,0,0,51,0,53,54,
+ 0,1,2,3,4,5,6,7,0,119,
+ 0,0,0,0,0,0,71,72,0,0,
+ 0,0,0,1,2,3,4,5,6,7,
+ 0,0,0,0,0,0,0,0,0,0,
+ 40,0,0,0,0,45,0,0,48,0,
+ 0,51,0,53,54,0,0,0,0,0,
+ 0,0,40,0,0,0,0,45,0,0,
+ 48,71,72,51,0,53,54,0,1,2,
+ 3,4,5,6,7,0,0,0,0,0,
+ 0,0,0,71,72,0,0,0,0,0,
+ 1,2,3,4,5,6,7,0,0,0,
+ 0,0,0,0,0,0,0,40,0,0,
+ 0,0,45,0,0,48,0,0,51,0,
+ 53,54,0,0,0,0,0,0,0,40,
+ 0,0,0,0,45,0,0,48,71,72,
+ 51,0,53,54,0,1,2,3,4,5,
+ 6,7,0,0,0,0,0,0,0,0,
+ 71,72,0,0,0,1,2,3,4,5,
+ 6,7,0,0,0,1,2,3,4,5,
+ 6,7,0,0,40,0,0,0,0,45,
+ 0,0,48,0,0,51,0,53,54,0,
+ 0,0,0,0,40,0,0,0,0,45,
+ 0,0,48,0,40,51,72,53,54,45,
+ 0,0,48,0,0,51,0,53,54,0,
+ 0,0,0,0,0,0,72,0,0,0,
+ 0,0,0,0,0,0,72,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0
+ };
+ };
+ public final static byte termCheck[] = TermCheck.termCheck;
+ public final int termCheck(int index) { return termCheck[index]; }
+
+ public interface TermAction {
+ public final static char termAction[] = {0,
+ 5298,5167,5053,5053,5053,5053,5053,5053,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 5171,1,1,1,1,1,1,1,5298,2674,
+ 599,602,1,2672,640,1,1,1,1,1,
+ 1,1,1,313,5072,5069,5065,5062,5059,5069,
+ 5069,5306,708,1271,1,2648,1773,1920,1768,2581,
+ 3211,2645,2657,2629,2563,2628,5298,5167,5053,5053,
+ 5053,5053,5053,5053,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5171,1,1,1,
+ 1,1,1,1,5298,2674,599,602,1,2672,
+ 640,1,1,1,1,1,1,1,1,5298,
+ 5106,1009,945,112,5298,2486,3519,3763,5298,1271,
+ 906,2648,1773,1920,1768,2581,3211,2645,2657,2629,
+ 2563,2628,5298,5167,5053,5053,5053,5053,5053,5053,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,5171,1,1,1,1,1,1,1,
+ 5298,2674,599,602,1,2672,640,1,1,1,
+ 1,1,1,1,1,333,5112,5298,5109,1375,
+ 5626,5298,3741,3719,618,1271,5304,2648,1773,1920,
+ 1768,2581,3211,2645,2657,2629,2563,2628,5298,5167,
+ 5053,5053,5053,5053,5053,5053,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,5171,1,
+ 1,1,1,1,1,1,3094,2674,599,602,
+ 1,2672,640,1,1,1,1,1,1,1,
+ 1,332,5118,432,5115,1375,5626,5298,5103,34,
+ 5331,1271,5331,2648,1773,1920,1768,2581,3211,2645,
+ 2657,2629,2563,2628,5298,5167,5053,5053,5053,5053,
+ 5053,5053,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,5171,1,1,1,1,1,
+ 1,1,2378,2674,599,602,1,2672,640,1,
+ 1,1,1,1,1,1,1,429,34,413,
+ 5331,5177,5174,5298,5103,5298,5331,1271,2458,2648,
+ 1773,1920,1768,2581,3211,2645,2657,2629,2563,2628,
+ 5298,5167,5053,5053,5053,5053,5053,5053,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 5171,1,1,1,1,1,1,1,3036,2674,
+ 599,602,1,2672,640,1,1,1,1,1,
+ 1,1,1,5298,5106,5298,945,2502,114,2486,
+ 3519,1,3763,1271,377,2648,1773,1920,1768,2581,
+ 3211,2645,2657,2629,2563,2628,5298,5167,5053,5053,
+ 5053,5053,5053,5053,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5171,1,1,1,
+ 1,1,1,1,5298,2674,599,602,1,2672,
+ 640,1,1,1,1,1,1,1,1,5298,
+ 5106,5298,945,33,5144,2486,3519,3741,3719,1271,
+ 1821,2648,1773,1920,1768,2581,3211,2645,2657,2629,
+ 2563,2628,5298,5167,5053,5053,5053,5053,5053,5053,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,5171,1,1,1,1,1,1,1,
+ 5688,2674,599,602,1,2672,640,1,1,1,
+ 1,1,1,1,1,92,34,118,5331,5292,
+ 5289,5298,5091,5298,1247,1271,5298,2648,1773,1920,
+ 1768,2581,3211,2645,2657,2629,2563,2628,5298,5167,
+ 5053,5053,5053,5053,5053,5053,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,5171,1,
+ 1,1,1,1,1,1,115,2674,599,602,
+ 1,2672,640,1,1,1,1,1,1,1,
+ 1,5298,1479,2953,2977,3299,3007,2486,3519,5298,
+ 5298,1271,5298,2648,1773,1920,1768,2581,3211,2645,
+ 2657,2629,2563,2628,5298,5167,5053,5053,5053,5053,
+ 5053,5053,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,5171,1,1,1,1,1,
+ 1,1,1,2674,599,602,1,2672,640,1,
+ 1,1,1,1,1,1,1,5298,348,5132,
+ 5128,5125,5062,5059,1,1,567,1271,5298,2648,
+ 1773,1920,1768,2581,3211,2645,2657,2629,2563,2628,
+ 5298,5082,5082,5082,5082,5082,5082,5082,5298,348,
+ 34,5164,5331,1375,5626,5718,5719,5720,5298,5082,
+ 5082,5049,5082,5082,128,5298,1247,5298,5106,2328,
+ 945,5298,825,5252,3519,386,5076,3253,5331,34,
+ 5082,353,5331,1375,5626,5082,314,1,824,126,
+ 5082,5305,5082,3156,648,5082,5082,5082,5082,5082,
+ 5082,5082,5082,5082,5086,5082,5082,3975,840,5082,
+ 5082,5082,353,5082,5082,634,34,123,5164,5331,
+ 1375,5626,125,34,136,124,5082,5082,5082,5082,
+ 5082,5082,5082,5082,5082,5082,5082,5082,5082,5082,
+ 5082,5082,5082,5082,5082,5082,5082,5082,5082,5082,
+ 5082,5082,5082,5082,5082,5298,909,1061,5306,5745,
+ 5749,5751,1,5559,5557,5566,5565,5561,5562,5560,
+ 5563,5564,5567,5558,5743,5744,5298,5774,5775,353,
+ 5752,2800,5222,5097,2421,2389,2800,5267,5298,2800,
+ 5270,5298,5155,5298,1728,4116,5685,1719,1769,625,
+ 5298,5686,5687,5100,5298,1479,5298,5091,2750,2453,
+ 1387,45,5091,2750,2453,5298,2750,2453,691,5754,
+ 5755,5776,5635,5636,2136,5753,1680,1632,1584,1536,
+ 1488,1440,1392,1344,1296,1242,755,3591,5298,5329,
+ 3417,5765,5764,5777,5746,5747,5770,5771,3975,840,
+ 5768,5769,5748,5750,5772,5773,5778,5758,5759,5760,
+ 5756,5757,5766,5767,5762,5761,5763,5298,5053,5053,
+ 5053,5053,5053,5053,5053,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,5261,1,1,
+ 1,1,1,1,1,30,5452,5298,5121,1,
+ 5298,1139,1,1,1,1,1,1,1,1,
+ 34,5056,4094,945,3891,3912,2291,3519,5559,5557,
+ 5566,5565,5561,5562,5560,5563,5564,5567,5558,3851,
+ 3830,1721,3954,3933,5314,3793,1863,1915,5316,1865,
+ 2170,1909,5317,5315,1817,5310,5312,5313,5311,1056,
+ 1096,5685,432,5298,625,5545,5686,5687,22,497,
+ 5298,1477,5548,405,5298,5542,5549,5522,5547,5546,
+ 5543,5544,5523,5298,1,1,1,1,1,1,
+ 1,5213,5219,5192,5195,5207,5204,5210,5201,5198,
+ 5189,5216,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,432,5685,1,1,625,305,5686,
+ 5687,2378,5452,5234,5234,849,336,317,45,5135,
+ 4621,1247,2378,2046,40,5161,849,5298,5305,5602,
+ 5635,5636,5298,1,1,1,1,1,1,1,
+ 5213,5219,5192,5195,5207,5204,5210,5201,5198,5189,
+ 5216,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,5158,5685,1,1,625,5094,5686,5687,
+ 1020,5452,1247,5635,5636,312,5298,5298,1765,5298,
+ 5298,5298,5079,346,5331,352,5298,1481,3239,5635,
+ 5636,5298,1,1,1,1,1,1,1,5213,
+ 5219,5192,5195,5207,5204,5210,5201,5198,5189,5216,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1471,5685,1,1,625,117,5686,5687,1206,
+ 5452,2492,2728,648,385,573,352,376,419,34,
+ 5306,5331,5298,825,5298,3299,3007,433,5635,5636,
+ 5298,1,1,1,1,1,1,1,5213,5219,
+ 5192,5195,5207,5204,5210,5201,5198,5189,5216,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 5716,5685,1,1,625,116,5686,5687,122,5452,
+ 1,8669,5298,7088,384,5681,5298,319,3423,438,
+ 30,5298,9343,2571,3299,3007,44,5635,5636,5298,
+ 1,1,1,1,1,1,1,5213,5219,5192,
+ 5195,5207,5204,5210,5201,5198,5189,5216,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,5329,
+ 5685,1,1,625,570,5686,5687,121,5452,384,
+ 1020,5298,492,5138,5141,1717,287,5588,5298,5328,
+ 32,5186,5298,1,2953,2977,5635,5636,5298,1,
+ 1,1,1,1,1,1,5213,5219,5192,5195,
+ 5207,5204,5210,5201,5198,5189,5216,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,5329,5685,
+ 1,1,625,1136,5686,5687,5298,5452,5298,5795,
+ 5298,7088,4353,136,508,108,113,5298,5298,2544,
+ 3763,42,5258,2953,2977,5635,5636,34,5106,4094,
+ 945,3891,3912,2291,3519,5559,5557,5566,5565,5561,
+ 5562,5560,5563,5564,5567,5558,3851,3830,1673,3954,
+ 3933,5314,3793,1863,1915,5316,1865,2170,1909,5317,
+ 5315,1817,5310,5312,5313,5311,1056,1384,5685,5255,
+ 1,625,305,5686,5687,1,5228,377,5298,5246,
+ 5298,5246,5246,1,5151,221,5147,221,221,221,
+ 221,5097,501,5602,5635,5636,5246,5246,5298,5246,
+ 5246,5298,5106,3996,945,3741,3719,5252,3519,4017,
+ 5298,5100,5298,2136,127,5307,5298,5246,1387,2591,
+ 253,2685,5231,221,5298,1197,3591,132,1519,2685,
+ 1525,485,130,1,699,71,111,3261,5307,507,
+ 5246,5246,5246,5246,384,5298,5246,5246,5246,1282,
+ 110,5246,221,109,402,5782,120,5358,5359,119,
+ 599,216,1623,5246,5246,5246,5246,5246,5246,5246,
+ 5246,5246,5246,5246,5246,5246,5246,5246,5246,5246,
+ 5246,5246,5246,5246,5246,5246,5246,5246,5246,5246,
+ 5246,5246,376,5298,5249,5306,5249,5249,3332,5718,
+ 5719,5720,32,5186,5298,8609,5545,360,5186,2421,
+ 2389,5249,5249,5548,5249,5249,5542,5549,5522,5547,
+ 5546,5543,5544,5523,3996,2223,360,32,5186,2254,
+ 4017,394,5249,5307,5298,5298,833,4184,3996,5298,
+ 1864,3996,2953,2977,4017,2953,2977,4017,5298,2356,
+ 1578,5298,5329,4209,2685,5249,5249,5249,5249,3492,
+ 134,5249,5249,5249,5298,5298,5249,4948,5298,131,
+ 4231,5225,5298,2746,5237,1527,5298,490,5249,5249,
+ 5249,5249,5249,5249,5249,5249,5249,5249,5249,5249,
+ 5249,5249,5249,5249,5249,5249,5249,5249,5249,5249,
+ 5249,5249,5249,5249,5249,5249,5249,34,5106,4094,
+ 945,3891,3912,2291,3519,5559,5557,5566,5565,5561,
+ 5562,5560,5563,5564,5567,5558,3851,3830,1673,3954,
+ 3933,5314,3793,1863,1915,5316,1865,2170,1909,5317,
+ 5315,1817,5310,5312,5313,5311,1056,4380,5685,1,
+ 363,625,361,5686,5687,5298,5298,4529,442,2190,
+ 88,441,5243,5298,5588,228,2254,5264,129,5298,
+ 5279,5298,133,2328,5635,5636,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5307,5329,1,1,
+ 1110,5180,1158,159,5183,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,161,5298,1,1,
+ 2223,5298,135,3635,355,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,161,5298,1,1,
+ 5298,217,5298,5298,5298,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5545,5652,1,1,
+ 5298,2190,288,5548,5298,5452,5542,5549,5522,5547,
+ 5546,5543,5544,5523,4430,5298,4461,4483,4507,5298,
+ 5298,3660,5298,286,5298,5298,218,500,5298,155,
+ 161,5298,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,5545,1956,1,1,3003,5298,5298,5548,3673,
+ 5452,5542,5549,5522,5547,5546,5543,5544,5523,1514,
+ 5794,5474,5298,853,1481,1776,5298,3322,32,419,
+ 5298,5298,4103,1,3112,161,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5329,5298,1,1,
+ 5298,5716,4128,31,5283,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5654,5298,1,1,
+ 5298,5298,3345,3474,5298,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5298,5298,1,1,
+ 100,5298,3475,3363,3146,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5298,5298,1,1,
+ 277,5298,5295,4277,5298,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5298,5298,1,1,
+ 5298,5298,4302,5298,5298,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5298,5298,1,1,
+ 5298,5298,5298,5298,5298,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5298,5298,1,1,
+ 5298,5298,5298,5298,5298,5452,5298,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,5298,5298,1,1,
+ 183,5298,5298,5298,5298,5452,138,5106,4094,945,
+ 3891,3912,2291,3519,5559,5557,5566,5565,5561,5562,
+ 5560,5563,5564,5567,5558,3851,3830,1673,3954,3933,
+ 5314,3793,1863,1915,5316,1865,2170,1909,5317,5315,
+ 1817,5310,5312,5313,5311,1056,219,5298,34,34,
+ 34,5106,4094,945,3891,3912,2291,3519,5559,5557,
+ 5566,5565,5561,5562,5560,5563,5564,5567,5558,3851,
+ 3830,1673,3954,3933,5314,3793,1863,1915,5316,1865,
+ 2170,1909,5317,5315,1817,5310,5312,5313,5311,1056,
+ 5298,5545,5298,5298,5298,5298,411,405,5548,359,
+ 1671,5542,5549,5522,5547,5546,5543,5544,5523,5298,
+ 5298,5298,5298,5298,494,5298,2010,97,96,5,
+ 5286,5306,34,5106,4094,945,3891,3912,2291,3519,
+ 5559,5557,5566,5565,5561,5562,5560,5563,5564,5567,
+ 5558,3851,3830,1673,3954,3933,5314,3793,1863,1915,
+ 5316,1865,2170,1909,5317,5315,1817,5310,5312,5313,
+ 5311,1056,2490,5473,1824,902,5298,2046,5298,5298,
+ 5298,5298,1671,5298,5737,3004,3005,3041,3042,1,
+ 4174,2100,5298,32,1992,1872,5298,5298,5298,5298,
+ 5298,5298,5298,5306,34,5106,4094,945,3891,3912,
+ 2291,3519,5559,5557,5566,5565,5561,5562,5560,5563,
+ 5564,5567,5558,3851,3830,1673,3954,3933,5314,3793,
+ 1863,1915,5316,1865,2170,1909,5317,5315,1817,5310,
+ 5312,5313,5311,1056,5298,13,1061,5298,5745,5749,
+ 5751,173,1,5298,1671,519,5298,5298,5681,5298,
+ 5298,5298,5298,5743,5744,5298,5774,5775,5298,5752,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5276,1719,1769,2175,5298,
+ 5298,5240,313,5298,3148,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,691,5754,5755,
+ 5776,5276,5298,5298,5753,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5765,5764,5777,5746,5747,5770,5771,5298,5298,5768,
+ 5769,5748,5750,5772,5773,5778,5758,5759,5760,5756,
+ 5757,5766,5767,5762,5761,5763,34,5106,4094,945,
+ 3891,3912,2291,3519,5559,5557,5566,5565,5561,5562,
+ 5560,5563,5564,5567,5558,3851,3830,1673,3954,3933,
+ 5314,3793,1863,1915,5316,1865,2170,1909,5317,5315,
+ 1817,5310,5312,5313,5311,34,5106,4094,945,3891,
+ 3912,2291,3519,5559,5557,5566,5565,5561,5562,5560,
+ 5563,5564,5567,5558,3851,3830,1673,3954,3933,5314,
+ 3793,1863,1915,5316,1865,2170,1909,5317,5315,1817,
+ 5310,5312,5313,5311,1056,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5304,34,
+ 5106,4094,945,3891,3912,2291,3519,5559,5557,5566,
+ 5565,5561,5562,5560,5563,5564,5567,5558,3851,3830,
+ 1673,3954,3933,5314,3793,1863,1915,5316,1865,2170,
+ 1909,5317,5315,1817,5310,5312,5313,5311,34,5106,
+ 4094,945,3891,3912,2291,3519,5559,5557,5566,5565,
+ 5561,5562,5560,5563,5564,5567,5558,3851,3830,1673,
+ 3954,3933,5314,3793,1863,1915,5316,1865,2170,1909,
+ 5317,5315,1817,5310,5312,5313,5311,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,2491,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,164,34,5106,4094,945,3891,3912,2291,3519,
+ 5559,5557,5566,5565,5561,5562,5560,5563,5564,5567,
+ 5558,3851,3830,1673,3954,3933,5314,3793,1863,1915,
+ 5316,1865,2170,1909,5317,5315,1817,5310,5312,5313,
+ 5311,1056,34,5106,4162,945,3891,3912,2291,3519,
+ 5559,5557,5566,5565,5561,5562,5560,5563,5564,5567,
+ 5558,3851,3830,1673,3954,3933,5314,3793,1863,1915,
+ 5316,1865,2170,1909,5317,5315,1817,5310,5312,5313,
+ 5311,34,5106,4094,945,3891,3912,2291,3519,5559,
+ 5557,5566,5565,5561,5562,5560,5563,5564,5567,5558,
+ 3851,3830,1673,3954,3933,5314,3793,1863,1915,5316,
+ 1865,2170,1909,5317,5315,1817,5310,5312,5313,5311,
+ 34,5106,4094,945,3891,3912,2291,3519,5559,5557,
+ 5566,5565,5561,5562,5560,5563,5564,5567,5558,3851,
+ 3830,1673,3954,3933,5314,3793,1863,1915,5316,1865,
+ 2170,1909,5317,5315,1817,5310,5312,5313,3044,34,
+ 5106,4094,945,3891,3912,2291,3519,5559,5557,5566,
+ 5565,5561,5562,5560,5563,5564,5567,5558,3851,3830,
+ 1673,3954,3933,5314,3793,1863,1915,5316,1865,2170,
+ 1909,5317,5315,1817,5310,5312,5313,5311,5298,5056,
+ 5298,5331,5298,5298,5298,5298,5559,5557,5566,5565,
+ 5561,5562,5560,5563,5564,5567,5558,5298,5298,958,
+ 5298,5056,5298,5331,5298,5298,5298,5298,5559,5557,
+ 5566,5565,5561,5562,5560,5563,5564,5567,5558,5685,
+ 5298,958,625,5545,5686,5687,5298,5298,5298,5298,
+ 5548,5298,5298,5542,5549,5522,5547,5546,5543,5544,
+ 5523,5685,5298,5298,625,5545,5686,5687,5298,5298,
+ 5298,5298,5548,5298,5298,5542,5549,5522,5547,5546,
+ 5543,5544,5523,32,5328,5328,5328,5328,5328,5328,
+ 5328,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5328,5298,5298,5298,5298,5328,5298,
+ 5298,5298,5298,5298,5298,5328,5298,5298,5328,5328,
+ 5328,5328,5328,5328,5328,5328,5328,5298,5328,5328,
+ 5298,5298,5328,5328,5298,5298,5298,5328,5559,5557,
+ 5566,5565,5561,5562,5560,5563,5564,5567,5558,1,
+ 5132,5128,5125,5062,5059,5298,5328,5559,5557,5566,
+ 5565,5561,5562,5560,5563,5564,5567,5558,5298,5298,
+ 5298,5685,5298,5298,625,5298,5686,5687,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5685,5298,5298,625,5298,5686,5687,5635,5636,5298,
+ 5298,5298,5298,5298,5305,5298,5298,5298,5298,5298,
+ 5298,5298,353,5298,5298,5298,5635,5636,5298,5298,
+ 5298,5298,5298,515,341,34,5164,5331,1375,5626,
+ 5298,5298,5559,5557,5566,5565,5561,5562,5560,5563,
+ 5564,5567,5558,215,5298,5298,5298,5298,5298,5298,
+ 5298,5559,5557,5566,5565,5561,5562,5560,5563,5564,
+ 5567,5558,5298,5298,5298,5685,5298,5298,625,5298,
+ 5686,5687,5298,5298,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,353,5545,5298,
+ 5298,5635,5636,5298,5298,5548,5298,5298,5542,5549,
+ 5522,5547,5546,5543,5544,5523,429,34,5298,5331,
+ 5177,5174,5298,5298,5559,5557,5566,5565,5561,5562,
+ 5560,5563,5564,5567,5558,89,1,5298,1,5273,
+ 5273,5298,5298,5559,5557,5566,5565,5561,5562,5560,
+ 5563,5564,5567,5558,5298,5298,5298,5685,5298,5298,
+ 625,5298,5686,5687,5298,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5685,5298,5298,625,
+ 5298,5686,5687,5635,5636,5559,5557,5566,5565,5561,
+ 5562,5560,5563,5564,5567,5558,5298,5298,4575,5298,
+ 5298,5298,5635,5636,5559,5557,5566,5565,5561,5562,
+ 5560,5563,5564,5567,5558,5298,5298,5298,5685,5298,
+ 5298,625,5298,5686,5687,5298,5298,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,5685,5298,5298,
+ 625,5298,5686,5687,5635,5636,5559,5557,5566,5565,
+ 5561,5562,5560,5563,5564,5567,5558,5298,5298,5298,
+ 5298,5298,5298,5635,5636,5298,5298,5298,5298,5298,
+ 2805,5298,5298,5298,5298,5298,5298,5298,1,5685,
+ 5298,5298,625,5298,5686,5687,5559,5557,5566,5565,
+ 5561,5562,5560,5563,5564,5567,5558,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5635,5636,1,5151,221,
+ 5147,221,221,221,221,5298,5298,5298,5298,5685,
+ 5298,5298,625,5298,5686,5687,5298,5298,5298,1,
+ 5053,221,5053,221,221,221,221,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5635,5636,221,5298,5298,
+ 5298,5298,5298,5298,5298,485,5298,5298,699,5298,
+ 1,5053,221,5053,221,221,221,221,5298,221,
+ 5298,5298,5298,5298,6642,5298,221,5050,401,5782,
+ 602,5298,957,640,5298,5298,1,5053,221,5053,
+ 221,221,221,221,5298,5298,5298,5298,5298,5298,
+ 221,5782,5298,5298,5298,6642,5298,5298,5050,5298,
+ 5298,602,5298,957,640,1,5053,221,5053,221,
+ 221,221,221,5718,5719,5720,221,5298,5298,5298,
+ 5298,6642,5782,5298,5050,5298,5298,602,5298,957,
+ 640,5298,5298,5298,5298,5298,5298,5298,11,5298,
+ 651,5298,5298,5298,5298,221,5298,5298,5782,5298,
+ 6642,5298,5298,5050,5298,5298,602,5298,957,640,
+ 1,5053,221,5053,221,221,221,221,5298,10,
+ 5298,5298,5298,5298,5298,5298,213,5782,5298,5298,
+ 5298,5298,1,5053,221,5053,221,221,221,221,
+ 5298,5298,5298,5298,5298,5298,5298,5298,5298,5298,
+ 221,5298,5298,5298,5298,6642,5298,5298,5050,5298,
+ 5298,602,5298,957,640,5298,5298,5298,5298,5298,
+ 5298,5298,221,5298,5298,5298,5298,6642,5298,5298,
+ 5050,213,5782,602,5298,957,640,1,5053,221,
+ 5053,221,221,221,221,5298,5298,5298,5298,5298,
+ 5298,5298,5298,212,5782,5298,5298,5298,5298,1,
+ 5053,221,5053,221,221,221,221,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5298,221,5298,5298,
+ 5298,5298,6642,5298,5298,5050,5298,5298,602,5298,
+ 957,640,5298,5298,5298,5298,5298,5298,5298,221,
+ 5298,5298,5298,5298,6642,5298,5298,5050,213,5782,
+ 602,5298,957,640,1,5053,221,5053,221,221,
+ 221,221,5298,5298,5298,5298,5298,5298,5298,5298,
+ 213,5782,5298,5298,1,5053,221,5053,221,221,
+ 221,221,5298,5298,1,5053,221,5053,221,221,
+ 221,221,5298,5298,221,5298,5298,5298,5298,6642,
+ 5298,5298,5050,5298,5298,602,5298,957,640,5298,
+ 5298,5298,5298,5298,221,5298,5298,5298,5298,6642,
+ 5298,5298,5050,5298,221,602,5782,957,640,6642,
+ 5298,5298,5050,5298,5298,602,5298,957,640,5298,
+ 5298,5298,5298,5298,5298,5298,5782,5298,5298,5298,
+ 5298,5298,5298,5298,5298,5298,5782
+ };
+ };
+ public final static char termAction[] = TermAction.termAction;
+ public final int termAction(int index) { return termAction[index]; }
+
+ public interface Asb {
+ public final static char asb[] = {0,
+ 630,6,834,744,783,526,321,956,485,42,
+ 630,8,121,356,671,526,125,136,486,136,
+ 730,136,484,136,321,356,61,306,411,834,
+ 309,486,486,350,306,621,310,309,310,320,
+ 486,306,733,620,257,56,618,256,411,205,
+ 618,492,411,733,782,307,732,732,353,486,
+ 361,411,364,411,411,782,160,309,309,309,
+ 306,411,622,309,120,356,1,1,148,551,
+ 358,411,956,486,49,49,411,900,211,211,
+ 411,407,618,584,445,618,533,205,492,733,
+ 733,733,782,665,733,361,361,411,364,782,
+ 411,257,1114,309,309,309,411,411,622,1114,
+ 320,310,320,119,119,156,156,993,955,154,
+ 150,552,306,411,266,123,162,413,1049,202,
+ 160,211,211,364,411,780,917,160,160,584,
+ 444,956,356,356,356,356,306,956,1000,409,
+ 585,585,585,585,585,585,585,585,585,77,
+ 1076,1081,1078,1085,1083,1090,1088,1092,1091,1093,
+ 259,1094,205,204,1114,411,492,871,303,863,
+ 492,733,733,785,411,307,411,361,1114,626,
+ 1113,121,873,874,83,120,411,1114,1114,411,
+ 257,257,257,120,1031,1031,584,584,160,162,
+ 413,551,871,585,871,257,956,956,956,552,
+ 956,411,686,257,257,526,570,411,486,550,
+ 160,488,956,202,1108,413,209,202,202,364,
+ 622,736,444,1000,1031,1031,1031,1031,411,266,
+ 160,160,958,1030,780,1000,63,63,779,779,
+ 266,793,585,585,585,585,585,585,585,585,
+ 585,585,585,585,585,585,585,585,585,585,
+ 585,584,584,584,584,584,584,584,584,584,
+ 584,584,793,585,205,780,256,871,542,358,
+ 788,411,665,1114,585,411,1001,257,1047,202,
+ 413,871,552,1000,1000,568,742,1000,257,257,
+ 526,505,306,409,547,123,1116,160,683,158,
+ 121,584,1113,160,160,121,121,121,121,782,
+ 160,585,202,1030,584,160,621,623,621,160,
+ 202,1078,1078,1076,1076,1076,1083,1083,1083,1083,
+ 1081,1081,1088,1085,1085,1091,1090,1092,871,1093,
+ 622,864,585,585,785,346,411,1,160,160,
+ 1024,160,686,257,956,160,411,780,123,160,
+ 160,836,535,414,444,956,956,956,956,411,
+ 411,585,1031,1074,1055,160,411,623,780,584,
+ 257,545,229,306,119,675,552,547,552,257,
+ 686,793,552,782,622,549,486,486,535,793,
+ 793,793,793,956,956,160,1074,530,411,307,
+ 622,411,621,675,584,550,792,257,160,411,
+ 537,160,160,160,160,266,266,1075,1075,1074,
+ 793,1072,624,307,411,677,552,160,792,257,
+ 516,537,160,160,266,585,202,411,624,677,
+ 552,160,956,160,202,411,552,844,159,1031
+ };
+ };
+ public final static char asb[] = Asb.asb;
+ public final int asb(int index) { return asb[index]; }
+
+ public interface Asr {
+ public final static byte asr[] = {0,
+ 65,70,66,1,0,119,0,54,55,8,
+ 9,41,10,44,56,72,45,11,57,58,
+ 12,13,59,60,14,15,61,46,48,62,
+ 47,16,51,52,17,18,2,5,4,40,
+ 50,7,1,6,3,21,53,0,73,50,
+ 65,69,93,74,63,66,40,70,2,0,
+ 73,50,3,6,1,52,62,61,60,7,
+ 59,58,57,45,56,55,69,93,112,74,
+ 71,40,63,2,114,94,101,88,22,23,
+ 5,4,19,20,89,90,86,87,64,91,
+ 92,95,96,97,98,99,100,113,102,103,
+ 104,105,106,107,108,109,110,111,70,66,
+ 65,0,115,0,9,18,8,14,12,13,
+ 15,16,11,10,17,69,40,55,60,61,
+ 45,59,58,52,56,57,62,7,6,1,
+ 3,4,5,63,2,65,70,93,66,74,
+ 0,42,43,2,21,27,31,29,26,34,
+ 9,18,8,14,12,13,15,16,11,10,
+ 17,35,38,36,37,24,33,28,32,3,
+ 7,6,22,23,5,4,19,20,25,30,
+ 1,112,0,39,67,7,68,6,1,3,
+ 73,50,69,93,70,102,103,104,105,106,
+ 107,108,109,110,111,112,74,71,63,2,
+ 114,94,101,88,22,23,5,4,19,20,
+ 89,90,86,87,64,65,91,92,95,96,
+ 97,98,99,100,113,66,40,0,65,69,
+ 93,66,112,71,40,74,8,9,26,42,
+ 10,27,28,11,12,13,43,29,14,15,
+ 30,31,32,39,33,34,16,17,18,35,
+ 36,37,24,38,2,22,23,5,4,19,
+ 20,25,7,6,21,1,3,0,71,7,
+ 2,5,4,6,40,51,53,54,72,48,
+ 21,44,41,46,47,9,18,8,14,12,
+ 13,15,16,11,10,17,55,60,61,45,
+ 59,58,56,57,62,1,3,52,0,70,
+ 50,0,50,69,3,64,0,50,66,0,
+ 1,71,0,8,9,41,67,26,10,27,
+ 44,28,11,12,13,29,14,15,30,31,
+ 46,32,39,33,34,21,47,16,17,68,
+ 18,35,36,37,24,38,2,22,23,5,
+ 4,19,20,25,65,3,6,7,43,42,
+ 1,0,74,55,8,9,41,10,44,56,
+ 45,11,57,58,12,13,59,60,14,15,
+ 61,46,62,21,47,16,52,17,18,1,
+ 3,93,0,71,42,43,39,22,23,5,
+ 4,19,20,6,25,30,2,7,35,38,
+ 36,37,24,33,28,32,9,18,8,14,
+ 12,13,15,16,11,10,17,21,27,31,
+ 29,26,34,3,1,50,0,54,53,119,
+ 115,41,44,72,116,117,118,46,48,21,
+ 47,51,69,71,8,9,10,11,12,13,
+ 14,15,16,17,18,55,56,45,57,58,
+ 59,60,61,62,52,7,2,6,40,1,
+ 3,5,4,0,67,68,39,2,65,93,
+ 74,50,73,69,66,40,70,0,115,120,
+ 71,73,51,53,54,76,78,84,82,75,
+ 80,81,83,85,50,77,79,49,40,44,
+ 41,46,47,55,60,61,45,59,58,52,
+ 56,57,62,39,42,43,21,27,31,29,
+ 26,34,9,18,8,14,12,13,15,16,
+ 11,10,17,35,38,36,37,24,33,28,
+ 32,22,23,19,20,25,30,4,5,2,
+ 3,7,1,6,0,66,71,70,0,8,
+ 9,41,10,44,56,11,57,58,12,13,
+ 59,60,14,15,61,46,62,21,47,16,
+ 52,17,18,55,119,2,5,40,51,53,
+ 54,72,45,3,7,4,6,1,48,0,
+ 50,73,69,0,67,68,39,63,2,65,
+ 70,66,74,93,0,8,9,26,42,10,
+ 27,28,11,12,13,43,7,29,14,15,
+ 30,31,32,39,33,34,21,16,17,18,
+ 35,36,37,24,38,1,2,22,23,5,
+ 4,19,20,6,25,3,40,49,0,48,
+ 1,3,50,69,0,69,112,74,40,66,
+ 0,75,0,9,41,10,44,56,11,57,
+ 58,12,13,59,60,14,15,61,46,62,
+ 21,47,16,52,17,18,8,55,2,5,
+ 4,40,51,53,54,72,45,64,3,7,
+ 6,1,48,0,1,52,3,116,117,118,
+ 0,74,8,9,26,42,10,27,28,11,
+ 12,13,43,7,29,14,15,30,31,32,
+ 39,33,34,21,16,17,18,35,36,37,
+ 38,1,2,22,23,5,4,19,20,6,
+ 25,3,49,24,0,7,6,63,1,4,
+ 5,3,2,74,67,68,44,41,46,47,
+ 9,18,8,14,12,13,15,16,11,10,
+ 17,0,40,7,2,5,4,6,3,1,
+ 69,0,74,8,9,41,67,10,44,11,
+ 12,13,14,15,46,47,16,17,68,18,
+ 1,63,5,4,65,3,66,2,0,9,
+ 18,8,14,12,13,15,16,11,10,17,
+ 41,46,47,44,67,68,43,42,19,20,
+ 4,89,90,97,5,98,6,25,70,64,
+ 65,105,106,102,103,104,110,109,111,87,
+ 86,107,108,95,96,91,92,99,100,22,
+ 23,66,88,101,63,2,0,42,43,22,
+ 23,19,20,6,25,30,7,35,38,36,
+ 37,24,33,28,32,9,18,8,14,12,
+ 13,15,16,11,10,17,21,27,31,29,
+ 26,34,63,1,3,4,5,2,0,49,
+ 42,43,39,22,23,19,20,25,30,35,
+ 38,36,37,24,33,28,32,21,27,31,
+ 29,26,34,7,1,5,4,6,3,2,
+ 9,18,8,14,12,13,15,16,11,10,
+ 17,46,47,44,67,68,41,0,73,50,
+ 114,101,22,23,9,18,8,14,12,13,
+ 15,16,11,10,17,41,46,47,44,67,
+ 68,1,3,63,2,94,88,4,89,90,
+ 19,20,87,86,64,91,92,95,96,5,
+ 97,98,99,65,93,74,70,102,103,104,
+ 105,106,107,108,109,110,111,69,112,40,
+ 100,113,66,71,0,9,18,8,14,12,
+ 13,15,16,11,10,17,41,46,47,44,
+ 67,68,93,0
+ };
+ };
+ public final static byte asr[] = Asr.asr;
+ public final int asr(int index) { return asr[index]; }
+
+ public interface Nasb {
+ public final static char nasb[] = {0,
+ 104,12,12,162,12,153,90,12,62,20,
+ 162,160,12,12,109,126,204,205,12,205,
+ 140,205,98,205,197,12,12,98,238,12,
+ 160,12,12,12,98,98,162,160,162,184,
+ 13,100,110,207,133,65,128,12,238,160,
+ 176,160,142,160,242,12,160,12,12,12,
+ 160,242,160,238,24,12,231,104,160,160,
+ 98,242,242,104,12,12,182,182,191,17,
+ 12,242,12,13,35,35,116,187,12,12,
+ 238,57,153,45,8,153,12,73,222,160,
+ 160,37,87,112,37,160,27,60,29,87,
+ 143,133,43,162,104,104,242,15,10,43,
+ 184,162,184,12,12,12,12,193,12,12,
+ 193,146,100,116,123,55,67,160,174,71,
+ 231,12,12,160,24,79,189,231,231,8,
+ 160,12,12,12,12,12,98,12,212,238,
+ 8,8,6,8,8,8,8,8,8,12,
+ 12,12,12,12,12,12,12,12,12,12,
+ 8,12,160,73,43,238,133,12,20,179,
+ 222,37,37,167,143,12,243,27,43,12,
+ 12,12,173,12,12,12,143,43,43,15,
+ 133,12,133,12,219,219,8,8,231,8,
+ 160,156,12,8,12,133,12,12,12,157,
+ 12,12,131,133,133,160,1,12,81,12,
+ 231,85,12,71,12,184,176,71,71,29,
+ 10,12,39,212,219,219,219,219,238,123,
+ 231,231,8,53,79,212,12,12,48,48,
+ 123,159,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,
+ 8,8,159,8,73,79,133,12,135,12,
+ 227,242,112,43,8,27,29,133,12,71,
+ 184,12,157,217,217,246,12,217,133,133,
+ 153,12,98,238,12,160,219,231,12,12,
+ 12,8,43,231,231,12,12,12,12,78,
+ 231,8,71,219,45,231,9,238,9,231,
+ 71,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,
+ 10,180,8,8,119,121,116,182,231,231,
+ 151,231,248,133,12,231,238,79,55,231,
+ 231,171,160,184,39,12,12,12,12,143,
+ 60,8,219,160,233,231,238,24,79,8,
+ 133,137,12,98,12,160,157,12,157,133,
+ 248,159,157,77,143,85,81,81,73,159,
+ 159,159,159,12,12,231,22,176,24,12,
+ 143,242,9,73,8,12,248,133,231,143,
+ 160,231,231,231,231,123,123,75,75,12,
+ 159,176,12,12,116,160,157,231,248,133,
+ 12,83,231,231,123,8,71,24,12,83,
+ 157,231,12,231,71,24,157,229,231,219
+ };
+ };
+ public final static char nasb[] = Nasb.nasb;
+ public final int nasb(int index) { return nasb[index]; }
+
+ public interface Nasr {
+ public final static char nasr[] = {0,
+ 137,135,43,134,133,3,1,6,4,9,
+ 2,0,150,0,50,0,5,66,0,140,
+ 0,175,0,2,89,0,113,0,4,2,
+ 9,6,43,0,145,0,107,0,6,4,
+ 9,2,66,0,5,26,0,4,2,9,
+ 126,0,170,0,167,0,2,9,1,3,
+ 0,3,49,0,178,0,6,4,9,2,
+ 79,0,36,0,127,0,3,123,69,0,
+ 62,0,144,0,109,0,3,69,0,2,
+ 137,136,135,43,134,133,132,4,0,162,
+ 4,161,0,98,5,48,65,0,151,115,
+ 0,69,125,124,0,2,29,0,4,157,
+ 118,0,5,96,0,5,88,146,4,0,
+ 5,37,39,0,115,151,155,156,0,4,
+ 60,3,2,1,0,5,48,37,177,0,
+ 43,45,5,88,0,66,48,80,37,5,
+ 0,5,48,65,70,0,4,118,189,0,
+ 5,88,103,43,45,4,68,0,39,5,
+ 88,105,0,5,38,0,55,43,164,0,
+ 5,88,4,103,68,0,2,4,43,40,
+ 41,42,111,6,92,0,4,9,2,182,
+ 0,55,43,5,37,0,5,110,55,43,
+ 0,5,48,65,63,4,117,0,55,43,
+ 31,0,43,5,174,45,0,54,2,60,
+ 0,67,2,54,0,48,53,5,99,0
+ };
+ };
+ public final static char nasr[] = Nasr.nasr;
+ public final int nasr(int index) { return nasr[index]; }
+
+ public interface TerminalIndex {
+ public final static char terminalIndex[] = {0,
+ 115,2,32,11,10,14,81,50,54,62,
+ 70,76,77,88,89,104,107,109,12,13,
+ 102,8,9,114,15,57,63,69,86,90,
+ 92,96,99,101,111,112,113,46,97,123,
+ 55,60,80,65,68,93,103,95,124,3,
+ 105,106,79,48,49,66,72,75,78,85,
+ 91,100,1,20,21,45,56,108,31,34,
+ 122,67,98,121,110,51,52,58,59,61,
+ 71,73,74,87,94,18,19,7,16,17,
+ 22,23,33,5,24,25,26,27,28,29,
+ 6,35,36,37,38,39,40,41,42,43,
+ 44,120,30,4,53,82,83,84,125,64,
+ 116,117,118,119
+ };
+ };
+ public final static char terminalIndex[] = TerminalIndex.terminalIndex;
+ public final int terminalIndex(int index) { return terminalIndex[index]; }
+
+ public interface NonterminalIndex {
+ public final static char nonterminalIndex[] = {0,
+ 136,232,134,0,0,144,0,135,228,133,
+ 0,132,0,0,0,143,148,0,0,149,
+ 158,159,160,161,162,151,163,164,137,165,
+ 127,166,167,168,0,192,131,179,129,187,
+ 188,189,193,214,191,169,0,0,197,142,
+ 0,0,176,139,152,0,0,0,0,138,
+ 146,172,178,0,0,128,0,155,0,177,
+ 0,0,0,0,0,0,0,0,126,171,
+ 0,0,0,0,0,0,0,175,147,0,
+ 0,185,0,0,157,0,209,130,0,0,
+ 0,206,207,0,0,0,0,0,236,174,
+ 190,195,196,199,0,212,215,0,0,231,
+ 0,234,0,140,141,145,0,154,0,170,
+ 0,180,181,182,183,184,186,0,194,0,
+ 198,0,0,0,204,205,0,0,208,210,
+ 211,0,216,219,220,221,223,0,0,225,
+ 226,227,0,229,230,233,235,0,0,0,
+ 150,0,0,153,156,0,173,200,201,202,
+ 0,203,0,213,0,0,217,218,222,224,
+ 237,238,0,0,0,0,0
+ };
+ };
+ public final static char nonterminalIndex[] = NonterminalIndex.nonterminalIndex;
+ public final int nonterminalIndex(int index) { return nonterminalIndex[index]; }
+
+ public interface ScopePrefix {
+ public final static char scopePrefix[] = {
+ 539,558,322,490,506,517,528,302,79,207,
+ 221,243,249,255,232,347,376,428,547,330,
+ 30,59,85,118,238,261,272,283,51,213,
+ 227,458,312,283,566,171,194,1,14,26,
+ 69,132,147,165,266,279,288,295,394,421,
+ 451,482,486,576,580,584,92,7,92,132,
+ 365,372,385,405,37,473,385,437,437,497,
+ 513,524,535,37,336,64,64,101,139,142,
+ 162,64,191,199,202,64,299,400,418,425,
+ 139,599,20,153,159,184,369,412,64,107,
+ 107,184,64,356,184,99,398,588,595,99,
+ 588,595,73,125
+ };
+ };
+ public final static char scopePrefix[] = ScopePrefix.scopePrefix;
+ public final int scopePrefix(int index) { return scopePrefix[index]; }
+
+ public interface ScopeSuffix {
+ public final static char scopeSuffix[] = {
+ 5,5,309,5,5,5,5,309,67,123,
+ 90,123,123,123,218,353,382,434,75,317,
+ 35,35,90,123,123,123,277,277,56,218,
+ 96,463,317,553,571,176,176,5,18,18,
+ 5,123,151,169,270,270,270,90,123,169,
+ 5,5,5,5,5,169,597,11,96,136,
+ 309,309,309,409,47,463,389,441,446,501,
+ 501,501,501,41,340,67,67,90,5,145,
+ 5,182,169,5,205,182,90,403,5,169,
+ 5,5,23,156,156,292,156,415,455,110,
+ 114,187,477,359,467,90,90,590,590,104,
+ 592,592,75,127
+ };
+ };
+ public final static char scopeSuffix[] = ScopeSuffix.scopeSuffix;
+ public final int scopeSuffix(int index) { return scopeSuffix[index]; }
+
+ public interface ScopeLhs {
+ public final static char scopeLhs[] = {
+ 16,16,84,16,16,16,16,84,157,73,
+ 51,78,77,42,58,84,83,18,16,84,
+ 1,8,153,40,76,42,41,111,64,59,
+ 51,126,84,16,16,103,181,168,151,87,
+ 161,116,63,103,41,41,111,53,62,175,
+ 17,16,16,16,16,16,13,109,153,116,
+ 84,83,83,35,121,126,83,18,18,16,
+ 16,16,16,121,84,162,157,153,178,63,
+ 103,183,145,180,88,111,85,81,129,175,
+ 173,15,151,97,97,111,110,20,126,44,
+ 44,68,126,84,126,153,82,124,60,153,
+ 124,60,161,40
+ };
+ };
+ public final static char scopeLhs[] = ScopeLhs.scopeLhs;
+ public final int scopeLhs(int index) { return scopeLhs[index]; }
+
+ public interface ScopeLa {
+ public final static byte scopeLa[] = {
+ 74,74,74,74,74,74,74,74,1,71,
+ 40,71,71,71,1,74,120,74,2,40,
+ 65,65,40,71,71,71,1,1,65,1,
+ 1,3,40,1,1,74,74,74,115,115,
+ 74,71,50,112,1,1,1,40,71,112,
+ 74,74,74,74,74,112,1,74,1,66,
+ 74,74,74,69,65,3,74,2,9,65,
+ 65,65,65,65,40,1,1,40,74,73,
+ 74,1,112,74,1,1,40,69,74,112,
+ 74,74,50,70,70,48,70,74,6,1,
+ 1,4,1,75,48,40,40,3,3,1,
+ 3,3,2,50
+ };
+ };
+ public final static byte scopeLa[] = ScopeLa.scopeLa;
+ public final int scopeLa(int index) { return scopeLa[index]; }
+
+ public interface ScopeStateSet {
+ public final static char scopeStateSet[] = {
+ 150,150,268,150,150,150,150,268,18,291,
+ 279,291,291,215,281,268,268,150,150,268,
+ 99,140,314,215,291,215,215,241,303,281,
+ 279,13,268,150,150,90,34,1,96,268,
+ 36,211,303,90,215,215,241,256,39,7,
+ 150,150,150,150,150,150,144,21,314,211,
+ 268,268,268,182,58,13,268,150,150,150,
+ 150,150,150,58,268,36,18,314,32,303,
+ 90,34,29,34,245,241,268,268,4,7,
+ 16,150,96,55,55,241,9,151,13,215,
+ 215,83,13,268,13,314,268,26,62,314,
+ 26,62,36,215
+ };
+ };
+ public final static char scopeStateSet[] = ScopeStateSet.scopeStateSet;
+ public final int scopeStateSet(int index) { return scopeStateSet[index]; }
+
+ public interface ScopeRhs {
+ public final static char scopeRhs[] = {0,
+ 316,2,39,0,127,0,315,2,115,0,
+ 127,172,0,274,239,73,0,235,0,239,
+ 73,0,210,235,0,129,186,73,0,287,
+ 129,64,126,0,21,0,289,64,48,0,
+ 21,55,0,34,132,0,21,55,0,0,
+ 289,64,48,189,0,21,177,0,287,129,
+ 64,133,0,191,128,0,137,0,220,2,
+ 286,0,286,0,2,0,127,0,191,128,
+ 242,241,242,0,134,193,184,128,0,129,
+ 0,193,184,128,0,133,129,0,172,0,
+ 311,172,0,217,129,0,184,167,0,136,
+ 0,0,0,134,0,0,0,309,129,50,
+ 168,0,128,0,168,0,3,0,0,128,
+ 0,308,129,50,0,45,128,0,150,2,
+ 0,212,172,0,211,0,239,212,172,0,
+ 210,0,271,162,0,34,169,0,212,162,
+ 0,226,2,0,300,63,228,0,126,0,
+ 267,129,2,228,0,127,0,0,0,0,
+ 0,147,0,184,128,0,11,0,0,0,
+ 219,63,0,267,129,2,304,0,212,2,
+ 0,266,129,0,201,0,230,129,50,24,
+ 45,0,191,128,53,51,0,142,129,0,
+ 134,191,128,264,51,0,191,128,264,51,
+ 0,191,128,70,1,53,0,230,129,50,
+ 53,0,230,129,50,173,53,0,230,129,
+ 50,127,53,0,262,129,50,1,44,0,
+ 262,129,50,44,0,191,128,44,0,134,
+ 0,193,191,128,167,0,136,0,191,128,
+ 167,0,193,184,128,21,0,184,128,21,
+ 0,95,136,0,255,129,172,0,161,84,
+ 0,223,163,223,177,2,81,0,127,171,
+ 0,223,177,2,81,0,129,0,127,171,
+ 0,223,163,223,163,223,2,81,0,223,
+ 163,223,2,81,0,223,2,81,0,129,
+ 0,129,0,127,171,0,161,2,75,204,
+ 80,0,127,129,0,204,80,0,110,2,
+ 131,127,129,0,234,2,75,0,212,179,
+ 0,234,2,85,0,204,155,234,2,83,
+ 0,64,171,0,234,2,83,0,127,171,
+ 64,171,0,301,129,50,0,161,0,219,
+ 77,0,31,0,161,113,158,0,31,169,
+ 0,185,2,0,127,149,0,220,2,0,
+ 219,63,299,0,161,63,0,185,2,294,
+ 43,128,0,127,0,0,294,43,128,0,
+ 2,146,127,0,0,150,0,0,0,0,
+ 185,2,30,0,14,147,0,125,48,184,
+ 128,0,32,14,147,0,95,136,32,14,
+ 147,0,213,191,128,0,147,32,14,147,
+ 0,185,2,34,0,161,2,34,0,161,
+ 2,65,185,64,26,0,185,64,26,0,
+ 21,2,131,127,0,161,2,65,185,64,
+ 29,0,185,64,29,0,161,2,65,185,
+ 64,31,0,185,64,31,0,161,2,65,
+ 185,64,27,0,185,64,27,0,220,2,
+ 125,193,184,128,21,0,125,193,184,128,
+ 21,0,136,2,0,127,0,220,2,127,
+ 247,184,128,21,0,247,184,128,21,0,
+ 134,2,0,127,0,220,2,130,0,220,
+ 2,140,0,161,63,140,0,249,0,32,
+ 0,32,140,0,178,0,133,0,161,2,
+ 0
+ };
+ };
+ public final static char scopeRhs[] = ScopeRhs.scopeRhs;
+ public final int scopeRhs(int index) { return scopeRhs[index]; }
+
+ public interface ScopeState {
+ public final static char scopeState[] = {0,
+ 1445,1349,0,1541,1198,0,609,0,4231,4209,
+ 4184,0,2356,833,0,840,0,2490,3036,0,
+ 2371,3162,1816,852,0,2591,2458,0,790,747,
+ 0,1011,0,4080,0,2571,2378,0,3631,3568,
+ 3528,1855,1575,3465,3425,3362,3322,1271,3211,2865,
+ 2825,1279,548,0,902,1383,1335,3423,648,3417,
+ 0,4882,4976,4961,4850,4820,4811,4921,4906,4891,
+ 4779,4749,4740,4708,4678,3642,4669,4645,2592,4600,
+ 2688,0,3047,2380,2875,4281,2313,2603,2509,3236,
+ 3391,4297,2833,3530,0,2579,2450,0,4277,3363,
+ 3353,1620,4882,1578,3253,1527,2843,4976,1194,4961,
+ 2826,4850,4820,4811,4921,1153,4143,965,4906,4891,
+ 2839,2557,4779,570,4749,2486,4740,4708,4678,621,
+ 3642,4669,4645,558,2592,4600,3785,2688,2283,2086,
+ 2082,764,945,1992,1282,634,2356,833,4080,2170,
+ 4059,4038,2136,2190,2254,2223,2421,2389,2328,2977,
+ 2953,2800,2775,2750,2453,3763,3741,3719,3299,3007,
+ 4017,3996,3975,3954,3933,3912,3891,3851,3830,2291,
+ 3793,2100,1872,1824,2046,2010,1776,853,1956,1728,
+ 1680,1632,1584,1536,1488,1440,1392,1344,1296,1242,
+ 716,522,1920,1206,1158,1110,1056,970,1020,660,
+ 573,785,909,0,4621,4302,4599,4575,3236,2852,
+ 4553,4529,4231,4209,4184,853,4162,4507,4483,4461,
+ 4430,4116,716,4380,4353,3391,4094,4281,660,3519,
+ 522,3785,2283,0,3236,2852,3492,3326,3284,2492,
+ 1009,3530,2509,626,0,4948,3156,2649,2605,3125,
+ 2561,2478,3094,3063,3032,3001,2447,3631,3568,3528,
+ 3465,3425,3362,3322,3211,2865,2825,0,4310,4265,
+ 3631,3568,3528,3465,3425,3362,3322,3211,2865,2825,
+ 3156,2649,2605,3125,2561,2478,3094,3063,3032,3001,
+ 2447,0,3156,2649,2605,3125,2561,2478,3094,3063,
+ 3032,3001,2447,4310,4265,0
+ };
+ };
+ public final static char scopeState[] = ScopeState.scopeState;
+ public final int scopeState(int index) { return scopeState[index]; }
+
+ public interface InSymb {
+ public final static char inSymb[] = {0,
+ 0,293,45,48,189,172,129,54,53,51,
+ 222,24,64,48,212,129,256,257,168,258,
+ 167,259,44,260,261,126,1,21,128,2,
+ 50,173,127,1,53,264,129,50,65,64,
+ 239,69,73,266,255,212,129,265,128,4,
+ 270,50,184,310,128,178,125,127,1,1,
+ 50,128,64,128,191,184,24,129,50,50,
+ 70,128,128,129,289,48,21,41,162,50,
+ 285,128,286,239,306,304,6,7,133,1,
+ 128,3,2,2,70,66,184,129,129,125,
+ 127,129,191,3,129,50,129,191,129,184,
+ 48,155,230,222,129,129,128,191,191,230,
+ 66,65,64,229,229,271,212,2,228,227,
+ 192,129,66,191,2,274,63,2,179,63,
+ 2,42,43,64,191,184,7,212,150,129,
+ 50,34,26,29,31,27,21,130,2,128,
+ 30,25,6,20,19,4,5,23,22,140,
+ 145,147,146,149,148,152,151,156,154,157,
+ 39,158,4,160,309,128,187,241,51,172,
+ 312,129,129,69,193,249,193,129,262,237,
+ 263,287,179,130,136,290,193,230,230,191,
+ 174,1,134,289,70,70,70,70,226,63,
+ 2,301,79,77,1,161,85,83,81,80,
+ 75,82,84,78,76,172,129,53,73,49,
+ 220,291,115,219,158,129,192,63,63,129,
+ 193,254,129,2,64,64,64,64,128,2,
+ 185,161,42,43,184,2,125,127,101,114,
+ 2,63,88,94,20,19,90,89,4,92,
+ 91,65,64,86,87,5,96,95,98,97,
+ 99,111,110,109,108,107,106,105,104,103,
+ 102,70,113,100,129,184,311,229,212,313,
+ 242,128,3,262,70,66,66,174,65,300,
+ 129,219,69,2,2,2,204,2,1,161,
+ 129,130,21,128,1,186,2,267,272,273,
+ 287,66,308,185,161,185,185,185,185,184,
+ 220,155,63,294,2,185,48,128,48,220,
+ 161,146,146,145,145,145,148,148,148,148,
+ 147,147,151,149,149,154,152,156,161,157,
+ 193,66,69,70,66,241,191,41,267,234,
+ 179,234,177,223,75,234,128,184,129,93,
+ 315,179,155,66,66,65,65,65,65,193,
+ 247,203,2,295,179,150,128,191,184,69,
+ 134,212,38,242,229,155,155,212,155,223,
+ 163,2,155,184,48,291,155,155,129,2,
+ 2,2,2,125,127,185,129,129,6,213,
+ 48,128,70,129,70,204,163,223,161,193,
+ 224,161,161,161,161,2,2,155,296,299,
+ 63,192,3,125,191,224,120,223,163,155,
+ 125,129,220,220,2,63,161,6,3,129,
+ 155,223,39,220,219,6,155,2,316,66
+ };
+ };
+ public final static char inSymb[] = InSymb.inSymb;
+ public final int inSymb(int index) { return inSymb[index]; }
+
+ public interface Name {
+ public final static String name[] = {
+ "",
+ "[",
+ "(",
+ "{",
+ ".",
+ ".*",
+ "->",
+ "->*",
+ "++",
+ "--",
+ "&",
+ "*",
+ "+",
+ "-",
+ "~",
+ "!",
+ "/",
+ "%",
+ ">>",
+ "<<",
+ "<",
+ ">",
+ "<=",
+ ">=",
+ "==",
+ "!=",
+ "^",
+ "|",
+ "&&",
+ "||",
+ "?",
+ ":",
+ "::",
+ "...",
+ "=",
+ "*=",
+ "/=",
+ "%=",
+ "+=",
+ "-=",
+ ">>=",
+ "<<=",
+ "&=",
+ "^=",
+ "|=",
+ ",",
+ "0",
+ "$empty",
+ "asm",
+ "auto",
+ "bool",
+ "break",
+ "case",
+ "catch",
+ "char",
+ "class",
+ "const",
+ "const_cast",
+ "continue",
+ "default",
+ "delete",
+ "do",
+ "double",
+ "dynamic_cast",
+ "else",
+ "enum",
+ "explicit",
+ "export",
+ "extern",
+ "false",
+ "float",
+ "for",
+ "friend",
+ "goto",
+ "if",
+ "inline",
+ "int",
+ "long",
+ "mutable",
+ "namespace",
+ "new",
+ "operator",
+ "private",
+ "protected",
+ "public",
+ "register",
+ "reinterpret_cast",
+ "return",
+ "short",
+ "signed",
+ "sizeof",
+ "static",
+ "static_cast",
+ "struct",
+ "switch",
+ "template",
+ "this",
+ "throw",
+ "try",
+ "true",
+ "typedef",
+ "typeid",
+ "typename",
+ "union",
+ "unsigned",
+ "using",
+ "virtual",
+ "void",
+ "volatile",
+ "wchar_t",
+ "while",
+ "integer",
+ "floating",
+ "charconst",
+ "stringlit",
+ "identifier",
+ "TypedefName",
+ "Completion",
+ "EndOfCompletion",
+ "Invalid",
+ "RightBracket",
+ "RightParen",
+ "RightBrace",
+ "SemiColon",
+ "ERROR_TOKEN",
+ "EOF_TOKEN",
+ "]",
+ ")",
+ "}",
+ ";",
+ "declaration_seq",
+ "expression",
+ "qualified_or_unqualified_name",
+ "unqualified_id_name",
+ "identifier_name",
+ "operator_function_id_name",
+ "template_id_name",
+ "class_name",
+ "nested_name_specifier",
+ "class_or_namespace_name",
+ "nested_name_specifier_with_tem" +
+ "plate",
+ "class_or_namespace_name_with_t" +
+ "emplate",
+ "namespace_name",
+ "postfix_expression",
+ "simple_type_specifier",
+ "pseudo_destructor_name",
+ "type_id",
+ "type_name",
+ "unary_expression",
+ "cast_expression",
+ "new_type_id",
+ "expression_list",
+ "type_specifier_seq",
+ "new_declarator",
+ "new_pointer_operators",
+ "ptr_operator",
+ "new_array_expressions",
+ "constant_expression",
+ "pm_expression",
+ "multiplicative_expression",
+ "additive_expression",
+ "shift_expression",
+ "relational_expression",
+ "equality_expression",
+ "and_expression",
+ "exclusive_or_expression",
+ "inclusive_or_expression",
+ "logical_and_expression",
+ "logical_or_expression",
+ "assignment_expression",
+ "expression_list_actual",
+ "statement",
+ "compound_statement",
+ "statement_seq",
+ "condition",
+ "declarator",
+ "simple_declaration",
+ "declaration",
+ "function_definition",
+ "declaration_specifiers",
+ "simple_declaration_specifiers",
+ "class_declaration_specifiers",
+ "elaborated_declaration_specifi" +
+ "ers",
+ "enum_declaration_specifiers",
+ "type_name_declaration_specifie" +
+ "rs",
+ "no_type_declaration_specifier",
+ "no_type_declaration_specifiers",
+ "class_specifier",
+ "elaborated_type_specifier",
+ "enum_specifier",
+ "type_name_specifier",
+ "type_specifier",
+ "cv_qualifier",
+ "class_keyword",
+ "enumerator_list",
+ "enumerator_definition",
+ "enumerator",
+ "original_namespace_name",
+ "init_declarator_list",
+ "init_declarator",
+ "initializer",
+ "direct_declarator",
+ "basic_direct_declarator",
+ "array_direct_declarator",
+ "array_modifier",
+ "ptr_operator_seq",
+ "abstract_declarator",
+ "direct_abstract_declarator",
+ "parameter_declaration_list",
+ "parameter_declaration",
+ "function_body",
+ "function_try_block",
+ "initializer_clause",
+ "initializer_list",
+ "class_head",
+ "access_specifier_keyword",
+ "member_declaration",
+ "member_declarator_list",
+ "member_declaration_list",
+ "member_declarator",
+ "pure_specifier",
+ "constant_initializer",
+ "base_specifier_list",
+ "base_specifier",
+ "conversion_type_id",
+ "mem_initializer_list",
+ "mem_initializer",
+ "mem_initializer_id",
+ "operator_id_name",
+ "overloadable_operator",
+ "template_parameter_list",
+ "template_parameter",
+ "template_identifier",
+ "template_argument_list",
+ "template_argument",
+ "handler_seq",
+ "handler",
+ "exception_declaration",
+ "type_id_list"
+ };
+ };
+ public final static String name[] = Name.name;
+ public final String name(int index) { return name[index]; }
+
+ public final static int
+ ERROR_SYMBOL = 49,
+ SCOPE_UBOUND = 113,
+ SCOPE_SIZE = 114,
+ MAX_NAME_LENGTH = 37;
+
+ public final int getErrorSymbol() { return ERROR_SYMBOL; }
+ public final int getScopeUbound() { return SCOPE_UBOUND; }
+ public final int getScopeSize() { return SCOPE_SIZE; }
+ public final int getMaxNameLength() { return MAX_NAME_LENGTH; }
+
+ public final static int
+ NUM_STATES = 500,
+ NT_OFFSET = 124,
+ LA_STATE_OFFSET = 5819,
+ MAX_LA = 2147483647,
+ NUM_RULES = 521,
+ NUM_NONTERMINALS = 197,
+ NUM_SYMBOLS = 321,
+ SEGMENT_SIZE = 8192,
+ START_STATE = 2447,
+ IDENTIFIER_SYMBOL = 0,
+ EOFT_SYMBOL = 119,
+ EOLT_SYMBOL = 119,
+ ACCEPT_ACTION = 5049,
+ ERROR_ACTION = 5298;
+
+ public final static boolean BACKTRACK = true;
+
+ public final int getNumStates() { return NUM_STATES; }
+ public final int getNtOffset() { return NT_OFFSET; }
+ public final int getLaStateOffset() { return LA_STATE_OFFSET; }
+ public final int getMaxLa() { return MAX_LA; }
+ public final int getNumRules() { return NUM_RULES; }
+ public final int getNumNonterminals() { return NUM_NONTERMINALS; }
+ public final int getNumSymbols() { return NUM_SYMBOLS; }
+ public final int getSegmentSize() { return SEGMENT_SIZE; }
+ public final int getStartState() { return START_STATE; }
+ public final int getStartSymbol() { return lhs[0]; }
+ public final int getIdentifierSymbol() { return IDENTIFIER_SYMBOL; }
+ public final int getEoftSymbol() { return EOFT_SYMBOL; }
+ public final int getEoltSymbol() { return EOLT_SYMBOL; }
+ public final int getAcceptAction() { return ACCEPT_ACTION; }
+ public final int getErrorAction() { return ERROR_ACTION; }
+ public final boolean isValidForParser() { return isValidForParser; }
+ public final boolean getBacktrack() { return BACKTRACK; }
+
+ public final int originalState(int state) {
+ return -baseCheck[state];
+ }
+ public final int asi(int state) {
+ return asb[originalState(state)];
+ }
+ public final int nasi(int state) {
+ return nasb[originalState(state)];
+ }
+ public final int inSymbol(int state) {
+ return inSymb[originalState(state)];
+ }
+
+ public final int ntAction(int state, int sym) {
+ return baseAction[state + sym];
+ }
+
+ public final int tAction(int state, int sym) {
+ int i = baseAction[state],
+ k = i + sym;
+ return termAction[termCheck[k] == sym ? k : i];
+ }
+ public final int lookAhead(int la_state, int sym) {
+ int k = la_state + sym;
+ return termAction[termCheck[k] == sym ? k : la_state];
+ }
+}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParsersym.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParsersym.java
new file mode 100644
index 00000000000..be7e44fe79a
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParsersym.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+* Copyright (c) 2006, 2008 IBM Corporation and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl_v10.html
+*
+* Contributors:
+* IBM Corporation - initial API and implementation
+*********************************************************************************/
+
+// This file was generated by LPG
+
+package org.eclipse.cdt.internal.core.dom.lrparser.cpp;
+
+public interface CPPParsersym {
+ public final static int
+ TK_asm = 54,
+ TK_auto = 55,
+ TK_bool = 8,
+ TK_break = 76,
+ TK_case = 77,
+ TK_catch = 115,
+ TK_char = 9,
+ TK_class = 41,
+ TK_const = 67,
+ TK_const_cast = 26,
+ TK_continue = 78,
+ TK_default = 79,
+ TK_delete = 42,
+ TK_do = 80,
+ TK_double = 10,
+ TK_dynamic_cast = 27,
+ TK_else = 120,
+ TK_enum = 44,
+ TK_explicit = 56,
+ TK_export = 72,
+ TK_extern = 45,
+ TK_false = 28,
+ TK_float = 11,
+ TK_for = 81,
+ TK_friend = 57,
+ TK_goto = 82,
+ TK_if = 83,
+ TK_inline = 58,
+ TK_int = 12,
+ TK_long = 13,
+ TK_mutable = 59,
+ TK_namespace = 53,
+ TK_new = 43,
+ TK_operator = 7,
+ TK_private = 116,
+ TK_protected = 117,
+ TK_public = 118,
+ TK_register = 60,
+ TK_reinterpret_cast = 29,
+ TK_return = 84,
+ TK_short = 14,
+ TK_signed = 15,
+ TK_sizeof = 30,
+ TK_static = 61,
+ TK_static_cast = 31,
+ TK_struct = 46,
+ TK_switch = 85,
+ TK_template = 48,
+ TK_this = 32,
+ TK_throw = 39,
+ TK_try = 73,
+ TK_true = 33,
+ TK_typedef = 62,
+ TK_typeid = 34,
+ TK_typename = 21,
+ TK_union = 47,
+ TK_unsigned = 16,
+ TK_using = 51,
+ TK_virtual = 52,
+ TK_void = 17,
+ TK_volatile = 68,
+ TK_wchar_t = 18,
+ TK_while = 75,
+ TK_integer = 35,
+ TK_floating = 36,
+ TK_charconst = 37,
+ TK_stringlit = 24,
+ TK_zero = 38,
+ TK_identifier = 1,
+ TK_TypedefName = 121,
+ TK_Completion = 122,
+ TK_EndOfCompletion = 123,
+ TK_Invalid = 124,
+ TK_LeftBracket = 63,
+ TK_LeftParen = 2,
+ TK_LeftBrace = 50,
+ TK_Dot = 114,
+ TK_DotStar = 94,
+ TK_Arrow = 101,
+ TK_ArrowStar = 88,
+ TK_PlusPlus = 22,
+ TK_MinusMinus = 23,
+ TK_And = 5,
+ TK_Star = 4,
+ TK_Plus = 19,
+ TK_Minus = 20,
+ TK_Tilde = 6,
+ TK_Bang = 25,
+ TK_Slash = 89,
+ TK_Percent = 90,
+ TK_RightShift = 86,
+ TK_LeftShift = 87,
+ TK_LT = 64,
+ TK_GT = 65,
+ TK_LE = 91,
+ TK_GE = 92,
+ TK_EQ = 95,
+ TK_NE = 96,
+ TK_Caret = 97,
+ TK_Or = 98,
+ TK_AndAnd = 99,
+ TK_OrOr = 100,
+ TK_Question = 113,
+ TK_Colon = 69,
+ TK_ColonColon = 3,
+ TK_DotDotDot = 93,
+ TK_Assign = 70,
+ TK_StarAssign = 102,
+ TK_SlashAssign = 103,
+ TK_PercentAssign = 104,
+ TK_PlusAssign = 105,
+ TK_MinusAssign = 106,
+ TK_RightShiftAssign = 107,
+ TK_LeftShiftAssign = 108,
+ TK_AndAssign = 109,
+ TK_CaretAssign = 110,
+ TK_OrAssign = 111,
+ TK_Comma = 66,
+ TK_RightBracket = 112,
+ TK_RightParen = 74,
+ TK_RightBrace = 71,
+ TK_SemiColon = 40,
+ TK_ERROR_TOKEN = 49,
+ TK_EOF_TOKEN = 119;
+
+ public final static String orderedTerminalSymbols[] = {
+ "",
+ "identifier",
+ "LeftParen",
+ "ColonColon",
+ "Star",
+ "And",
+ "Tilde",
+ "operator",
+ "bool",
+ "char",
+ "double",
+ "float",
+ "int",
+ "long",
+ "short",
+ "signed",
+ "unsigned",
+ "void",
+ "wchar_t",
+ "Plus",
+ "Minus",
+ "typename",
+ "PlusPlus",
+ "MinusMinus",
+ "stringlit",
+ "Bang",
+ "const_cast",
+ "dynamic_cast",
+ "false",
+ "reinterpret_cast",
+ "sizeof",
+ "static_cast",
+ "this",
+ "true",
+ "typeid",
+ "integer",
+ "floating",
+ "charconst",
+ "zero",
+ "throw",
+ "SemiColon",
+ "class",
+ "delete",
+ "new",
+ "enum",
+ "extern",
+ "struct",
+ "union",
+ "template",
+ "ERROR_TOKEN",
+ "LeftBrace",
+ "using",
+ "virtual",
+ "namespace",
+ "asm",
+ "auto",
+ "explicit",
+ "friend",
+ "inline",
+ "mutable",
+ "register",
+ "static",
+ "typedef",
+ "LeftBracket",
+ "LT",
+ "GT",
+ "Comma",
+ "const",
+ "volatile",
+ "Colon",
+ "Assign",
+ "RightBrace",
+ "export",
+ "try",
+ "RightParen",
+ "while",
+ "break",
+ "case",
+ "continue",
+ "default",
+ "do",
+ "for",
+ "goto",
+ "if",
+ "return",
+ "switch",
+ "RightShift",
+ "LeftShift",
+ "ArrowStar",
+ "Slash",
+ "Percent",
+ "LE",
+ "GE",
+ "DotDotDot",
+ "DotStar",
+ "EQ",
+ "NE",
+ "Caret",
+ "Or",
+ "AndAnd",
+ "OrOr",
+ "Arrow",
+ "StarAssign",
+ "SlashAssign",
+ "PercentAssign",
+ "PlusAssign",
+ "MinusAssign",
+ "RightShiftAssign",
+ "LeftShiftAssign",
+ "AndAssign",
+ "CaretAssign",
+ "OrAssign",
+ "RightBracket",
+ "Question",
+ "Dot",
+ "catch",
+ "private",
+ "protected",
+ "public",
+ "EOF_TOKEN",
+ "else",
+ "TypedefName",
+ "Completion",
+ "EndOfCompletion",
+ "Invalid"
+ };
+
+ public final static boolean isValidForParser = true;
+}

Back to the top