diff --git a/nixd/include/nixd/Syntax/Nodes.h b/nixd/include/nixd/Syntax/Nodes.h index 4b5935f36..791c83927 100644 --- a/nixd/include/nixd/Syntax/Nodes.h +++ b/nixd/include/nixd/Syntax/Nodes.h @@ -83,6 +83,11 @@ struct StringAttr : Node {}; struct AttrPath : Node {}; +struct OpHasAttr : Node { + Node *Operand; + AttrPath *Path; +}; + struct OpNot : Node { Node *Body; }; diff --git a/nixd/lib/Syntax/Parser/Parser.y b/nixd/lib/Syntax/Parser/Parser.y index f0db11bd7..cd2f11713 100644 --- a/nixd/lib/Syntax/Parser/Parser.y +++ b/nixd/lib/Syntax/Parser/Parser.y @@ -23,6 +23,7 @@ nixd::syntax::If *If; nixd::syntax::Formals *Formals; nixd::syntax::Binds *Binds; + nixd::syntax::AttrPath *AttrPath; // Tokens nixd::syntax::StringToken STR; @@ -38,6 +39,7 @@ %type identifier %type formals %type binds +%type attrpath %token ID %token INT %token FLOAT @@ -150,7 +152,10 @@ expr_op | expr_op '/' expr_op { $$ = mkBinOp($1, $3, yylloc, *Data); } | expr_op CONCAT expr_op { $$ = mkBinOp($1, $3, yylloc, *Data); } | expr_op '?' attrpath { - + $$ = decorateNode(new OpHasAttr{ + .Operand = $1, + .Path = $3 + }, yylloc, *Data); } | expr_app ;