xo-expression: + Variable + apply/lambda fixes
This commit is contained in:
parent
20b23b50fc
commit
9d2b0f17f8
7 changed files with 90 additions and 3 deletions
42
include/xo/expression/Variable.hpp
Normal file
42
include/xo/expression/Variable.hpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/** @file Variable.hpp
|
||||
*
|
||||
* Author: Roland Conybeare
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Expression.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace ast {
|
||||
|
||||
/** @class Variable
|
||||
* @brief syntax for a variable reference
|
||||
**/
|
||||
class Variable : public Expression {
|
||||
public:
|
||||
Variable(const std::string & name) : Expression(exprtype::variable), name_{name} {}
|
||||
|
||||
/** downcast from Expression **/
|
||||
static ref::brw<Variable> from(ref::brw<Expression> x) {
|
||||
return ref::brw<Variable>::from(x);
|
||||
}
|
||||
|
||||
const std::string & name() const { return name_; }
|
||||
|
||||
virtual void display(std::ostream & os) const;
|
||||
|
||||
private:
|
||||
/** variable name **/
|
||||
std::string name_;
|
||||
}; /*Variable*/
|
||||
|
||||
inline ref::rp<Variable>
|
||||
make_var(const std::string & name) {
|
||||
return new Variable(name);
|
||||
}
|
||||
} /*namespace ast*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
/** end Variable.hpp **/
|
||||
Loading…
Add table
Add a link
Reference in a new issue