@Override protected IdentifierNode copy() { return new IdentifierNode(this); }
@Override protected IdentifierNode copy() { return new IdentifierNode(this); }
/** * Returns a typed expression that represents the signature of this Vector * * @return a {@link TypedExpressionNode} */ public TypedExpressionNode toTypedExpression() { if (elementType instanceof AppliedVectorDefinition) { return new TypedExpressionNode(new IdentifierNode(IASLanguageConstants.Vector), ((AppliedVectorDefinition)elementType).toTypedExpression()); } return new TypedExpressionNode(new IdentifierNode(IASLanguageConstants.Vector), new IdentifierNode(elementType.getBaseName())); }
/** * Returns a typed expression that represents the signature of this Vector * * @return a {@link TypedExpressionNode} */ public TypedExpressionNode toTypedExpression() { if (elementType instanceof AppliedVectorDefinition) { return new TypedExpressionNode(new IdentifierNode(IASLanguageConstants.Vector), ((AppliedVectorDefinition)elementType).toTypedExpression()); } return new TypedExpressionNode(new IdentifierNode(IASLanguageConstants.Vector), new IdentifierNode(elementType.getBaseName())); }
/** * Returns the expression that represents the value of this vector * * @return an expression that represents the value of this vector */ public ExpressionNodeBase toExpression() { if (elementType instanceof AppliedVectorDefinition) { return new TypedExpressionNode(new IdentifierNode(IASLanguageConstants.Vector), ((AppliedVectorDefinition)elementType).toExpression()); } return new IdentifierNode(elementType.getBaseName()); }
/** * Returns the expression that represents the value of this vector * * @return an expression that represents the value of this vector */ public ExpressionNodeBase toExpression() { if (elementType instanceof AppliedVectorDefinition) { return new TypedExpressionNode(new IdentifierNode(IASLanguageConstants.Vector), ((AppliedVectorDefinition)elementType).toExpression()); } return new IdentifierNode(elementType.getBaseName()); }
protected final IdentifierNode build(Token token) { IdentifierNode name = new IdentifierNode(getText(token)); name.span(token); return name; }
/** * Builds an ImportNode for a qname. */ public static ImportNode buildImportNode(String qname) { Deque<IASNode> nodeList = new LinkedList<IASNode>(); for (String s : qname.split("\\.")) { nodeList.add(new IdentifierNode(s)); } IASToken dotToken = new ASToken(ASTokenTypes.TOKEN_OPERATOR_MEMBER_ACCESS, -1, -1, -1, -1, "."); while (nodeList.size() > 1) { ExpressionNodeBase first = (ExpressionNodeBase)nodeList.removeFirst(); ExpressionNodeBase second = (ExpressionNodeBase)nodeList.removeFirst(); nodeList.addFirst(new FullNameNode(first, dotToken, second)); } ImportNode importNode = new ImportNode((ExpressionNodeBase)nodeList.getFirst()); return importNode; }
protected final IdentifierNode build(Token token) { IdentifierNode name = new IdentifierNode(getText(token)); name.span(token); return name; }
/** * Builds an ImportNode for a qname. */ public static ImportNode buildImportNode(String qname) { Deque<IASNode> nodeList = new LinkedList<IASNode>(); for (String s : qname.split("\\.")) { nodeList.add(new IdentifierNode(s)); } IASToken dotToken = new ASToken(ASTokenTypes.TOKEN_OPERATOR_MEMBER_ACCESS, -1, -1, -1, -1, "."); while (nodeList.size() > 1) { ExpressionNodeBase first = (ExpressionNodeBase)nodeList.removeFirst(); ExpressionNodeBase second = (ExpressionNodeBase)nodeList.removeFirst(); nodeList.addFirst(new FullNameNode(first, dotToken, second)); } ImportNode importNode = new ImportNode((ExpressionNodeBase)nodeList.getFirst()); return importNode; }
/** * Create a dummy {@code IdentifierNode} after the given token. This is used * to repair the AST where an identifier node is expected. * * @param token The empty ID node will have start offset following this * token. * @return Dummy identifier node. */ public static IdentifierNode createEmptyIdentifierNodeAfterToken(final Token token) { final IdentifierNode result = new IdentifierNode(""); result.startAfter(token); result.endAfter(token); return result; }
/** * Create a dummy {@code IdentifierNode} after the given token. This is used * to repair the AST where an identifier node is expected. * * @param token The empty ID node will have start offset following this * token. * @return Dummy identifier node. */ public static IdentifierNode createEmptyIdentifierNodeAfterToken(final Token token) { final IdentifierNode result = new IdentifierNode(""); result.startAfter(token); result.endAfter(token); return result; }
@Override protected void ensureTypeNode() { if (typeNode == null && isRest()) { typeNode = new IdentifierNode(IASLanguageConstants.Array); typeNode.span(-1, -1, -1, -1); return; } super.ensureTypeNode(); }
@Override protected void ensureTypeNode() { if (typeNode == null && isRest()) { typeNode = new IdentifierNode(IASLanguageConstants.Array); typeNode.span(-1, -1, -1, -1); return; } super.ensureTypeNode(); }
/** * Build an AST to represent the embedded asset class * * @param problems The collection of compiler problems to which this method will add problems. * @param filename The path to the file being embedded. * @return generated class AST */ public FileNode buildAST(Collection<ICompilerProblem> problems, String filename) { FileNode fileNode = new FileNode(workspace, filename); PackageNode packageNode = new PackageNode(new IdentifierNode(""), null); fileNode.addItem(packageNode); ScopedBlockNode contents = packageNode.getScopedNode(); ImportNode importNode = ImportNode.buildImportNode(getBaseClassQName()); contents.addItem(importNode); ClassNode classNode = new ClassNode(new IdentifierNode(data.getQName())); classNode.setBaseClass(new IdentifierNode(getBaseClassName())); classNode.setNamespace(new NamespaceIdentifierNode(INamespaceConstants.public_)); contents.addItem(classNode); fileNode.runPostProcess(EnumSet.of(PostProcessStep.POPULATE_SCOPE)); return fileNode; }
/** * Matches a "config namespace foo" directive. */ public final void configNamespace( ContainerNode c ) throws RecognitionException, TokenStreamException { Token configN = null; try { // for error handling match(TOKEN_RESERVED_WORD_CONFIG); match(TOKEN_RESERVED_WORD_NAMESPACE); configN = LT(1); match(TOKEN_IDENTIFIER); NamespaceNode cNode = new ConfigNamespaceNode(new IdentifierNode((ASToken)configN)); addConditionalCompilationNamespace(cNode); matchOptionalSemicolon(); } catch (RecognitionException ex) { handleParsingError(ex); } }
/** * Matches a "config namespace foo" directive. */ public final void configNamespace( ContainerNode c ) throws RecognitionException, TokenStreamException { Token configN = null; try { // for error handling match(TOKEN_RESERVED_WORD_CONFIG); match(TOKEN_RESERVED_WORD_NAMESPACE); configN = LT(1); match(TOKEN_IDENTIFIER); NamespaceNode cNode = new ConfigNamespaceNode(new IdentifierNode((ASToken)configN)); addConditionalCompilationNamespace(cNode); matchOptionalSemicolon(); } catch (RecognitionException ex) { handleParsingError(ex); } }
/** * Similar to "configCondition", only that the token type after "::" is * "TOKEN_NAMESPACE_ANNOTATION". This rule only applies to "attributed * definitions". */ public final boolean configConditionOfDefinition() throws RecognitionException, TokenStreamException { boolean result; Token ns = null; Token op = null; Token id = null; result = false; ns = LT(1); match(TOKEN_NAMESPACE_NAME); op = LT(1); match(TOKEN_OPERATOR_NS_QUALIFIER); id = LT(1); match(TOKEN_NAMESPACE_ANNOTATION); result = evaluateConfigurationVariable(new NamespaceIdentifierNode((ASToken)ns), (ASToken) op, new IdentifierNode((ASToken)id)); return result; }
/** * Similar to "configCondition", only that the token type after "::" is * "TOKEN_NAMESPACE_ANNOTATION". This rule only applies to "attributed * definitions". */ public final boolean configConditionOfDefinition() throws RecognitionException, TokenStreamException { boolean result; Token ns = null; Token op = null; Token id = null; result = false; ns = LT(1); match(TOKEN_NAMESPACE_NAME); op = LT(1); match(TOKEN_OPERATOR_NS_QUALIFIER); id = LT(1); match(TOKEN_NAMESPACE_ANNOTATION); result = evaluateConfigurationVariable(new NamespaceIdentifierNode((ASToken)ns), (ASToken) op, new IdentifierNode((ASToken)id)); return result; }
/** * Matches a config condition such as "CONFIG::debug". This rule only applies * to blocks gated with configuration variable. * * @return Evaluated result of the configuration variable. */ public final boolean configCondition() throws RecognitionException, TokenStreamException { boolean result; Token ns = null; Token op = null; Token id = null; result = false; ns = LT(1); match(TOKEN_NAMESPACE_NAME); op = LT(1); match(TOKEN_OPERATOR_NS_QUALIFIER); id = LT(1); match(TOKEN_IDENTIFIER); result = evaluateConfigurationVariable(new NamespaceIdentifierNode((ASToken)ns), (ASToken) op, new IdentifierNode((ASToken)id)); return result; }