Repository: flex-falcon Updated Branches: refs/heads/falcon-antlr4 59f6373b3 -> a185d7ee1
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a185d7ee/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/ConstantArithmetic.jbg ---------------------------------------------------------------------- diff --git a/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/ConstantArithmetic.jbg b/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/ConstantArithmetic.jbg index b9e1cf4..9db2fb0 100644 --- a/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/ConstantArithmetic.jbg +++ b/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/ConstantArithmetic.jbg @@ -90,22 +90,22 @@ Op_AddID(numeric_constant l, numeric_constant r): 0 constant_value= Op_AddID(constant_value l, constant_value r): 1 // prefer the other addition rules -JBurg.Reduction reducer.reduce_constantAddition(__p, l, r); +@Reduction reducer.reduce_constantAddition(__p, l, r); /* * Specializations for adding strings */ string_constant= Op_AddID(string_constant l, string_constant r):0 -JBurg.Reduction reducer.reduce_constantStringConcatenation(__p, l, r); +@Reduction reducer.reduce_constantStringConcatenation(__p, l, r); string_constant= Op_AddID(string_constant l, constant_value r):0 -JBurg.Reduction reducer.reduce_constantStringConcatenation(__p, l, r); +@Reduction reducer.reduce_constantStringConcatenation(__p, l, r); string_constant= Op_AddID(constant_value l, string_constant r):0 -JBurg.Reduction reducer.reduce_constantStringConcatenation(__p, l, r); +@Reduction reducer.reduce_constantStringConcatenation(__p, l, r); numeric_constant= Op_SubtractID(numeric_constant l, numeric_constant r): 0 http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a185d7ee/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionPatterns.jbg ---------------------------------------------------------------------- diff --git a/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionPatterns.jbg b/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionPatterns.jbg index c10e313..27f74f7 100644 --- a/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionPatterns.jbg +++ b/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionPatterns.jbg @@ -20,9 +20,9 @@ // Prototype patterns for function nodes. // Getter/Setter functions specialize the // pattern with their own node ID. -Pattern typelessFunction +@Pattern typelessFunction FunctionID(IdentifierID(void), parameterList plist, statement block); -Pattern typedFunction +@Pattern typedFunction FunctionID(IdentifierID(void), parameterList plist, return_type_name return_type, statement block); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a185d7ee/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionRules.jbg ---------------------------------------------------------------------- diff --git a/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionRules.jbg b/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionRules.jbg index 14868b0..12f633f 100644 --- a/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionRules.jbg +++ b/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/FunctionRules.jbg @@ -21,16 +21,16 @@ // placed in their own .jbg file so they // can be included in a parameterized fashion. function = Pattern typelessFunction : 0 -Prologue reducer.prologue_function(p) -JBurg.Reduction reducer.generateFunctionBody(__p, block, LexicalScope.anyType); +@Prologue reducer.prologue_function(p) +@Reduction reducer.generateFunctionBody(__p, block, LexicalScope.anyType); function = Pattern typedFunction: 0 -Prologue reducer.prologue_function(p) -JBurg.Reduction reducer.generateFunctionBody(__p, block, return_type); +@Prologue reducer.prologue_function(p) +@Reduction reducer.generateFunctionBody(__p, block, return_type); return_type_name = type_name; // return types can be any type name, or 'void' // void is usually not an allowable type name return_type_name = Pattern voidExpr : 0 -JBurg.Reduction reducer.reduce_voidExpr_to_return_type_name(__p); \ No newline at end of file +@Reduction reducer.reduce_voidExpr_to_return_type_name(__p); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a185d7ee/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/cmc.jbg ---------------------------------------------------------------------- diff --git a/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/cmc.jbg b/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/cmc.jbg deleted file mode 100644 index df5a793..0000000 --- a/compiler/src/main/jburg/org/apache/flex/compiler/internal/as/codegen/cmc.jbg +++ /dev/null @@ -1,245 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.flex.compiler.internal.as.codegen; - -header -{ - import org.apache.flex.compiler.problems.ICompilerProblem; - import org.apache.flex.compiler.problems.*; - import org.apache.flex.compiler.exceptions.BURMAbortException; - - import static org.apache.flex.abc.ABCConstants.*; - - import org.apache.flex.abc.semantics.Label; - import org.apache.flex.abc.semantics.Name; - import org.apache.flex.abc.semantics.Namespace; - import org.apache.flex.abc.semantics.ECMASupport; - import org.apache.flex.abc.instructionlist.InstructionList; - - import org.apache.flex.compiler.constants.IASLanguageConstants; - - import org.apache.flex.compiler.tree.ASTNodeID; - import static org.apache.flex.compiler.tree.ASTNodeID.*; - - import org.apache.flex.compiler.internal.semantics.SemanticUtils; - - import org.apache.flex.compiler.tree.as.IASNode; - import org.apache.flex.compiler.tree.as.ITryNode; - -} - -INodeType IASNode; -OpcodeType ASTNodeID; - -/* - * The I-node type is IASNode, and it has its own adapter. - */ -INodeAdapter org.apache.flex.compiler.internal.as.codegen.IASNodeAdapter; - -// Generate Java output. -Language java; - -ReturnType InstructionList; - -/* - * A Name built for a declaration, such as the name for 'x' in: - * var x : Foo; - * A declaration name can just be a simple AET Name, as there is no need to resolve - * it or do anything else to figure out what Name to use. - */ -ReturnType decl_name = Name; - -/** - * This is a name to use in an expression context. It is a Binding - * as the Binding will also hold additional information like did the expression - * resolve to anything, and if so what did it resolve to. In an expression context - * we will always need that information. - */ -ReturnType name = Binding; - -/** - * Qualified name - this acts the same as a name above, but is built a little differently. - */ -ReturnType qualifiedName = Binding; -ReturnType qualifiedNamePart = String; - -/** - * This is a name used in a type annotation context, such as 'Foo' in: - * var x : Foo; - * It is a Binding, as type annotations must always be resolved. - * A type_name also allows '*', which can't happen in a general expression context. - */ -ReturnType type_name = Binding; - -/** - * Name of a return type from a function signature. - * It is the same as a type_name, above, except it also allows 'void', which is not usually allowed as a type_name - */ -ReturnType return_type_name = Binding; - -/** - * This is a name used in a new context, such as 'Foo' in: - * new Foo(); - * We can do additional analysis when the new expression resolves to a Type, which - * is why we have a special name for the new expression. - */ -ReturnType new_type_name = Binding; - -ReturnType dottedNamePart = String; - -ReturnType conditionalElements = ABCGeneratingReducer.ConditionalFragment; - -ReturnType ifElseIf = ABCGeneratingReducer.ConditionalFragment; - -ReturnType catch_block = ABCGeneratingReducer.CatchPrototype; - -ReturnType integer_constant = Integer; -ReturnType uint_constant = Long; -ReturnType double_constant = Double; -ReturnType string_constant = String; -ReturnType boolean_constant = Boolean; - -ReturnType numeric_constant = Number; - -ReturnType constant_value = Object; -ReturnType required_constant_value = Object; - -ReturnType non_resolving_identifier = String; - -ReturnType runtime_name_expression = ABCGeneratingReducer.RuntimeMultiname; -ReturnType multinameL = Name; -ReturnType stmt_label = String; -ReturnType e4x_literal = String; - -JBurg.Constant ERROR_TRAP = 268435456; - -{ - final static boolean NEED_VALUE = true; - final static boolean DISCARD_VALUE = false; - - - /** - * The reducer has all the implementation - * logic for the rewrite; the BURM constructed - * by this specification drives that logic. - */ - ABCGeneratingReducer reducer; - - /** - * Delegate calls to pushNumericConstant to the reducer. - * This routine is called from other parts of the code generator, - * so it's necessary to keep this layer of indirection. - */ - public static void pushNumericConstant(long value, InstructionList result_list) - { - ABCGeneratingReducer.pushNumericConstant(value, result_list); - } - - /* - * ** Cost functions ** - */ - - - /** - * @return "feasible" if the reducer can reduce this to a dotted name. - */ - int isDottedName(IASNode iNode) - { - return reducer.isDottedName(iNode); - } - - /** - * @return "feasible" if the reducer can reduce this to a package name. - */ - int isPackageName(IASNode iNode) - { - return reducer.isPackageName(iNode); - } - - /** - * @return "feasible" if this node's qualifier is a compile-time constant. - */ - int qualifierIsCompileTimeConstant(IASNode iNode) - { - return reducer.qualifierIsCompileTimeConstant(iNode); - } - - /** - * @return "feasible" if this node can be resolved to a compile-time constant. - */ - int isCompileTimeConstant(IASNode iNode) - { - return reducer.isCompileTimeConstant(iNode); - } - - /** - * @return "feasible" if this node is for 'new Array()'. - */ - int isEmptyArrayConstructor(IASNode iNode) - { - return reducer.isEmptyArrayConstructor(iNode); - } - - /** - * @return "feasible" if this node is for 'new Object()'. - */ - int isEmptyObjectConstructor(IASNode iNode) - { - return reducer.isEmptyObjectConstructor(iNode); - } - - /** - * @return "feasible" if this node is "super(this)". - */ - int isSuperThisForFieldAccess(IASNode iNode) - { - return SemanticUtils.isSuperThisForFieldAccess(iNode); - } - - /** - * recordError is a convenience method for error reductions; - * it adds a problem to the current set of problems and - * returns an empty InstructionList. - * @return an empty InstructionList. - */ - InstructionList recordError(ICompilerProblem problem) - { - reducer.getProblems().add(problem); - return new InstructionList(); - } -} - -/* - * Error recovery routine: deduce what we can from the problem - * tree, then abort this BURM with an exception that the caller - * can catch and ignore. - */ -DefaultErrorHandler -{ - new UnknownTreeHandler(reducer.getProblems()).analyze(p); - BURMAbortException.abort(); -} - -/* - * Patterns and rules are stored in their own, shareable file. - */ -JBurg.include "CmcPatterns.jbg" -JBurg.include "CmcRules.jbg" -JBurg.include "SemanticErrors.jbg" http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a185d7ee/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSEmitter.jbg ---------------------------------------------------------------------- diff --git a/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSEmitter.jbg b/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSEmitter.jbg new file mode 100644 index 0000000..2192128 --- /dev/null +++ b/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSEmitter.jbg @@ -0,0 +1,57 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +@package org.apache.flex.compiler.internal.css.codegen; +@Language java; + +@Header +{ + import static org.apache.flex.abc.ABCConstants.*; + import static org.apache.flex.compiler.internal.css.CSSModelTreeType.*; + + import org.apache.flex.compiler.css.*; + import org.apache.flex.compiler.internal.css.*; + + import org.apache.flex.abc.semantics.*; + import org.apache.flex.abc.instructionlist.InstructionList; + import org.apache.flex.compiler.internal.css.codegen.Pair.*; +} + +@INodeType ICSSNode; + +@INodeAdapter jburg.burg.inode.DefaultAdapter; + +@OpcodeType CSSModelTreeType; + +@ReturnType PairOfInstructionLists; +@ReturnType selector = InstructionListAndString; +@ReturnType selectorGroup = InstructionListAndClosure; +@ReturnType rule = InstructionListAndClosure; + +{ + public CSSEmitter(final CSSReducer reducer) + { + this.reducer = reducer; + } + + private final CSSReducer reducer; +} + +@include "CSSPatterns.jbg" +@include "CSSRules.jbg" http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a185d7ee/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSPatterns.jbg ---------------------------------------------------------------------- diff --git a/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSPatterns.jbg b/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSPatterns.jbg index 66c9a43..7608223 100644 --- a/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSPatterns.jbg +++ b/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSPatterns.jbg @@ -41,42 +41,42 @@ ) --------------------------------------------------------------------------*/ -Pattern document +@Pattern document DOCUMENT (namespaceList namespaceList, fontFaceList fontFaceList, ruleList ruleList); -Pattern namespaceList +@Pattern namespaceList NAMESPACE_LIST (namespaceDefinition namespaces*); -Pattern namespaceDefinition +@Pattern namespaceDefinition NAMESPACE_DEFINITION (void); -Pattern ruleList +@Pattern ruleList RULE_LIST (rule rules*); -Pattern rule +@Pattern rule RULE (selectorGroup selectorGroup, mediaQuery mediaQuery, propertyList propertyList); -Pattern selectorGroup +@Pattern selectorGroup SELECTOR_GROUP (selector selectors*); -Pattern selector +@Pattern selector SELECTOR (void); -Pattern propertyList +@Pattern propertyList PROPERTY_LIST (property properties*); -Pattern property +@Pattern property PROPERTY (void); -Pattern mediaQuery +@Pattern mediaQuery MEDIA_QUERY (mediaQueryCondition conditions*); -Pattern mediaQueryCondition +@Pattern mediaQueryCondition MEDIA_QUERY_CONDITION (void); -Pattern fontFaceList +@Pattern fontFaceList FONT_FACE_LIST (fontFace fontFaces*); -Pattern fontFace +@Pattern fontFace FONT_FACE (void); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a185d7ee/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSRules.jbg ---------------------------------------------------------------------- diff --git a/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSRules.jbg b/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSRules.jbg index 7ce48f6..27580f1 100644 --- a/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSRules.jbg +++ b/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/CSSRules.jbg @@ -17,41 +17,41 @@ * */ -document = Pattern document : 1 -JBurg.Reduction reducer.reduceDocument(__p, namespaceList, ruleList); +document = DOCUMENT (namespaceList namespaceList, fontFaceList fontFaceList, ruleList ruleList) : 1 +@Reduction reducer.reduceDocument(__p, namespaceList, ruleList); -namespaceList = Pattern namespaceList : 1 -JBurg.Reduction reducer.reduceNamespaceList(__p, namespaces); +namespaceList = NAMESPACE_LIST (namespaceDefinition namespaces*) : 1 +@Reduction reducer.reduceNamespaceList(__p, namespaces); -namespaceDefinition = Pattern namespaceDefinition : 1 -JBurg.Reduction reducer.reduceNamespaceDefinition(__p); +namespaceDefinition = NAMESPACE_DEFINITION (void) : 1 +@Reduction reducer.reduceNamespaceDefinition(__p); -ruleList = Pattern ruleList : 1 -JBurg.Reduction reducer.reduceRuleList(__p, rules); +ruleList = RULE_LIST (rule rules*) : 1 +@Reduction reducer.reduceRuleList(__p, rules); -rule = Pattern rule : 1 -JBurg.Reduction reducer.reduceRule(__p, selectorGroup, propertyList); +rule = RULE (selectorGroup selectorGroup, mediaQuery mediaQuery, propertyList propertyList) : 1 +@Reduction reducer.reduceRule(__p, selectorGroup, propertyList); -selectorGroup = Pattern selectorGroup : 1 -JBurg.Reduction reducer.reduceSelectorGroup(__p, selectors); +selectorGroup = SELECTOR_GROUP (selector selectors*) : 1 +@Reduction reducer.reduceSelectorGroup(__p, selectors); -selector = Pattern selector : 1 -JBurg.Reduction reducer.reduceSelector(__p); +selector = SELECTOR (void) : 1 +@Reduction reducer.reduceSelector(__p); -propertyList = Pattern propertyList : 1 -JBurg.Reduction reducer.reducePropertyList(__p, properties); +propertyList = PROPERTY_LIST (property properties*) : 1 +@Reduction reducer.reducePropertyList(__p, properties); -property = Pattern property : 1 -JBurg.Reduction reducer.reduceProperty(__p); +property = PROPERTY (void) : 1 +@Reduction reducer.reduceProperty(__p); -mediaQuery = Pattern mediaQuery : 1 -JBurg.Reduction reducer.reduceMediaQuery(__p, conditions); +mediaQuery = MEDIA_QUERY (mediaQueryCondition conditions*) : 1 +@Reduction reducer.reduceMediaQuery(__p, conditions); -mediaQueryCondition = Pattern mediaQueryCondition : 1 -JBurg.Reduction reducer.reduceMediaQueryCondition(__p); +mediaQueryCondition = MEDIA_QUERY_CONDITION (void) : 1 +@Reduction reducer.reduceMediaQueryCondition(__p); -fontFaceList = Pattern fontFaceList : 1 -JBurg.Reduction reducer.reduceFontFaceList(__p, fontFaces); +fontFaceList = FONT_FACE_LIST (fontFace fontFaces*) : 1 +@Reduction reducer.reduceFontFaceList(__p, fontFaces); -fontFace = Pattern fontFace : 1 -JBurg.Reduction reducer.reduceFontFace(__p); \ No newline at end of file +fontFace = FONT_FACE (void) : 1 +@Reduction reducer.reduceFontFace(__p); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a185d7ee/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/css.jbg ---------------------------------------------------------------------- diff --git a/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/css.jbg b/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/css.jbg deleted file mode 100644 index f5548aa..0000000 --- a/compiler/src/main/jburg/org/apache/flex/compiler/internal/css/codegen/css.jbg +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.flex.compiler.internal.css.codegen; - -header -{ - import static org.apache.flex.abc.ABCConstants.*; - import static org.apache.flex.compiler.internal.css.CSSModelTreeType.*; - - import org.apache.flex.compiler.css.*; - import org.apache.flex.compiler.internal.css.*; - - import org.apache.flex.abc.semantics.*; - import org.apache.flex.abc.instructionlist.InstructionList; - import org.apache.flex.compiler.internal.css.codegen.Pair.*; -} - -INodeType ICSSNode; - -INodeAdapter jburg.burg.inode.DefaultAdapter; - -OpcodeType CSSModelTreeType; - -Language java; - -ReturnType PairOfInstructionLists; -ReturnType selector = InstructionListAndString; -ReturnType selectorGroup = InstructionListAndClosure; -ReturnType rule = InstructionListAndClosure; - -{ - public CSSEmitter(final CSSReducer reducer) - { - this.reducer = reducer; - } - - private final CSSReducer reducer; -} - -JBurg.include "CSSPatterns.jbg" -JBurg.include "CSSRules.jbg"