Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing at @wix

Eugene Obrezkov ghaiklor

🎯
Focusing at @wix
View GitHub Profile
@ghaiklor
ghaiklor / compiler.ts
Last active May 24, 2020
Tiny compiler for mathematical expressions written in TypeScript
View compiler.ts
// Feel free to change this constant and Run the playground
// It will emit assembly into Logs tab to your right
const EXPRESSION_TO_COMPILE = "5 + 10 * 10";
// Tokens
enum TokenType { NUMBER, PLUS, MINUS, STAR, SLASH, LEFT_PAREN, RIGHT_PAREN, EOF }
interface Token { type: TokenType, value: string }
// Lexical Analysis
class Scanner {
@ghaiklor
ghaiklor / cloudSettings
Last active Aug 6, 2020
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2020-08-06T14:04:38.018Z","extensionVersion":"v3.4.3"}
@ghaiklor
ghaiklor / cool-tree.h
Created Jan 9, 2020
Semantic analysis phase for COOL language
View cool-tree.h
#ifndef COOL_TREE_H
#define COOL_TREE_H
//////////////////////////////////////////////////////////
//
// file: cool-tree.h
//
// This file defines classes for each phylum and constructor
//
//////////////////////////////////////////////////////////
@ghaiklor
ghaiklor / cool.y
Created Dec 23, 2019
Bison parser definition for the COOL language
View cool.y
/*
* cool.y
* Parser definition for the COOL language.
*
*/
%{
#include <iostream>
#include "cool-tree.h"
#include "stringtab.h"
#include "utilities.h"
@ghaiklor
ghaiklor / cool.flex
Created Dec 16, 2019
Flex specification for COOL language
View cool.flex
%{
#include <cool-parse.h>
#include <stringtab.h>
#include <utilities.h>
#include <string.h>
#define yylval cool_yylval
#define yylex cool_yylex
#define MAX_STR_CONST 1025
#define YY_NO_UNPUT /* keep g++ happy */
@ghaiklor
ghaiklor / output.txt
Created Jul 30, 2019
Wix Technical Task (Jul 2019)
View output.txt
$ tsc --target es6 --module commonjs wix.ts && node wix.js
---serialize---
13,A,9,12;9,B,5,8;5,C,0,4;0,0,0,0;4,E,1,2;1,0,0,0;2,0,0,0;8,P,5,6;5,0,0,0;6,0,0,0;12,G,9,10;9,0,0,0;10,0,0,0
---deserialize---
BinaryTree {
root: BinaryNode {
value: 'A',
left: BinaryNode { value: 'B', left: [BinaryNode], right: [BinaryNode] },
right: BinaryNode { value: 'G', left: null, right: null }
View say-hello.wat
(module
(type $t0 (func))
(type $t1 (func (param i32 i32) (result i32)))
(import "main" "sayHello" (func $main.sayHello (type $t0)))
(func $add (export "add") (type $t1) (param $p0 i32) (param $p1 i32) (result i32)
get_local $p0
get_local $p1
i32.add)
(func $f2 (type $t0)
call $main.sayHello)
View fluentd-match.conf
<match **>
@type copy
<store>
@type gelf
host "#{ENV['GELF_HOST']}"
port "#{ENV['GELF_PORT']}"
protocol "#{ENV['GELF_PROTOCOL']}"
<buffer>
flush_at_shutdown true
View fluentd-match.conf
<match **>
@type copy
<store>
@type gelf
host "#{ENV['GELF_HOST']}"
port "#{ENV['GELF_PORT']}"
protocol "#{ENV['GELF_PROTOCOL']}"
</store>
</match>
You can’t perform that action at this time.