Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2009-04-17 18:52:09 +0000
committerMike Kucera2009-04-17 18:52:09 +0000
commitcb8fe367dd2c4ffeda055c5d5ba1ad16f2640903 (patch)
tree46b97d413bfc5e849988c92d7489fe2790755392 /xlc/org.eclipse.cdt.core.lrparser.xlc/grammar
parente8477ef98a4319989eea988aa1184d9e47f0b7ac (diff)
downloadorg.eclipse.cdt-cb8fe367dd2c4ffeda055c5d5ba1ad16f2640903.tar.gz
org.eclipse.cdt-cb8fe367dd2c4ffeda055c5d5ba1ad16f2640903.tar.xz
org.eclipse.cdt-cb8fe367dd2c4ffeda055c5d5ba1ad16f2640903.zip
[272745] initial commit of XLC parser extensions
Diffstat (limited to 'xlc/org.eclipse.cdt.core.lrparser.xlc/grammar')
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/build.xml49
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcCPPParser.g60
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcCParser.g67
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcGrammarExtensions.g82
4 files changed, 258 insertions, 0 deletions
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/build.xml b/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/build.xml
new file mode 100644
index 00000000000..99a4603a956
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/build.xml
@@ -0,0 +1,49 @@
+<!--
+ 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="XLC Parsers" default="c" basedir=".">
+
+ <import file="../../org.eclipse.cdt.core.lrparser/grammar/generate.xml"/>
+
+ <property name="c_location" value="../parser/org/eclipse/cdt/internal/core/lrparser/xlc/c"/>
+ <property name="cpp_location" value="../parser/org/eclipse/cdt/internal/core/lrparser/xlc/cpp"/>
+
+
+ <target name="c">
+ <antcall target="generate_c">
+ <param name="grammar_name" value="XlcCParser"/>
+ </antcall>
+ </target>
+
+ <target name="cpp">
+ <antcall target="generate_cpp">
+ <param name="grammar_name" value="XlcCPPParser"/>
+ </antcall>
+ </target>
+
+
+ <target name="generate_c">
+ <antcall target="generate">
+ <param name="grammar_dir" value="xlc"/>
+ <param name="output_dir" value="${c_location}"/>
+ <param name="grammar_name" value="${grammar_name}"/>
+ </antcall>
+ </target>
+
+ <target name="generate_cpp">
+ <antcall target="generate">
+ <param name="grammar_dir" value="xlc"/>
+ <param name="output_dir" value="${cpp_location}"/>
+ <param name="grammar_name" value="${grammar_name}"/>
+ </antcall>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcCPPParser.g b/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcCPPParser.g
new file mode 100644
index 00000000000..9e57880a5f5
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcCPPParser.g
@@ -0,0 +1,60 @@
+-----------------------------------------------------------------------------------
+-- 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
+-----------------------------------------------------------------------------------
+
+%options la=2
+%options package=org.eclipse.cdt.internal.core.lrparser.xlc.cpp
+%options template=LRParserTemplate.g
+
+
+$Import
+ GPPGrammar.g
+$End
+
+$Import
+ XlcGrammarExtensions.g
+$End
+
+$Globals
+/.
+ import org.eclipse.cdt.core.lrparser.xlc.action.XlcCPPBuildASTParserAction;
+ import org.eclipse.cdt.core.dom.lrparser.action.gnu.GPPSecondaryParserFactory;
+ import org.eclipse.cdt.internal.core.lrparser.xlc.ast.XlcCPPNodeFactory;
+./
+$End
+
+$Define
+
+ $build_action_class /. XlcCPPBuildASTParserAction ./
+ $parser_factory_create_expression /. GPPSecondaryParserFactory.getDefault() ./
+ $node_factory_create_expression /. XlcCPPNodeFactory.getDefault() ./
+
+$End
+
+$Start
+ translation_unit
+$End
+
+$Rules
+
+block_declaration
+ ::= vector_declaration
+
+
+identifier_token
+ ::= 'vector'
+ | 'pixel'
+
+
+specifier_qualifier
+ ::= 'typedef'
+ /. $Build consumeToken(); $EndBuild ./
+
+$End \ No newline at end of file
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcCParser.g b/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcCParser.g
new file mode 100644
index 00000000000..a6c7ae9669a
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcCParser.g
@@ -0,0 +1,67 @@
+-----------------------------------------------------------------------------------
+-- 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
+-----------------------------------------------------------------------------------
+
+%options la=2
+%options package=org.eclipse.cdt.internal.core.lrparser.xlc.c
+%options template=LRParserTemplate.g
+
+
+$Import
+ GCCGrammar.g
+$End
+
+$Import
+ XlcGrammarExtensions.g
+$End
+
+
+$Globals
+/.
+ import org.eclipse.cdt.core.lrparser.xlc.action.XlcCBuildASTParserAction;
+ import org.eclipse.cdt.core.dom.lrparser.action.gnu.GCCSecondaryParserFactory;
+ import org.eclipse.cdt.internal.core.lrparser.xlc.ast.XlcCNodeFactory;
+./
+$End
+
+
+$Define
+
+ $build_action_class /. XlcCBuildASTParserAction ./
+ $parser_factory_create_expression /. GCCSecondaryParserFactory.getDefault() ./
+ $node_factory_create_expression /. XlcCNodeFactory.getDefault() ./
+
+$End
+
+
+$Start
+ translation_unit
+$End
+
+
+$Rules
+
+declaration
+ ::= vector_declaration
+
+identifier_token
+ ::= 'pixel'
+ | 'vector'
+ | 'bool'
+
+declarator_id_name
+ ::= 'pixel'
+ /. $Build consumeIdentifierName(); $EndBuild ./
+ | 'vector'
+ /. $Build consumeIdentifierName(); $EndBuild ./
+ | 'bool'
+ /. $Build consumeIdentifierName(); $EndBuild ./
+
+$End \ No newline at end of file
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcGrammarExtensions.g b/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcGrammarExtensions.g
new file mode 100644
index 00000000000..d1bc86b3702
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/grammar/xlc/XlcGrammarExtensions.g
@@ -0,0 +1,82 @@
+-----------------------------------------------------------------------------------
+-- 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
+-----------------------------------------------------------------------------------
+
+
+-- These are additional rules that allow for parsing of GNU extensions.
+-- This file is intended to be mixed-in with C99Parser.g or GPPParser.g
+
+
+$Terminals
+
+ vector
+ pixel
+ bool
+
+$End
+
+
+
+
+
+$Rules
+
+type_id
+ ::= vector_type
+ /. $Build consumeTypeId(false); $EndBuild ./
+ | vector_type abstract_declarator
+ /. $Build consumeTypeId(true); $EndBuild ./
+
+vector_declaration
+ ::= vector_type <openscope-ast> init_declarator_list ';'
+ /. $Build consumeDeclarationSimple(true); $EndBuild ./
+
+
+vector_type
+ ::= <openscope-ast> no_type_declaration_specifiers_opt 'vector' vector_type_specifier all_specifier_qualifier_list_opt
+ /. $Build consumeVectorTypeSpecifier(); $EndBuild ./
+
+
+vector_type_specifier
+ ::= vector_type_specifier_token
+ /. $Build consumeToken(); $EndBuild ./
+
+vector_type_specifier_token
+ ::= 'pixel'
+ | 'float'
+ | 'bool'
+ | 'signed'
+ | 'unsigned'
+ | 'char'
+ | 'short'
+ | 'int'
+ | 'long'
+
+
+
+all_specifier_qualifiers
+ ::= vector_type_specifier
+ | no_type_declaration_specifiers
+
+all_specifier_qualifier_list
+ ::= all_specifier_qualifiers
+ | all_specifier_qualifier_list all_specifier_qualifiers
+
+all_specifier_qualifier_list_opt
+ ::= all_specifier_qualifier_list
+ | $empty
+
+no_type_declaration_specifiers_opt
+ ::= no_type_declaration_specifiers
+ | $empty
+
+
+$End
+

Back to the top