Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds QNames antiquote production. #726

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions grammars/silver/compiler/definition/core/QName.sv
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ top::QName ::= msg::[Message]
top.lookupAttribute = decorate errorLookup(msg) with {};
}


nonterminal QNameLookup<a> with fullName, typeScheme, errors, dcls<a>, dcl<a>, found;

synthesized attribute lookupValue :: Decorated QNameLookup<ValueDclInfo> occurs on QName;
Expand Down
8 changes: 8 additions & 0 deletions grammars/silver/compiler/extension/convenience/Lists.sv
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ top::QNames ::= id1::QNameWithTL ',' id2::QNames
top.qnames = [id1] ++ id2.qnames;
}

abstract production qNamesError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "error" production doesn't actually flow up the errors in msg, since errors doesn't occur on QNames. This production isn't needed anyway, see my comment below.

top::QNames ::= msg::[Message]
{
top.unparse = "<err>";
top.qnames = [];

}

--------------------------------------------------------------------------------

function makeOccursDcls
Expand Down
10 changes: 10 additions & 0 deletions grammars/silver/compiler/extension/silverconstruction/Syntax.sv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ imports silver:compiler:definition:env;
imports silver:compiler:definition:type:syntax;
imports silver:compiler:modification:list;
imports silver:compiler:extension:patternmatching;
imports silver:compiler:extension:convenience;

concrete production quoteAGDcl
top::Expr ::= 'Silver_AGDcl' '{' ast::AGDcl '}'
Expand Down Expand Up @@ -117,6 +118,15 @@ top::QName ::= '$QName' '{' e::Expr '}'
location=top.location);
}

concrete production antiquoteQNames
top::QNames ::= '$QNames' '{' e::Expr '}'
{
top.unparse = s"$$QNames{${e.unparse}}";
forwards to
qNamesError(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be qNamesSingle(qNameWithTL(qNameError(...), botlNone()) to avoid adding a new "error" production that is only useful here.

[err(e.location, "$QNames should not occur outside of quoted Silver literal")]);
}

concrete production antiquoteQNameAttrOccur
top::QNameAttrOccur ::= '$QNameAttrOccur' '{' e::Expr '}'
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ terminal AntiquotePattern_t '$Pattern' lexer classes {Antiqu
terminal AntiquoteAspectRHS_t '$AspectRHS' lexer classes {Antiquote};
terminal AntiquoteProductionStmt_t '$ProductionStmt' lexer classes {Antiquote};
terminal AntiquoteQName_t '$QName' lexer classes {Antiquote};
terminal AntiquoteQNames_t '$QNames' lexer classes {Antiquote};
terminal AntiquoteQNameAttrOccur_t '$QNameAttrOccur' lexer classes {Antiquote};
terminal AntiquoteName_t '$Name' lexer classes {Antiquote};
terminal Antiquote_qName_t '$qName' lexer classes {Antiquote};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ top::AST ::= prodName::String children::ASTs annotations::NamedASTs
"silver:compiler:extension:silverconstruction:antiquoteAspectRHS",
"silver:compiler:extension:silverconstruction:antiquoteProductionStmt",
"silver:compiler:extension:silverconstruction:antiquoteQName",
"silver:compiler:extension:silverconstruction:antiquoteQNames",
"silver:compiler:extension:silverconstruction:antiquoteQNameAttrOccur",
"silver:compiler:extension:silverconstruction:antiquoteName"];

Expand Down