mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-14 02:06:16 +02:00
parser.y: use names where I'll be refactoring
This commit is contained in:
parent
c274e005b6
commit
429a197d24
1 changed files with 36 additions and 36 deletions
|
@ -180,22 +180,22 @@ expr_function
|
||||||
$$ = me;
|
$$ = me;
|
||||||
SET_DOC_POS(me, @1);
|
SET_DOC_POS(me, @1);
|
||||||
}
|
}
|
||||||
| '{' formals '}' ':' expr_function
|
| '{' formals '}' ':' expr_function[body]
|
||||||
{ auto me = new ExprLambda(CUR_POS, state->validateFormals($2), $5);
|
{ auto me = new ExprLambda(CUR_POS, state->validateFormals($formals), $body);
|
||||||
$$ = me;
|
$$ = me;
|
||||||
SET_DOC_POS(me, @1);
|
SET_DOC_POS(me, @1);
|
||||||
}
|
}
|
||||||
| '{' formals '}' '@' ID ':' expr_function
|
| '{' formals '}' '@' ID ':' expr_function[body]
|
||||||
{
|
{
|
||||||
auto arg = state->symbols.create($5);
|
auto arg = state->symbols.create($ID);
|
||||||
auto me = new ExprLambda(CUR_POS, arg, state->validateFormals($2, CUR_POS, arg), $7);
|
auto me = new ExprLambda(CUR_POS, arg, state->validateFormals($formals, CUR_POS, arg), $body);
|
||||||
$$ = me;
|
$$ = me;
|
||||||
SET_DOC_POS(me, @1);
|
SET_DOC_POS(me, @1);
|
||||||
}
|
}
|
||||||
| ID '@' '{' formals '}' ':' expr_function
|
| ID '@' '{' formals '}' ':' expr_function[body]
|
||||||
{
|
{
|
||||||
auto arg = state->symbols.create($1);
|
auto arg = state->symbols.create($ID);
|
||||||
auto me = new ExprLambda(CUR_POS, arg, state->validateFormals($4, CUR_POS, arg), $7);
|
auto me = new ExprLambda(CUR_POS, arg, state->validateFormals($formals, CUR_POS, arg), $body);
|
||||||
$$ = me;
|
$$ = me;
|
||||||
SET_DOC_POS(me, @1);
|
SET_DOC_POS(me, @1);
|
||||||
}
|
}
|
||||||
|
@ -364,50 +364,50 @@ ind_string_parts
|
||||||
;
|
;
|
||||||
|
|
||||||
binds
|
binds
|
||||||
: binds attrpath '=' expr ';' {
|
: binds[accum] attrpath '=' expr ';' {
|
||||||
$$ = $1;
|
$$ = $accum;
|
||||||
|
|
||||||
auto pos = state->at(@2);
|
auto pos = state->at(@attrpath);
|
||||||
auto exprPos = state->at(@4);
|
auto exprPos = state->at(@expr);
|
||||||
{
|
{
|
||||||
auto it = state->lexerState.positionToDocComment.find(pos);
|
auto it = state->lexerState.positionToDocComment.find(pos);
|
||||||
if (it != state->lexerState.positionToDocComment.end()) {
|
if (it != state->lexerState.positionToDocComment.end()) {
|
||||||
$4->setDocComment(it->second);
|
$expr->setDocComment(it->second);
|
||||||
state->lexerState.positionToDocComment.emplace(exprPos, it->second);
|
state->lexerState.positionToDocComment.emplace(exprPos, it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state->addAttr($$, std::move(*$2), $4, pos);
|
state->addAttr($$, std::move(*$attrpath), $expr, pos);
|
||||||
delete $2;
|
delete $attrpath;
|
||||||
}
|
}
|
||||||
| binds INHERIT attrs ';'
|
| binds[accum] INHERIT attrs ';'
|
||||||
{ $$ = $1;
|
{ $$ = $accum;
|
||||||
for (auto & [i, iPos] : *$3) {
|
for (auto & [i, iPos] : *$attrs) {
|
||||||
if ($$->attrs.find(i.symbol) != $$->attrs.end())
|
if ($accum->attrs.find(i.symbol) != $accum->attrs.end())
|
||||||
state->dupAttr(i.symbol, iPos, $$->attrs[i.symbol].pos);
|
state->dupAttr(i.symbol, iPos, $accum->attrs[i.symbol].pos);
|
||||||
$$->attrs.emplace(
|
$accum->attrs.emplace(
|
||||||
i.symbol,
|
i.symbol,
|
||||||
ExprAttrs::AttrDef(new ExprVar(iPos, i.symbol), iPos, ExprAttrs::AttrDef::Kind::Inherited));
|
ExprAttrs::AttrDef(new ExprVar(iPos, i.symbol), iPos, ExprAttrs::AttrDef::Kind::Inherited));
|
||||||
}
|
}
|
||||||
delete $3;
|
delete $attrs;
|
||||||
}
|
}
|
||||||
| binds INHERIT '(' expr ')' attrs ';'
|
| binds[accum] INHERIT '(' expr ')' attrs ';'
|
||||||
{ $$ = $1;
|
{ $$ = $accum;
|
||||||
if (!$$->inheritFromExprs)
|
if (!$accum->inheritFromExprs)
|
||||||
$$->inheritFromExprs = std::make_unique<std::vector<Expr *>>();
|
$accum->inheritFromExprs = std::make_unique<std::vector<Expr *>>();
|
||||||
$$->inheritFromExprs->push_back($4);
|
$accum->inheritFromExprs->push_back($expr);
|
||||||
auto from = new nix::ExprInheritFrom(state->at(@4), $$->inheritFromExprs->size() - 1);
|
auto from = new nix::ExprInheritFrom(state->at(@expr), $accum->inheritFromExprs->size() - 1);
|
||||||
for (auto & [i, iPos] : *$6) {
|
for (auto & [i, iPos] : *$attrs) {
|
||||||
if ($$->attrs.find(i.symbol) != $$->attrs.end())
|
if ($accum->attrs.find(i.symbol) != $accum->attrs.end())
|
||||||
state->dupAttr(i.symbol, iPos, $$->attrs[i.symbol].pos);
|
state->dupAttr(i.symbol, iPos, $accum->attrs[i.symbol].pos);
|
||||||
$$->attrs.emplace(
|
$accum->attrs.emplace(
|
||||||
i.symbol,
|
i.symbol,
|
||||||
ExprAttrs::AttrDef(
|
ExprAttrs::AttrDef(
|
||||||
new ExprSelect(iPos, from, i.symbol),
|
new ExprSelect(iPos, from, i.symbol),
|
||||||
iPos,
|
iPos,
|
||||||
ExprAttrs::AttrDef::Kind::InheritedFrom));
|
ExprAttrs::AttrDef::Kind::InheritedFrom));
|
||||||
}
|
}
|
||||||
delete $6;
|
delete $attrs;
|
||||||
}
|
}
|
||||||
| { $$ = new ExprAttrs(state->at(@0)); }
|
| { $$ = new ExprAttrs(state->at(@0)); }
|
||||||
;
|
;
|
||||||
|
@ -468,10 +468,10 @@ expr_list
|
||||||
;
|
;
|
||||||
|
|
||||||
formals
|
formals
|
||||||
: formal ',' formals
|
: formal ',' formals[accum]
|
||||||
{ $$ = $3; $$->formals.emplace_back(*$1); delete $1; }
|
{ $$ = $accum; $$->formals.emplace_back(*$formal); delete $formal; }
|
||||||
| formal
|
| formal
|
||||||
{ $$ = new Formals; $$->formals.emplace_back(*$1); $$->ellipsis = false; delete $1; }
|
{ $$ = new Formals; $$->formals.emplace_back(*$formal); $$->ellipsis = false; delete $formal; }
|
||||||
|
|
|
|
||||||
{ $$ = new Formals; $$->ellipsis = false; }
|
{ $$ = new Formals; $$->ellipsis = false; }
|
||||||
| ELLIPSIS
|
| ELLIPSIS
|
||||||
|
|
Loading…
Reference in a new issue