This file contains 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
// Precedence climbing | |
// | |
// Source: https://www.engr.mun.ca/~theo/Misc/exp_parsing.htm#climbing | |
// | |
// | |
// Eparser is | |
// var t : Tree | |
// t := Exp( 0 ) | |
// expect( end ) | |
// return t |
This file contains 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
#include <sys/select.h> | |
#include <termios.h> | |
#include <unistd.h> | |
#include <csignal> | |
#include <cstdint> | |
#include <cstdio> | |
#include <cstdlib> | |
#include <cstring> |
This file contains 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 libc::{EPOLLIN, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD}; | |
use std::collections::HashMap; | |
use std::io; | |
use std::io::ErrorKind; | |
use std::net::TcpListener; | |
use std::os::unix::io::AsRawFd; | |
use std::ptr; | |
macro_rules! syscall { | |
($fn: ident ( $($arg: expr),* $(,)* ) ) => {{ |
This file contains 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
mod ast0 { | |
enum BinOp { | |
Add, | |
Sub, | |
Mul, | |
Div, | |
} | |
enum Variable { | |
A, |
This file contains 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::fmt::Display; | |
#[derive(Clone, Copy, PartialEq, Eq)] | |
enum Token { | |
Minus, | |
Plus, | |
Mul, | |
Div, | |
Num(i32), | |
Eof, |
This file contains 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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
struct paddr_val { | |
uint64_t paddr; | |
uint64_t val; | |
}; | |
int paddr_val_cmp(const void *a, const void *b) |
This file contains 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
#include <cstddef> | |
#include <cstdint> | |
#include <iostream> | |
#include <variant> | |
#include <vector> | |
typedef int64_t i64; | |
typedef uint64_t u64; | |
typedef float f32; | |
typedef double f64; |
This file contains 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
/* | |
======= | |
Grammar | |
======= | |
Syntax | |
------ | |
expression → literal |
This file contains 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
#include <arpa/inet.h> | |
#include <errno.h> | |
#include <fcntl.h> | |
#include <netinet/in.h> | |
#include <sys/epoll.h> | |
#include <sys/socket.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
#include <stdbool.h> | |
#include <stdio.h> |
This file contains 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
.PHONY: help | |
# This is a code for automatic help generator. | |
# It supports ANSI colors and categories. | |
# To add new item into help output, simply add comments | |
# starting with '##'. To add category, use @category. | |
GREEN := $(shell tput -Txterm setaf 2) | |
WHITE := $(shell tput -Txterm setaf 7) | |
YELLOW := $(shell tput -Txterm setaf 3) | |
RESET := $(shell tput -Txterm sgr0) |
NewerOlder