This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('') } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for https://www.youtube.com/watch?v=v6y-57zw3zg | |
src = ''' | |
nop | |
nop | |
. | |
1 + 2 * 3 | |
. | |
bye | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src = ''' | |
nop | |
nop | |
. | |
1 2 3 | |
. | |
bye | |
''' | |
D = [] # data stack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _H_HPP | |
#define _H_HPP | |
... | |
#endif // _H_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@start . | |
@gvim -p src.src log.log ypp.ypp lpp.lpp hpp.hpp cpp.cpp | |
@rem Makefile .gitignore bat.bat README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*~ | |
*.swp | |
*.exe | |
*.log | |
ypp.tab.?pp | |
lex.yy.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |