nixd
|
#include <Parser.h>
Public Types | |
enum | ParserState { PS_Expr , PS_String , PS_IndString , PS_Path } |
Public Member Functions | |
Parser (std::string_view Src, std::vector< Diagnostic > &Diags) | |
std::shared_ptr< Interpolation > | parseInterpolation () |
Parse interpolations. | |
std::shared_ptr< Expr > | parseExprPath () |
Parse paths. | |
std::shared_ptr< InterpolatedParts > | parseStringParts () |
std::shared_ptr< ExprString > | parseString (bool IsIndented) |
std::shared_ptr< ExprParen > | parseExprParen () |
std::shared_ptr< AttrName > | parseAttrName () |
std::shared_ptr< AttrPath > | parseAttrPath () |
std::shared_ptr< Binding > | parseBinding () |
std::shared_ptr< Inherit > | parseInherit () |
std::shared_ptr< Binds > | parseBinds () |
std::shared_ptr< ExprAttrs > | parseExprAttrs () |
std::shared_ptr< Expr > | parseExprSimple () |
std::shared_ptr< Expr > | parseExprSelect () |
std::shared_ptr< Expr > | parseExprApp (int Limit=INT_MAX) |
std::shared_ptr< ExprList > | parseExprList () |
std::shared_ptr< Formal > | parseFormal () |
std::shared_ptr< Formals > | parseFormals () |
std::shared_ptr< LambdaArg > | parseLambdaArg () |
std::shared_ptr< ExprLambda > | parseExprLambda () |
std::shared_ptr< Expr > | parseExpr () |
std::shared_ptr< Expr > | parseExprOp () |
Parse binary/unary operators. | |
std::shared_ptr< ExprIf > | parseExprIf () |
std::shared_ptr< ExprAssert > | parseExprAssert () |
std::shared_ptr< ExprLet > | parseExprLet () |
std::shared_ptr< ExprWith > | parseExprWith () |
std::shared_ptr< Expr > | parse () |
Top-level parsing. | |
Definition at line 31 of file src/Parse/Parser.h.
Enumerator | |
---|---|
PS_Expr | |
PS_String | |
PS_IndString | |
PS_Path |
Definition at line 33 of file src/Parse/Parser.h.
|
inline |
Definition at line 153 of file src/Parse/Parser.h.
References PS_Expr.
std::shared_ptr< Expr > nixf::Parser::parse | ( | ) |
Top-level parsing.
Definition at line 43 of file ParseSupport.cpp.
References nixf::Token::kind().
Referenced by nixf::parse().
std::shared_ptr< AttrName > Parser::parseAttrName | ( | ) |
Definition at line 6 of file ParseAttrs.cpp.
References nixf::Token::kind(), parseInterpolation(), and parseString().
Referenced by parseAttrPath(), and parseInherit().
std::shared_ptr< AttrPath > Parser::parseAttrPath | ( | ) |
Definition at line 30 of file ParseAttrs.cpp.
References nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::Token::kind(), nixf::TextEdit::mkInsertion(), nixf::TextEdit::mkRemoval(), and parseAttrName().
Referenced by parseBinding(), and parseExprSelect().
std::shared_ptr< Binding > Parser::parseBinding | ( | ) |
Definition at line 72 of file ParseAttrs.cpp.
References nixf::detail::diagNullExpr(), nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::Token::kind(), nixf::TextEdit::mkInsertion(), parseAttrPath(), parseExpr(), and nixf::tok::spelling().
Referenced by parseBinds().
std::shared_ptr< Binds > Parser::parseBinds | ( | ) |
Definition at line 160 of file ParseAttrs.cpp.
References nixf::Token::lCur(), parseBinding(), and parseInherit().
Referenced by parseExprAttrs(), and parseExprLet().
std::shared_ptr< Expr > Parser::parseExpr | ( | ) |
Definition at line 73 of file ParseExpr.cpp.
References parseExprAssert(), parseExprAttrs(), parseExprIf(), parseExprLambda(), parseExprLet(), parseExprOp(), and parseExprWith().
Referenced by parseBinding(), parseExprAssert(), parseExprIf(), parseExprLambda(), parseExprLet(), parseExprParen(), parseExprWith(), parseFormal(), parseInherit(), and parseInterpolation().
std::shared_ptr< Expr > Parser::parseExprApp | ( | int | Limit = INT_MAX | ) |
Consume at most Limit
number of expr_select
as arguments e.g. Fn A1 A2 A3
with Limit = 2 will be parsed as ((Fn A1 A2) A3)
Definition at line 52 of file ParseExpr.cpp.
References parseExprSelect().
std::shared_ptr< ExprAssert > Parser::parseExprAssert | ( | ) |
Definition at line 210 of file ParseExpr.cpp.
References nixf::detail::diagNullExpr(), nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::Token::kind(), nixf::TextEdit::mkRemoval(), nixf::Diagnostic::note(), parseExpr(), nixf::Token::range(), and nixf::tok::spelling().
Referenced by parseExpr().
std::shared_ptr< ExprAttrs > Parser::parseExprAttrs | ( | ) |
attrset_expr : REC? '{' binds '}'
Note: peek tok_kw_rec
or tok_l_curly
before calling this function.
Definition at line 193 of file ParseAttrs.cpp.
References nixf::Token::kind(), nixf::Token::lCur(), nixf::Sema::onExprAttrs(), parseBinds(), nixf::Token::range(), and nixf::tok::spelling().
Referenced by parseExpr(), and parseExprSimple().
std::shared_ptr< ExprIf > Parser::parseExprIf | ( | ) |
Definition at line 143 of file ParseExpr.cpp.
References nixf::detail::diagNullExpr(), nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::Token::kind(), nixf::TextEdit::mkInsertion(), nixf::TextEdit::mkRemoval(), nixf::Diagnostic::note(), parseExpr(), nixf::Token::range(), nixf::Token::rCur(), and nixf::tok::spelling().
Referenced by parseExpr().
std::shared_ptr< ExprLambda > Parser::parseExprLambda | ( | ) |
Definition at line 132 of file ParseLambda.cpp.
References nixf::detail::diagNullExpr(), parseExpr(), and parseLambdaArg().
Referenced by parseExpr().
std::shared_ptr< ExprLet > Parser::parseExprLet | ( | ) |
Definition at line 253 of file ParseExpr.cpp.
References nixf::detail::diagNullExpr(), nixf::Token::kind(), nixf::Sema::onExprAttrs(), parseBinds(), parseExpr(), nixf::Node::range(), and nixf::Token::range().
Referenced by parseExpr().
std::shared_ptr< ExprList > Parser::parseExprList | ( | ) |
Definition at line 81 of file ParseSimple.cpp.
References nixf::Token::kind(), nixf::Token::lCur(), parseExprSelect(), nixf::Token::range(), and nixf::tok::spelling().
Referenced by parseExprSimple().
|
inline |
Parse binary/unary operators.
Definition at line 315 of file src/Parse/Parser.h.
Referenced by parseExpr().
std::shared_ptr< ExprParen > Parser::parseExprParen | ( | ) |
Definition at line 40 of file ParseSimple.cpp.
References nixf::detail::diagNullExpr(), nixf::Fix::edit(), nixf::Faded, nixf::Diagnostic::fix(), nixf::Token::kind(), nixf::Token::lCur(), nixf::TextEdit::mkRemoval(), parseExpr(), nixf::Token::range(), nixf::tok::spelling(), and nixf::PartialDiagnostic::tag().
Referenced by parseExprSimple().
std::shared_ptr< Expr > Parser::parseExprPath | ( | ) |
Parse paths.
The first token, path_fragment is lexed in PS_Expr context, then switch in "PS_Path" context. The ending token "path_end" shall be poped with context switching.
Definition at line 29 of file ParseStrings.cpp.
References nixf::Token::kind(), nixf::Token::lCur(), parseInterpolation(), PS_Path, nixf::Token::rCur(), and nixf::Token::view().
Referenced by parseExprSimple().
std::shared_ptr< Expr > Parser::parseExprSelect | ( | ) |
Definition at line 6 of file ParseExpr.cpp.
References nixf::detail::diagNullExpr(), nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::Token::kind(), nixf::Node::lCur(), nixf::TextEdit::mkInsertion(), nixf::TextEdit::mkRemoval(), parseAttrPath(), parseExprSelect(), parseExprSimple(), nixf::Token::range(), and nixf::Token::rCur().
Referenced by parseExprApp(), parseExprList(), and parseExprSelect().
std::shared_ptr< Expr > Parser::parseExprSimple | ( | ) |
Definition at line 107 of file ParseSimple.cpp.
References nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::Token::kind(), nixf::Token::lCur(), nixf::TextEdit::mkInsertion(), parseExprAttrs(), parseExprList(), parseExprParen(), parseExprPath(), parseString(), nixf::Token::range(), nixf::Token::rCur(), and nixf::Token::view().
Referenced by parseExprSelect().
std::shared_ptr< ExprWith > Parser::parseExprWith | ( | ) |
Definition at line 292 of file ParseExpr.cpp.
References nixf::detail::diagNullExpr(), nixf::Token::kind(), nixf::Diagnostic::note(), parseExpr(), nixf::Token::range(), and nixf::tok::spelling().
Referenced by parseExpr().
std::shared_ptr< Formal > Parser::parseFormal | ( | ) |
Definition at line 6 of file ParseLambda.cpp.
References nixf::detail::diagNullExpr(), nixf::Token::kind(), and parseExpr().
Referenced by parseFormals().
std::shared_ptr< Formals > Parser::parseFormals | ( | ) |
Definition at line 50 of file ParseLambda.cpp.
References nixf::Token::kind(), nixf::Token::lCur(), nixf::Diagnostic::note(), nixf::Sema::onFormals(), parseFormal(), nixf::Token::range(), and nixf::tok::spelling().
Referenced by parseLambdaArg().
std::shared_ptr< Inherit > Parser::parseInherit | ( | ) |
Definition at line 103 of file ParseAttrs.cpp.
References nixf::detail::diagNullExpr(), nixf::Fix::edit(), nixf::Faded, nixf::Diagnostic::fix(), nixf::Token::kind(), nixf::Token::lCur(), nixf::TextEdit::mkRemoval(), nixf::Diagnostic::note(), parseAttrName(), parseExpr(), nixf::Token::range(), nixf::tok::spelling(), and nixf::PartialDiagnostic::tag().
Referenced by parseBinds().
std::shared_ptr< Interpolation > Parser::parseInterpolation | ( | ) |
Parse interpolations.
Definition at line 6 of file ParseStrings.cpp.
References nixf::detail::diagNullExpr(), nixf::Token::kind(), nixf::Token::lCur(), parseExpr(), PS_Expr, nixf::Token::range(), and nixf::tok::spelling().
Referenced by parseAttrName(), parseExprPath(), and parseStringParts().
std::shared_ptr< LambdaArg > Parser::parseLambdaArg | ( | ) |
Definition at line 84 of file ParseLambda.cpp.
References nixf::Fix::edit(), nixf::Diagnostic::fix(), nixf::Token::kind(), nixf::TextEdit::mkInsertion(), nixf::TextEdit::mkRemoval(), nixf::Diagnostic::note(), nixf::Sema::onLambdaArg(), parseFormals(), nixf::Token::range(), nixf::tok::spelling(), and nixf::Token::view().
Referenced by parseExprLambda().
std::shared_ptr< ExprString > Parser::parseString | ( | bool | IsIndented | ) |
Definition at line 88 of file ParseStrings.cpp.
References nixf::Token::kind(), nixf::Token::lCur(), parseStringParts(), PS_IndString, PS_String, nixf::Token::range(), and nixf::tok::spelling().
Referenced by parseAttrName(), and parseExprSimple().
std::shared_ptr< InterpolatedParts > Parser::parseStringParts | ( | ) |
Definition at line 58 of file ParseStrings.cpp.
References nixf::Token::kind(), nixf::Token::lCur(), and parseInterpolation().
Referenced by parseString().