Skip to content

Instantly share code, notes, and snippets.

View juanbono's full-sized avatar
:shipit:

Juan Bono juanbono

:shipit:
View GitHub Profile
@juanbono
juanbono / interprete.py
Created October 23, 2023 13:04
Ejemplo de interprete usando Lark
# Tener en cuenta que requiere la instalacion previa de lark:
# pip install lark
# correr con el comando:
# python3 interprete.py
# Basado en el ejemplo de la documentacion de Lark, le agregue algunas funciones para hacer la evaluacion.
import sys
from typing import List
from dataclasses import dataclass
from lark import Lark, ast_utils, Transformer, v_args
@juanbono
juanbono / main.rs
Last active September 29, 2024 12:19
cranelift binary
use cranelift::prelude::*;
use cranelift_module::{Linkage, Module};
use cranelift_object::{ObjectBuilder, ObjectModule};
fn main() {
// create a settings builder to configure the opt level
let mut settings_builder = settings::builder();
// disable optimizations
// TODO: take the opt level in the CLI.
settings_builder.set("opt_level", "none").unwrap();
@juanbono
juanbono / claseTiposDeDatosFuncional.hs
Created August 23, 2020 19:24
Clase 2 del Paradigma Funcional sobre tipos de datos (tuplas, listas y records)
-- Tipos de Datos
--
-- Tuplas
--
pos = (1, 2)
tercero (a, b, c) = c
cuarto (_, _, _, d) = d
defmodule Logging21.Application do
@moduledoc false
use Application
def start(_type, _args) do
:logger.add_handlers(:logging_21)
opts = [strategy: :one_for_one, name: Logging21.Supervisor]
Supervisor.start_link([], opts)
@juanbono
juanbono / day4.erl
Created December 5, 2019 01:24
advent of code 2019 - day 4
-module(day4).
-define(INPUT_FILE, "src/day4/input.txt").
-export([part1/0, part2/0]).
%%====================================================================
%% Main functions
%%====================================================================
@juanbono
juanbono / gist:5f09876c3393ca801fce69e4a9db7c3b
Created December 2, 2019 23:19 — forked from lukego/gist:3952159
Erlang literate programming
Simple literate programming.
Add comments to your Erlang file with a special %%% syntax, like this:
%%% This is a comment that will be formatted in a variable width font with Markdown.
%%% You can use *emphasis* and
%%% # Headings
%%% and even
%%%
%%% - Lists
@juanbono
juanbono / stlc.prolog
Created October 23, 2019 12:19 — forked from kayceesrk/stlc.prolog
Type inference and program synthesis from simply typed lambda calculus type checking rules
?- set_prolog_flag(occurs_check,true).
lookup([(X,A)|_],X,A).
lookup([(Y,_)|T],X,A) :- \+ X = Y, lookup(T,X,A).
/* Rules from the STLC lecture */
pred(D,DD) :- D >= 0, DD is D - 1.
type(_,u,unit,D) :- pred(D,_).
@juanbono
juanbono / sql_parser.exs
Created October 13, 2019 13:51 — forked from sasa1977/sql_parser.exs
Basic SQL parser developed at WebCamp Zagreb, 2019
defmodule SqlParser do
def run() do
input = "select col1 from (
select col2, col3 from (
select col4, col5, col6 from some_table
)
)
"
IO.puts("input: #{inspect(input)}\n")
IO.inspect(parse(input))
@juanbono
juanbono / RegAlloc1.hs
Created April 18, 2019 20:12 — forked from thoughtpolice/RegAlloc1.hs
Simple register allocation, see "Essentials of Compilation" for more https://jeapostrophe.github.io/courses/2017/spring/406/notes/book.pdf
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PartialTypeSignatures #-}
module RegAlloc1
( -- * Types
Var