Skip to content

Instantly share code, notes, and snippets.

@atoone
atoone / Expression Parser.java
Last active December 1, 2015 06:54
Precedence-climbing expression parser declared in a fluent Java style. Note the parsers handle user defined tokens (Token.java) which allows additional meta information to be handled cleanly. The AST is converted into POJOs using annotations that support path-like identifiers, automatic type conversion and discovery of leaf nodes based on type.
/**
* This is a parser for the precedence climbing grammar:
*
* E --> Exp(0)
* Exp(p) --> P {B Exp(q)}
* P --> U Exp(q) | "(" E ")" | v
* B --> "+" | "-" | "*" |"/" | "^" | "||" | "&&" | "="
* U --> "-"
*
* Where successive B are selected according to the precedence p of the parameterized expression Exp(p).
@atoone
atoone / example_output.txt
Created January 7, 2019 14:38
Quick 'n tidy Hex Dump method
- 0000 0000 0000 0000 0000 0000 0000 0000 ................
- 6425 a19c 0001 0003 0000 0000 5554 0500 d%??........UT..
- 011c 2f38 53 ../8S
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ASCII to Binary</title>
<style>
body {
background-color: black;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Stack;
import java.util.regex.Pattern;
public class Day15 {