Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2009-04-15 15:24:57 -0400
committerMike Kucera2009-04-15 15:24:57 -0400
commitd99739839b5dc6daf3b56b5c6174fa7983b3d39f (patch)
tree96736687c4c02a9667b10c89a75f7fa34e2a4723 /lrparser/org.eclipse.cdt.core.lrparser
parente389841b9f2af094c2c3417bc0a982978c19417d (diff)
downloadorg.eclipse.cdt-d99739839b5dc6daf3b56b5c6174fa7983b3d39f.tar.gz
org.eclipse.cdt-d99739839b5dc6daf3b56b5c6174fa7983b3d39f.tar.xz
org.eclipse.cdt-d99739839b5dc6daf3b56b5c6174fa7983b3d39f.zip
[272375] support for UTF string literals in LR parser
Diffstat (limited to 'lrparser/org.eclipse.cdt.core.lrparser')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF1
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/build.xml33
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/generate.xml64
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/DOMToC99TokenMap.java4
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/DOMToISOCPPTokenMap.java4
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGCCTokenMap.java4
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGPPTokenMap.java4
7 files changed, 84 insertions, 30 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF b/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF
index 403832ca95..0f1f07b721 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF
+++ b/lrparser/org.eclipse.cdt.core.lrparser/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ 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.action.cpp,
+ org.eclipse.cdt.core.dom.lrparser.action.gnu,
org.eclipse.cdt.core.dom.lrparser.c99,
org.eclipse.cdt.core.dom.lrparser.cpp,
org.eclipse.cdt.core.dom.lrparser.gnu,
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/build.xml b/lrparser/org.eclipse.cdt.core.lrparser/grammar/build.xml
index f1a71b9c8d..2dfb0d5191 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/build.xml
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/build.xml
@@ -12,17 +12,8 @@
<project name="CDT Extensible LR Parser Framework" basedir=".">
<description>Generates LPG parsers from grammar files</description>
-
- <fail unless="lpg_exe">
- Property $${lpg_exe} not set.
- This property must be set to the full path to the LPG generator executable.
- </fail>
-
- <fail unless="lpg_template">
- Property $${lpg_template} not set.
- This property must be set to the full path to the LPG templates folder.
- </fail>
-
+ <import file="generate.xml"/>
+
<property name="c99_location" value="../src/org/eclipse/cdt/internal/core/dom/lrparser/c99"/>
<property name="gcc_location" value="../src/org/eclipse/cdt/internal/core/dom/lrparser/gcc"/>
<property name="cpp_location" value="../src/org/eclipse/cdt/internal/core/dom/lrparser/cpp"/>
@@ -148,24 +139,6 @@
- <target name="generate">
- <property name="grammar_file" value="${grammar_dir}/${grammar_name}.g"/>
- <echo message="lpg_exe=${lpg_exe}"/>
- <echo message="lpg_template=${lpg_template}"/>
- <echo message="grammar_file=${grammar_file}.g"/>
- <echo message="output_dir=${output_dir}"/>
-
- <exec executable="${lpg_exe}">
- <arg value="${grammar_file}"/>
- <env key="LPG_TEMPLATE" path="${lpg_template}"/>
-
- </exec>
-
- <move overwrite="true" toDir="${output_dir}">
- <fileset dir=".">
- <include name="${grammar_name}*.*"/>
- </fileset>
- </move>
- </target>
+
</project> \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/generate.xml b/lrparser/org.eclipse.cdt.core.lrparser/grammar/generate.xml
new file mode 100644
index 0000000000..6241db9594
--- /dev/null
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/generate.xml
@@ -0,0 +1,64 @@
+<!--
+ Copyright (c) 2009 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
+-->
+
+<project name="CDT Extensible LR Parser Framework" basedir=".">
+
+ <!--
+ Common tasks that can be used to generate a parser using LPG and the
+ LR parser framework.
+
+ There are two ANT properties that must be defined:
+ 1) lpg_exe - This property must be set to the full path to the LPG generator executable (lpg.exe).
+ 2) lpg_template - This property must be set to the full path to the folder that contains the LRParserTemplate.g file.
+
+ Additionally if the $Import or $Include directives are being used in a grammar
+ file then the LPG_INCLUDE environment variable must be set to the directory
+ of the files being included.
+ -->
+
+ <fail unless="lpg_exe">
+ Property $${lpg_exe} not set.
+ This property must be set to the full path to the LPG generator executable.
+ </fail>
+
+ <fail unless="lpg_template">
+ Property $${lpg_template} not set.
+ This property must be set to the full path to the LPG templates folder.
+ </fail>
+
+
+ <!--
+ Parameters:
+ ${grammar_dir} - directory that contains the grammar files
+ ${grammar_name} - the name of the main grammar file to run LPG on (not including the .g extension)
+ ${output_dir} - name of directory where generated files should go
+ -->
+ <target name="generate">
+ <property name="grammar_file" value="${grammar_dir}/${grammar_name}.g"/>
+ <echo message="lpg_exe=${lpg_exe}"/>
+ <echo message="lpg_template=${lpg_template}"/>
+ <echo message="grammar_file=${grammar_file}.g"/>
+ <echo message="output_dir=${output_dir}"/>
+
+ <exec executable="${lpg_exe}">
+ <arg value="${grammar_file}"/>
+ <env key="LPG_TEMPLATE" path="${lpg_template}"/>
+ </exec>
+
+ <move overwrite="true" toDir="${output_dir}">
+ <fileset dir=".">
+ <include name="${grammar_name}*.*"/>
+ </fileset>
+ </move>
+ </target>
+
+
+</project> \ No newline at end of file
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
index f6b679a14a..e5ec6bf4d9 100644
--- 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
@@ -127,8 +127,12 @@ public final class DOMToC99TokenMap implements IDOMTokenMap {
case tFLOATINGPT : return TK_floating;
case tSTRING : return TK_stringlit;
case tLSTRING : return TK_stringlit;
+ case tUTF16STRING : return TK_stringlit;
+ case tUTF32STRING : return TK_stringlit;
case tCHAR : return TK_charconst;
case tLCHAR : return TK_charconst;
+ case tUTF16CHAR : return TK_charconst;
+ case tUTF32CHAR : return TK_charconst;
case t__Bool : return TK__Bool;
case t__Complex : return TK__Complex;
case t__Imaginary : return TK__Imaginary;
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
index a937207c53..19cc66af08 100644
--- 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
@@ -162,8 +162,12 @@ public class DOMToISOCPPTokenMap implements IDOMTokenMap {
case tFLOATINGPT : return TK_floating;
case tSTRING : return TK_stringlit;
case tLSTRING : return TK_stringlit;
+ case tUTF16STRING : return TK_stringlit;
+ case tUTF32STRING : return TK_stringlit;
case tCHAR : return TK_charconst;
case tLCHAR : return TK_charconst;
+ case tUTF16CHAR : return TK_charconst;
+ case tUTF32CHAR : return TK_charconst;
case tCOMPLETION : return TK_Completion;
case tEOC : return TK_EndOfCompletion;
case tEND_OF_INPUT : return TK_EOF_TOKEN;
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGCCTokenMap.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGCCTokenMap.java
index 41832355ad..335b0e5d9b 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGCCTokenMap.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGCCTokenMap.java
@@ -128,8 +128,12 @@ public final class DOMToGCCTokenMap implements IDOMTokenMap {
case tFLOATINGPT : return TK_floating;
case tSTRING : return TK_stringlit;
case tLSTRING : return TK_stringlit;
+ case tUTF16STRING : return TK_stringlit;
+ case tUTF32STRING : return TK_stringlit;
case tCHAR : return TK_charconst;
case tLCHAR : return TK_charconst;
+ case tUTF16CHAR : return TK_charconst;
+ case tUTF32CHAR : return TK_charconst;
case t__Bool : return TK__Bool;
case t__Complex : return TK__Complex;
case t__Imaginary : return TK__Imaginary;
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGPPTokenMap.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGPPTokenMap.java
index 7e64aed939..8ceea4f996 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGPPTokenMap.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/DOMToGPPTokenMap.java
@@ -163,6 +163,10 @@ public class DOMToGPPTokenMap implements IDOMTokenMap {
case tFLOATINGPT : return TK_floating;
case tSTRING : return TK_stringlit;
case tLSTRING : return TK_stringlit;
+ case tUTF16STRING : return TK_stringlit;
+ case tUTF32STRING : return TK_stringlit;
+ case tUTF16CHAR : return TK_charconst;
+ case tUTF32CHAR : return TK_charconst;
case tCHAR : return TK_charconst;
case tLCHAR : return TK_charconst;
case tCOMPLETION : return TK_Completion;

Back to the top