All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.antlr.codegen.templates.Ruby.AST.stg Maven / Gradle / Ivy

There is a newer version: 3.5.3
Show newest version
@parserBody.mixins() ::= <<
<@super.mixins()>
include ANTLR3::ASTBuilder
>>

gatedAction(block) ::= <<

if 
  
end



>>

ruleDeclarations() ::= <<

root_0 = nil<\n>
>>

ruleLabelDefs() ::= <<

<[ruleDescriptor.tokenLabels,ruleDescriptor.wildcardTreeLabels,ruleDescriptor.wildcardTreeListLabels,ruleDescriptor.tokenListLabels]
    :{int |tree_for_ = nil}; separator="\n">
 = ANTLR3::AST::RewriteRuleStream.new( @adaptor, "token " )}; separator="\n">
 = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, "rule " )}; separator="\n">
>>

alt(elements,altNum,description,autoAST,outerAlt,treeLevel,rew) ::= <<

root_0 = @adaptor.create_flat_list<\n><\n>

# at line 

>>

tokenRefTrack(token,label,elementIndex,terminalOptions) ::= <<

.add(  )})>
>>

tokenRefTrackAndListLabel(token,label,elementIndex,terminalOptions) ::= <<

},...)>
>>

tokenRefRuleRootTrack(token,label,elementIndex,terminalOptions) ::= <<

.add(  )})>
>>

tokenRefRuleRootTrackAndListLabel(token,label,elementIndex,terminalOptions) ::= <<


>>

ruleRefTrack(rule,label,elementIndex,args,scope) ::= <<

.add( .tree )})>
>>

ruleRefTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<

.tree},...)>
>>
ruleRefRuleRootTrack(rule,label,elementIndex,args,scope) ::= <<

.add( .tree )})>
>>

ruleRefRuleRootTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<

.tree},...)>
>>


rewriteCode(alts, description,
        referencedElementsDeep, // ALL referenced elements to right of ->
        referencedTokenLabels,
        referencedTokenListLabels,
        referencedRuleLabels,
        referencedRuleListLabels,
        referencedWildcardLabels,
        referencedWildcardListLabels,
        rewriteBlockLevel, enclosingTreeLevel, treeLevel) ::=
<<
# AST Rewrite
# elements: 
# token labels: 
# rule labels: 
# token list labels: 
# rule list labels: 
# wildcard labels: <[referencedWildcardLabels,referencedWildcardListLabels]; separator=", ">
.tree = root_0

root_0 = @adaptor.create_flat_list


}; anchor, separator="\n\n">




.tree = @adaptor.rule_post_processing( root_0 )
@input.replace_children(
  @adaptor.parent( return_value.start ),
  @adaptor.child_index( return_value.start ),
  @adaptor.child_index( _last ),
  return_value.tree
)<\n>





.tree = root_0<\n>


.tree = root_0<\n>


})>
>>

rewriteCodeLabels() ::= <<
 = _stream( "token ",  )};
separator="\n">
 = _stream( "token ", list_of_ )};
separator="\n">
 = subtree_stream( "wildcard ",  )};
separator="\n">
 = subtree_stream( "wildcard ", list_of_ )};
separator="\n">
 =  ? subtree_stream( "rule ", .tree ) : subtree_stream( "token " )};
separator="\n">
 = subtree_stream( "token ", list_of_ )};
separator="\n">
>>

rewriteOptionalBlock(
        alt,rewriteBlockLevel,
        referencedElementsDeep, // all nested refs
        referencedElements, // elements in immediately block; no nested blocks
        description) ::=
<<
# at line 
if .has_next?}; separator=" || ">
  
end

.reset();<\n>}>
>>

rewriteClosureBlock(
        alt,rewriteBlockLevel,
        referencedElementsDeep, // all nested refs
        referencedElements, // elements in immediately block; no nested blocks
        description) ::=
<<
# at line 
while .has_next?}; separator=" || ">
  
end

.reset();<\n>}>
>>

rewritePositiveClosureBlock(
        alt,rewriteBlockLevel,
        referencedElementsDeep, // all nested refs
        referencedElements, // elements in immediately block; no nested blocks
        description) ::=
<<
# at line 
.has_next?}; separator=" || "> or raise ANTLR3::RewriteEarlyExit

while .has_next?}; separator=" || ">
  
end
.reset<\n>}>
>>

rewriteAltRest(a) ::= <<

if 
  # 
  

e
  # 
  
end

>>

rewriteAltFirst(a) ::= <<

if 
  # 
  

# 


>>

rewriteEmptyAlt() ::= "root_0 = nil"

rewriteTree(root,children,description,enclosingTreeLevel,treeLevel) ::= <<
# at line 
root_ = @adaptor.create_flat_list


@adaptor.add_child( root_, root_ )<\n>
>>

rewriteElementList(elements) ::= ""
rewriteElement(e) ::= <<
<@pregen()>

>>

rewriteTokenRef(token,elementIndex,terminalOptions,args) ::= <<
@adaptor.add_child( root_,  )<\n>
>>

rewriteTokenLabelRef(label,elementIndex) ::= <<
@adaptor.add_child( root_, stream_




© 2015 - 2025 Weber Informatics LLC | Privacy Policy