Skip to content

Instantly share code, notes, and snippets.

log.log: src.src ./exe.exe
./exe.exe < $< > $@ && tail $(TAIL) $@
C = cpp.cpp $(OS).cpp ypp.tab.cpp lex.yy.c
H = hpp.hpp $(OS).hpp ypp.tab.hpp meta.hpp
CXXFLAGS += -std=gnu++11
./exe.exe: $(C) $(H)
$(CXX) $(CXXFLAGS) -o $@ $(C) $(L)
ypp.tab.cpp: ypp.ypp
bison $<
lex.yy.c: lpp.lpp
#define TITLE "skelex"
#define ABOUT "lexical program skeleton"
#define LICENSE "GNU Lesser GPL"
#define AUTHOR "Dmitry Ponyatov <<dponyatov@gmail.com>>"
#define COPYRIGHT "(c) " AUTHOR " , " LICENSE
#define GITHUB "https://github.com/ponyatov/sym" TITLE
*~
*.swp
*.exe
*.log
ypp.tab.?pp
lex.yy.c
@start .
@gvim -p src.src log.log ypp.ypp lpp.lpp hpp.hpp cpp.cpp
@rem Makefile .gitignore bat.bat README.md
@ponyatov
ponyatov / hpp.hpp
Created August 18, 2016 10:32
.hpp include once
#ifndef _H_HPP
#define _H_HPP
...
#endif // _H_HPP
rem first create your project on github & clone it locally
git clone -o gh git@github.com:ponyatov/skelex.git
rem create project files
cd skelex
touch src.src log.log ypp.ypp lpp.lpp hpp.hpp cpp.cpp Makefile .gitignore bat.bat
rem create (g)vim helper for windows
echo @gvim -p src.src log.log ypp.ypp lpp.lpp hpp.hpp cpp.cpp Makefile .gitignore bat.bat >> bat.bat
@ponyatov
ponyatov / hpp.hpp
Last active August 18, 2016 12:12
parser-enabled program required #includes
#ifndef _H_HPP
#define _H_HPP
// required includes
#include <iostream>
#include <cstdlib>
#include <vector>
#include <map>
using namespace std;
#include "meta.hpp"
// algebraic data type (base class)
@ponyatov
ponyatov / RPython_FORTH.py
Created March 25, 2017 09:06
Using PLY with RPython (FORTH-like VM)
src = '''
nop
nop
.
1 2 3
.
bye
'''
D = [] # data stack
# for https://www.youtube.com/watch?v=v6y-57zw3zg
src = '''
nop
nop
.
1 + 2 * 3
.
bye
'''
@ponyatov
ponyatov / ESD.peg
Created February 8, 2019 05:41
ESD parser grammar
splitter "parse words divided by spaces"
= _? x:(y:word _? { return y } )* { return x }
word
= number
/ w:[^ \t\n\r]+ { return w.join('') }
_ "space"
= s:[ \t\n\r]+ { return s.join('') }