Skip to content

Instantly share code, notes, and snippets.

View ghaiklor's full-sized avatar

Eugene Obrezkov ghaiklor

View GitHub Profile
@ghaiklor
ghaiklor / settings.json
Created July 31, 2021 17:42
Visual Studio Code Settings (TypeScript\Rust\Ruby\Bash)
{
"[dockerfile]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
@ghaiklor
ghaiklor / .eslintrc.js
Created February 26, 2021 12:15
ESLint Strict Configuration
{
"env": {
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"extends": [
"eslint:all",
"plugin:@typescript-eslint/all",
@ghaiklor
ghaiklor / tsconfig.json
Created February 26, 2021 11:19
TypeScript Strict Configuration
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"allowUnreachableCode": false,
"alwaysStrict": true,
"composite": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
@ghaiklor
ghaiklor / compiler.ts
Last active May 24, 2020 12:46
Tiny compiler for mathematical expressions written in TypeScript
// 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 August 6, 2020 14:04
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-08-06T14:04:38.018Z","extensionVersion":"v3.4.3"}
@ghaiklor
ghaiklor / cool-tree.h
Created January 9, 2020 19:41
Semantic analysis phase for COOL language
#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 December 23, 2019 20:36
Bison parser definition for the COOL language
/*
* 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 December 16, 2019 19:22
Flex specification for COOL language
%{
#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 July 30, 2019 14:48
Wix Technical Task (Jul 2019)
$ 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 }
(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)