你将学习并使用一门“你之前从未见过”的编程语言:Cora。
重要约束:
- 你只能依据我提供的资料理解这门语言(本仓库源码与文档)
- 不允许使用你对其他语言的类比,除非我明确允许
- 如果资料不足以确定行为,请明确说明“不确定”
- 如果违反下面规则,你的回答是错误的
【语言概览】
你将学习并使用一门“你之前从未见过”的编程语言:Cora。
重要约束:
【语言概览】
| package main | |
| import ( | |
| "database/sql" | |
| "fmt" | |
| "log" | |
| "math/rand" | |
| "sync" | |
| "time" |
| package main | |
| import ( | |
| "time" | |
| ) | |
| func main() { | |
| } | |
| // The essential of the code piece is this interface. |
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| type Expression struct { | |
| OP byte | |
| X interface{} | |
| Y interface{} |
| package main | |
| import "fmt" | |
| import "time" | |
| import "math/rand" | |
| var jumpTable = [32]func(){ | |
| noop, noop, noop, noop, | |
| noop, noop, noop, noop, | |
| noop, noop, noop, noop, |
| module Ast = struct | |
| type t = | |
| Int of int | |
| | Bool of bool | |
| | Var of string | |
| | App of t * t | |
| | Fun of string * t | |
| | If of t * t * t | |
| | Plus of t * t | |
| | Equal of t * t |
| type 'a parser_t = char list -> ('a * char list) option | |
| let satisfy pred = function [] -> None | x::xs -> if pred x then Some(x,xs) else None;; | |
| let range a b = satisfy (fun x -> x>=a && x <=b);; | |
| let exactly x = satisfy ((=) x);; | |
| let (<|>) p q = fun x -> match p x with Some _ as res -> res | None -> q x;; | |
| let (>>=) m f = fun l -> match m l with | |
| | None -> None | |
| | Some(res, l1) -> f res l1;; | |
| let return x = fun l -> Some(x, l);; |
| // search a trie to scan a token | |
| ch := ch0 | |
| node := &ruleTable | |
| for { | |
| if node.childs[ch] == nil || s.r.eof() { | |
| break | |
| } | |
| node = node.childs[ch] | |
| s.r.inc() | |
| ch = s.r.peek() |
| switch ch0 { | |
| case '|': | |
| s.r.inc() | |
| if s.r.peek() == '|' { | |
| s.r.inc() | |
| return oror | |
| } | |
| return '|' | |
| case '&': | |
| s.r.inc() |
| #lang racket | |
| (define ready-queue '()) | |
| (define list-append | |
| (lambda (ls x) | |
| (if (null? ls) | |
| (cons x '()) | |
| (cons (car ls) (list-append (cdr ls) x))))) | |
| ;; 定义队列操作的函数 |