xo-interpreter: apply expressions + llvm builtins working!
This commit is contained in:
parent
7ca1366bec
commit
1d1e72adf3
31 changed files with 531 additions and 50 deletions
|
|
@ -94,6 +94,7 @@ namespace xo {
|
|||
parserstatemachine * p_psm) override;
|
||||
|
||||
virtual void print(std::ostream & os) const override;
|
||||
virtual bool pretty_print(const print::ppindentinfo & ppii) const final override;
|
||||
|
||||
private:
|
||||
static std::unique_ptr<apply_xs> make();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace xo {
|
|||
*
|
||||
* Examples:
|
||||
* @text
|
||||
* add (1, 2) ;
|
||||
* def x : i64 = 5 ; // with allow_defs
|
||||
* lambda (f : x64) { ... } ;
|
||||
* if (prime(x)) { ... } ;
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ namespace xo {
|
|||
**/
|
||||
class lambda_xs : public exprstate {
|
||||
public:
|
||||
using Environment = xo::scm::SymbolTable;
|
||||
using LocalEnv = xo::scm::LocalSymtab;
|
||||
using SymbolTable = xo::scm::SymbolTable;
|
||||
using LocalSymtab = xo::scm::LocalSymtab;
|
||||
|
||||
public:
|
||||
lambda_xs();
|
||||
|
|
@ -81,6 +81,8 @@ namespace xo {
|
|||
parserstatemachine * p_psm) override;
|
||||
virtual void on_semicolon_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
virtual void on_f64_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) final override;
|
||||
|
||||
virtual void print(std::ostream & os) const override;
|
||||
virtual bool pretty_print(const print::ppindentinfo & ppii) const override;
|
||||
|
|
@ -93,7 +95,7 @@ namespace xo {
|
|||
lambdastatetype lmxs_type_ = lambdastatetype::lm_0;
|
||||
|
||||
/** lambda environment (for formal parameters) **/
|
||||
rp<LocalEnv> local_env_;
|
||||
rp<LocalSymtab> local_env_;
|
||||
|
||||
/** explicit return type (if supplied) **/
|
||||
TypeDescr explicit_return_td_ = nullptr;
|
||||
|
|
@ -105,7 +107,7 @@ namespace xo {
|
|||
rp<Expression> body_;
|
||||
|
||||
/** parent environment **/
|
||||
rp<Environment> parent_env_;
|
||||
rp<SymbolTable> parent_env_;
|
||||
|
||||
};
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ namespace xo {
|
|||
void on_rightbrace_token(const token_type & tk);
|
||||
void on_then_token(const token_type & tk);
|
||||
void on_else_token(const token_type & tk);
|
||||
void on_f64_token(const token_type & tk);
|
||||
|
||||
// ----- parsing error -----
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,10 @@ namespace xo {
|
|||
* Deals with infix operators, handles operator precedence.
|
||||
* Also generates argument-type-specific arithmetic expressions,
|
||||
* for example using ``Apply::make_add2_f64()`` when adding floating-point numbers
|
||||
*
|
||||
* One reason for this to exist is to simulate one-token lookahead.
|
||||
* To look at but not consume a token T, can push a progress_xs instance P,
|
||||
* then send T to P.
|
||||
**/
|
||||
class progress_xs : public exprstate {
|
||||
public:
|
||||
|
|
@ -105,6 +109,8 @@ namespace xo {
|
|||
parserstatemachine * p_psm) override;
|
||||
virtual void on_symbol_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
virtual void on_comma_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) final override;
|
||||
virtual void on_typedescr(TypeDescr td,
|
||||
parserstatemachine * p_psm) override;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue