[silver:compiler:extension:convenienceaspects]

Contents of [silver:compiler:extension:convenienceaspects]:

Defined in this grammar:

nonterminal ConvenienceAspectEquationKind

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/ConcreteSyntax.sv line 12.

A nonterminal describing what binding to use on the attribute in the generated aspects.


nonterminal ConvAspectLHS

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/ConcreteSyntax.sv line 49.

Nonterminal for the name and type of the term for which you’re constructing aspect productions for.


concrete production convenienceAspects_c   (top::AGDcl ::= 'aspect' attr::QNameAttrOccur 'on' aspectLHS::ConvAspectLHS eqKind::ConvenienceAspectEquationKind 'of' Opt_Vbar_t ml::MRuleList 'end' ';' )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/ConcreteSyntax.sv line 75.

Takes in the following:

  • attr: The attribute you’re defining aspect productions for.
  • aspectLHS: the type for your aspect productions, as well as a custom name for if you define it.
  • eqKind: The binding method for defining the new attribute within the generated aspect productions.
  • ml: A List of MatchRules that describe the aspects productions you’d like to make.

And returns a a single AgDcl defining all the aspect productions according to the parameters given. This is the concrete syntax for defining convenience aspects.


fun makePatternListFromListofPatterns   (PatternList ::= l::[Pattern] )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 10.

Parameter l
the list of patterns to modify
Return
A patternList List-Like Nonterminal instance.

From a list of Patterns, makes a PatternList with the right list-shaped productions.


function collectPatternsFromPatternList   ([Pattern] ::= l::PatternList accum::[Pattern] )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 25.

Parameter l
The next patternList element to extract out patterns from.
Parameter accum
The accumulating list of patterns.
Return
A list containing the patterns From a PatternList, makes a proper list of the patterns in them.

fun extractSubPatternListsFromProdPatterns   (PatternList ::= pl::PatternList )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 43.

WARNING!
Note that the subpatterns being extracted here are only applications of productions.
Parameter pl
The patternList List-like construct we’re extracting subpatterns from.
Return
A patternList List-like construct containing only the subpatterns of the list that was provided.

Extracts out the subpatterns of productions in a patternList, but in a way that doesn’t demand attributes.


fun makeExprsFromExprList   (Exprs ::= l::[Expr] )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 61.

Parameter l
A list of Expr’s.
Return
A combined Exprs List-like construct made from the Expr’s in the input list.

Takes in a regular list of Expr, turns them into an instance of the Exprs production.


fun makeMRuleListFromListMatchRules   (MRuleList ::= l::[MatchRule] )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 75.

Parameter l
A list of match rules.
Return
A MRuleList list-like construct from the list of match rules.

Takes in a regular list of MatchRule, turns them into an instance of the MRuleList production.


function collectMatchRulesfromMRuleList   ([MatchRule] ::= l::MRuleList accum::[MatchRule] )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 87.

Parameter l
A List-like construct MRuleList instance.
Parameter accum
An accumulated list of MatchRule’s
Return
A regular list of MatchRule’s

Given a MRuleList element, transforms it into a regular list of MatchRules


function makeGeneratedNamesFromMatchRule   ([Name] ::= mr::MatchRule )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 102.

Parameter mr
An instance of MatchRule
Return
A list of names where each name corresponds to an argument to the production subpattern.

This function goes into a production pattern (if it is one), extracts out the sub pattern for that production, and generates names for each element of that sub pattern. e.g Given silver_matchRule {foo(bar(3,x),y) -> y+1 } where foo,bar are productions, it returns [_gen1,_gen2] (where the numbers are generated from genInt)


function makeWildcardsFromMatchRule   (PatternList ::= mr::MatchRule )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 127.

Parameter mr
An instance of MatchRule
Return
A wildcard matchRule with the same number of params as the production pattern.

This function goes into a production pattern (if it is one), extracts out the sub pattern for that production, and generates wildcard patterns for each param, giving back a production pattern with the appropriate number of wildcards.


fun makeDefinitionLHSFromName   (DefLHS ::= name::Name )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 150.

Parameter name
The name being defined.
Return
a concrete definition LHS element that uses the name provided.

This function takes in a name and returns a concrete definition LHS element that is the result of applying the concrete definition production to them.


fun makeLetExprForTopRenaming   (Expr ::= newName::Name aspectLHS::Decorated ConvAspectLHS e::Expr )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 161.

Parameter newName
The name being defined.
Parameter aspectLHS
a convenience aspect LHS expression that contains the name and type of the term that our generated aspect production returns.
Parameter e
The expression that uses the name we’re defining and will be surrounded by let.
Return
A Let expr that binds the name we provide to the “top” term in our aspect production with let, and surrounds the expression we gave.

