MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / parse_var

Method parse_var

erpcgen/src/cpptemplate/cpptempl.cpp:1964–1994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1962}
1963
1964void TemplateParser::parse_var()
1965{
1966 size_t pos = m_text.find("}");
1967 if (pos == std::string::npos)
1968 {
1969 throw TemplateException(m_current_line, "unterminated variable block");
1970 }
1971
1972 std::string var_text = m_text.substr(1, pos - 1);
1973
1974 bool has_kill_newline_if_empty = !var_text.empty() && var_text[0] == '>' && var_text.size() > 2;
1975 if (has_kill_newline_if_empty)
1976 {
1977 var_text = var_text.substr(1, pos - 2);
1978 }
1979
1980 bool has_kill_newline = !var_text.empty() && var_text.back() == '>';
1981 if (has_kill_newline)
1982 {
1983 var_text.pop_back();
1984 }
1985
1986 bool eol_follows = m_text.size() > pos + 1 && m_text[pos + 1] == '\n';
1987 m_text = m_text.substr(pos + 1 + (has_kill_newline && eol_follows ? 1 : 0));
1988
1989 token_vector stmt_tokens = tokenize_statement(var_text);
1990 m_current_nodes->push_back(node_ptr(new NodeVar(stmt_tokens, m_current_line, has_kill_newline_if_empty)));
1991
1992 m_current_line += count_newlines(var_text);
1993 m_last_was_eol = false;
1994}
1995
1996void TemplateParser::push_node(Node *new_node, token_type_t until)
1997{

Callers

nothing calls this directly

Calls 6

TemplateExceptionClass · 0.85
tokenize_statementFunction · 0.85
count_newlinesFunction · 0.85
push_backMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected