Skip to content

Commit fb2f7ab

Browse files
committed
More
1 parent 9d0e4dd commit fb2f7ab

3 files changed

Lines changed: 33 additions & 8 deletions

File tree

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ethos 0.1.2 prerelease
55

66
- Change the execution semantics when a program takes an unevalated term as an argument. In particular, we do not call user provided programs and oracles when at least argument could not be evaluated. This change was made to make errors more intuitive. Note this changes the semantics of programs that previously relied on being called on unevaluated terms.
77
- User programs, user oracles, and builtin operators that are unapplied are now considered unevaluated. This makes the type checker more strict and disallows passing them as arguments to other programs, which previously led to undefined behavior.
8-
- Changes the semantics of `declare-parameterized-const`. In particular, the parameters of a parameterized constants are no longer assumed to be implicit, and are explicit by default. The `:implicit` attribute can be used on all parameters to recover the previous behavior.
8+
- Changes the semantics of `declare-parameterized-const`. In particular, the parameters of a parameterized constants are no longer assumed to be implicit, and are explicit by default. The `:implicit` attribute can be used on all parameters to recover the previous behavior. Other attributes such as `:opaque` and `:requires` can be used on parameters to this command.
99
- Remove support for the explicit parameter annotation `eo::_`, which was used to provide annotations for implicit arguments to parameterized constants.
1010
- Changed the semantics of pairwise and chainable operators for a single argument, which now reduces to the neutral element of the combining operator instead of a parse error.
1111
- The operator `eo::typeof` now fails to evaluate if the type of the given term is not ground.

src/expr_parser.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,9 @@ std::vector<Expr> ExprParser::parseAndBindSortedVarList(
795795
bind(name, v);
796796
// parse attribute list
797797
AttrMap& attrs = amap[v.getValue()];
798-
parseAttributeList(Kind::PARAM, v, attrs);
798+
// all other parameter lists make fresh parameters, pass along the
799+
// parameter list kind k
800+
parseAttributeList(Kind::PARAM, v, attrs, k);
799801
if (attrs.find(Attr::IMPLICIT)!=attrs.end())
800802
{
801803
attrs.erase(Attr::IMPLICIT);
@@ -1112,7 +1114,7 @@ std::string ExprParser::parseStr(bool unescape)
11121114
return s;
11131115
}
11141116

1115-
void ExprParser::parseAttributeList(Kind k, Expr& e, AttrMap& attrs, bool& pushedScope)
1117+
void ExprParser::parseAttributeList(Kind k, Expr& e, AttrMap& attrs, bool& pushedScope, Kind plk)
11161118
{
11171119
std::map<std::string, Attr>::iterator its;
11181120
// while the next token is KEYWORD, exit if RPAREN
@@ -1152,9 +1154,30 @@ void ExprParser::parseAttributeList(Kind k, Expr& e, AttrMap& attrs, bool& pushe
11521154
case Kind::PARAM:
11531155
{
11541156
// attributes on parameters
1155-
if (a==Attr::LIST || a==Attr::IMPLICIT || a==Attr::OPAQUE)
1157+
// parameter lists of define and declare-parameterized-const
1158+
// allow for several attributes
1159+
if (plk==Kind::CONST || plk==Kind::LAMBDA)
11561160
{
11571161
handled = true;
1162+
switch (a)
1163+
{
1164+
case Attr::LIST:
1165+
case Attr::IMPLICIT:
1166+
case Attr::OPAQUE:
1167+
// requires no value
1168+
break;
1169+
case Attr::REQUIRES:
1170+
val = parseExprPair();
1171+
break;
1172+
default:
1173+
handled = false;
1174+
break;
1175+
}
1176+
}
1177+
else
1178+
{
1179+
// all others only allow for :list
1180+
handled = (a==Attr::LIST);
11581181
}
11591182
}
11601183
break;
@@ -1271,10 +1294,10 @@ void ExprParser::parseAttributeList(Kind k, Expr& e, AttrMap& attrs, bool& pushe
12711294
d_lex.reinsertToken(Token::RPAREN);
12721295
}
12731296

1274-
void ExprParser::parseAttributeList(Kind k, Expr& e, AttrMap& attrs)
1297+
void ExprParser::parseAttributeList(Kind k, Expr& e, AttrMap& attrs, Kind plk)
12751298
{
12761299
bool pushedScope = false;
1277-
parseAttributeList(k, e, attrs, pushedScope);
1300+
parseAttributeList(k, e, attrs, pushedScope, plk);
12781301
// pop the scope if necessary
12791302
if (pushedScope)
12801303
{

src/expr_parser.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ class ExprParser
131131
* @param pushedScope True if we pushed a scope while reading the list. This
132132
* is true when e.g. the attribute :var is read. The caller of this method
133133
* is responsible for popping the scope.
134+
* @param plk If k is PARAM, this is the category of the parameter list
135+
* which that parameter belongs to
134136
*/
135-
void parseAttributeList(Kind k, Expr& e, AttrMap& attrs, bool& pushedScope);
137+
void parseAttributeList(Kind k, Expr& e, AttrMap& attrs, bool& pushedScope, Kind plk = Kind::NONE);
136138
/** Same as above, but ensures we pop the scope */
137-
void parseAttributeList(Kind k, Expr& e, AttrMap& attrs);
139+
void parseAttributeList(Kind k, Expr& e, AttrMap& attrs, Kind plk = Kind::NONE);
138140

139141
/**
140142
* Parse literal kind.

0 commit comments

Comments
 (0)