This function takes in a name, aspectRHS, and expr, returning a let expression that binds the name we provide to the name of the “top” term in our aspect production. This allows one to define convenience aspects that make use of variable named wildcards, and have those names be usable in our convenience aspect definition to access other attributes of the top level term.


function extractAspectAgDclFromRuleList   (Pair<AGDcl [Message]> ::= rules::[MatchRule] aspectLHS::Decorated ConvAspectLHS aspectAttr::QNameAttrOccur eqKind::ConvenienceAspectEquationKind env::Env )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 198.

Parameter rules
A list of matchrules that represents a grouping of match rules with similar patterns.
Parameter aspectLHS
a convenience aspect LHS expression that contains the name and type of the term that our generated aspect production returns.
Parameter aspectAttr
The aspect attribute we’re generating productions for
Parameter eqKind
The operator that assigns or binds to the attribute
Parameter env
A Environment for looking up production types.
Return
A pair of a single AgDcl that defines the aspect production we’re generating, and a list of warnings or errors that came from generating the AgDcl.

function eqProdNamePattern   (Boolean ::= l::Pattern r::Pattern )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 368.

Parameter l
first pattern we’re comparing
Parameter r
second pattern we’re comparing
Return
boolean telling us if two production patterns have the same name, otherwise compares the kind of pattern.

Compares patterns, if they’re both production patterns, compares production name otherwise compares the kind of pattern, (varname or wildcard, mostly). As a note, patterns with kinds other than varPattern,Wildcard, or prodAppPattern compare favorably with eachother even if they dont have the same kind, as this function is intended to sort patterns for convenience aspect purposes.


function extractHeadPatternFromPatternList   (Pattern ::= pList::PatternList )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 392.

WARNING!
throws an error if the pattern list is nil.
Parameter pList
a PatternList construct
Return
The head pattern from the given PatternList

Extracts out the head pattern from the given PatternList.


function extractHeadPatternFromMatchRule   (Pattern ::= mRule::MatchRule )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 410.

Parameter mRule
a MatchRule construct
Return
The head pattern from the given MatchRule

Extracts out the head pattern from the given matchRule.


fun eqHeadPatternMatchRule   (Boolean ::= l::MatchRule r::MatchRule )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 428.

Parameter l
first match rule
Parameter r
second match rule
Return
Boolean telling us if the head pattern of two match rules uses the same production (or are equivalent in terms of being a wildcard or varpattern).

Compares the head pattern of two match rules, but without demanding attributes Modeled after comparison used for AbstractMatchRules


function isWildcardMatchRule   (Boolean ::= mRule::MatchRule )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 440.

Parameter mRule
a MatchRule construct
Return
Boolean indicating whether its a wildcard match rule Given a MatchRule, tells you if its a “wildcard” match rule. varpatterns aren’t called wildcards, but they match everything just the same so they return true here.

abstract production convenienceAspects   (top::AGDcl ::= attr::QNameAttrOccur aspectLHS::Decorated ConvAspectLHS eqKind::ConvenienceAspectEquationKind ml::MRuleList )

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/AbstractSyntax.sv line 465.

Parameter attr
The attribute for which you’d like to define aspect productions for.
Parameter aspectLHS
a convenience aspect LHS expression that contains the name and type of the term that our generated aspect production returns.
Parameter eqKind
The operator that assigns or binds to the attribute
Parameter ml
The Match Rules that define what aspects we’d like to generate.

Gives back a single AgDcl defining all the aspect productions according to the parameters given. This is the abstract production for convenience aspects. It’s generally advised if you intend to use convenience aspects to use them as concrete syntax (using the concrete production starting with aspect <attr> on ... )

concrete production p_silver_compiler_extension_convenienceaspects_ConcreteSyntax_sv_22_0   (=> top::ConvenienceAspectEquationKind ::= 'using' ':=')

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/ConcreteSyntax.sv line 21.

(Undocumented.)


concrete production p_silver_compiler_extension_convenienceaspects_ConcreteSyntax_sv_28_0   (=> top::ConvenienceAspectEquationKind ::= 'using' '<-')

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/ConcreteSyntax.sv line 27.

(Undocumented.)


concrete production p_silver_compiler_extension_convenienceaspects_ConcreteSyntax_sv_34_0   (=> top::ConvenienceAspectEquationKind ::=)

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/ConcreteSyntax.sv line 33.

(Undocumented.)


concrete production p_silver_compiler_extension_convenienceaspects_ConcreteSyntax_sv_58_0   (=> top::ConvAspectLHS ::= ty::TypeExpr)

Contained in grammar [silver:compiler:extension:convenienceaspects]. Defined at silver/compiler/extension/convenienceaspects/ConcreteSyntax.sv line 57.

(Undocumented.)