This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::cell::RefCell; | |
| use std::collections::HashMap; | |
| use std::rc::Rc; | |
| // What's missing: | |
| // - branching (or more general, control flow) operations | |
| // - records / structs or some form of named compound data type | |
| type Symbol = &'static str; | |
| type Block = Rc<[Op]>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ast | |
| import dataclasses | |
| from typing import Any, Optional, TypeAlias | |
| Expr: TypeAlias = Any | |
| class Context: | |
| def __init__(self, env=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::HashMap; | |
| use std::rc::Rc; | |
| fn main() { | |
| let x = &Tensor::new(vec![ | |
| vec![0.0, 0.0], | |
| vec![1.0, 0.0], | |
| vec![2.0, 0.0], | |
| vec![0.0, 1.0], | |
| vec![1.0, 1.0], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::HashMap; | |
| use std::rc::Rc; | |
| macro_rules! ident_list { | |
| () => { | |
| vec![] | |
| }; | |
| ($a:ident) => { | |
| vec![stringify!(a)] | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Value = Null | |
| | Var Nat | |
| | Pair Value Value | |
| | Num Int | |
| data Substitution = Nil | |
| | (::) (Nat, Value) Substitution | |
| State : Type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Text.Lexer.Core | |
| import Text.Lexer | |
| import Text.Parser.Core | |
| import Text.Parser | |
| data ExpressionToken = Number Integer | |
| | Operator String | |
| | OParen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import itertools | |
| class Entity: | |
| def __init__(self): | |
| entities.append(self) | |
| class Lane(Entity): | |
| def __init__(self): | |
| super().__init__() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::HashMap; | |
| use std::hash::Hash; | |
| pub type Result<T> = std::result::Result<T, Span>; | |
| pub struct Scanner<'i, T: Clone> { | |
| classifier_table: DefaultTable<char, usize>, | |
| transition_table: Table<usize, Vec<usize>>, | |
| accepting_states: Table<usize, T>, | |
| input: &'i str, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- evaluation using environments | |
| mutual | |
| data Lc = Ident String | |
| | Lambda String Lc | |
| | Call Lc Lc | |
| | Closure Env String Lc | |
| data Env = Empty | Entry String Lc Env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from abc import ABC, abstractmethod | |
| from dataclasses import dataclass | |
| from typing import Literal, Any | |
| BYTEORDER: Literal["little", "big"] = "big" | |
| class Type(ABC): | |
| @abstractmethod | |
| def load(self, offset, memory): |