Skip to content

Instantly share code, notes, and snippets.

View KvanTTT's full-sized avatar

Ivan Kochurkin KvanTTT

View GitHub Profile
# Generated from /tmp/Python3Runner-ForkJoinPool-1-worker-7-1661867391485/P.g4 by ANTLR 4.10.2-SNAPSHOT
# encoding: utf-8
from antlr4 import *
from io import StringIO
import sys
if sys.version_info[1] > 5:
from typing import TextIO
else:
from typing.io import TextIO
@KvanTTT
KvanTTT / check-range-vs-mask.py
Last active July 4, 2022 08:57
Constant folding benchmark
from dis import dis
import sys
import timeit
warm_up_count = 4
iteration_count = 256
class C:
C0=0
C1=1
@KvanTTT
KvanTTT / LargeLexer.g4
Created March 21, 2022 16:33
atnStatesSizeMoreThan65535Descriptor
lexer grammar L;
T_000000: 'T_000000______________________________________________________________________';
T_000001: 'T_000001______________________________________________________________________';
T_000002: 'T_000002______________________________________________________________________';
T_000003: 'T_000003______________________________________________________________________';
T_000004: 'T_000004______________________________________________________________________';
T_000005: 'T_000005______________________________________________________________________';
T_000006: 'T_000006______________________________________________________________________';
T_000007: 'T_000007______________________________________________________________________';
This file has been truncated, but you can view the full file.
// Generated from C:\Users\User\AppData\Local\Temp\BaseJavaTest-main-1643656434572\L.g4 by ANTLR 4.9.3
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;
This file has been truncated, but you can view the full file.
// Generated from C:\Users\User\AppData\Local\Temp\BaseCppTest-main-1643540272050\L.g4 by ANTLR 4.9.3
#include "L.h"
using namespace antlr4;
@KvanTTT
KvanTTT / LargeLexerNew.cs
Created January 21, 2022 19:52
Old vs New Atn Serialization C#
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// ANTLR Version: 4.9.3
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@KvanTTT
KvanTTT / RESHI_ESLI_SILEN.smt
Last active February 13, 2021 10:37
РЕШИ + ЕСЛИ = СИЛЕН
; R E SH I
; E S L I
; S I L E N
; Обявление уникальных букв
(declare-const R Int)
(declare-const E Int)
(declare-const SH Int)
(declare-const I Int)
using System;
class Program
{
static void Main()
{
int validTimeCount = 0;
for (int hour = 0; hour < 24; hour++)
{
@KvanTTT
KvanTTT / SwitchByObjectVsInt.cs
Created March 13, 2020 13:22
Compare generated code for switch by object vs switch by int
using System;
public class C {
public const int C1Type = 1;
public const int C2Type = 2;
public const int C3Type = 3;
public const int C4Type = 4;
public abstract class Base
{
class Program
{
class Animal
{
}
class Cat : Animal
{
public void Meow()
{