File tree Expand file tree Collapse file tree 3 files changed +41
-4
lines changed Expand file tree Collapse file tree 3 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,13 @@ BISON = bison
55CPP = g++
66CPPFLAGS = -std=c++20 -O3
77TARGET = psc
8+ PROGS = pscexamples
89
910AUTOGEN = Parser.hpp Parser.cpp Lexer.cpp Location.hpp
1011OBJS = Lexer.o Parser.o main.o
12+ PROGS_OBJS = pscexamples.o
1113
12- all : $(TARGET )
14+ all : $(TARGET ) $( PROGS )
1315
1416$(AUTOGEN ) : scanner.l grammar.y
1517 $(BISON ) grammar.y
@@ -21,8 +23,11 @@ $(AUTOGEN): scanner.l grammar.y
2123$(TARGET ) : $(AUTOGEN ) $(OBJS )
2224 $(CPP ) $(CPPFLAGS ) -o $(TARGET ) $(OBJS )
2325
26+ $(PROGS ) : $(PROGS_OBJS )
27+ $(CPP ) $(CPPFLAGS ) -o $(PROGS ) $(PROGS_OBJS )
28+
2429clean :
25- rm -f $(TARGET ) $(AUTOGEN ) $(OBJS )
30+ rm -f $(PROGS ) $( PROGS_OBJS ) $( TARGET ) $(AUTOGEN ) $(OBJS )
2631
2732# Static dependencies
2833Lexer.o : SymbolTypes.hpp Tree.hpp Expression.hpp Symbol.hpp Lexer.hpp Parser.hpp
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ CPPFlags = /nologo /EHsc /std:c++20 /O2 /wd4005 $(FlexLexer_h)
1313Target = psc.exe
1414Objs = Lexer.obj Parser.obj main.obj
1515Autogen = Lexer.cpp Parser.hpp Parser.cpp Location.hpp
16+ Progs = pscexamples.exe
17+ ProgsObjs = pscexamples.obj
1618
17- all: $(Target)
19+ all: $(Target) $(Progs)
1820
1921$(Autogen): scanner.l grammar.y
2022 $(Bison) grammar.y
@@ -26,8 +28,11 @@ $(Autogen): scanner.l grammar.y
2628$(Target): $(Autogen) $(Objs)
2729 $(CPP) $(CPPFlags) /Fe$(Target) $(Objs)
2830
31+ $(Progs): $(ProgsObjs)
32+ $(CPP) $(CPPFlags) /Fe$(Progs) $(ProgsObjs)
33+
2934clean:
30- del $(Target) $(Objs) $(Autogen)
35+ del $(Progs) $(ProgsObjs) $( Target) $(Objs) $(Autogen)
3136
3237# Static dependencies
3338Lexer.obj: SymbolTypes.hpp Tree.hpp Expression.hpp Symbol.hpp Lexer.hpp Parser.hpp
Original file line number Diff line number Diff line change 1+ // pscexamples.cpp : group pseudocode programs into .js file for web interface
2+ // Note: use ./pscexamples hello.psc chars.psc ... > ../pscexamples.js
3+
4+ #include < iostream>
5+ #include < fstream>
6+ #include < span>
7+ #include < string>
8+
9+ using std::span;
10+ using std::cout;
11+ using std::ifstream;
12+ using std::string;
13+
14+ int main (const int argc, const char **argv) {
15+ span<const char *> args{ argv + 1 , argv + argc };
16+ cout << " pseudocode_examples = [ " ;
17+ for (auto sep = " " ; auto pscfile : args) {
18+ cout << sep << " { name: \' " << pscfile << " \' , code: `" ;
19+ ifstream file (pscfile);
20+ string code;
21+ getline (file, code, ' \0 ' );
22+ cout << code;
23+ cout << " ` }" ;
24+ sep = " , " ;
25+ }
26+ cout << " ];" ;
27+ }
You can’t perform that action at this time.
0 commit comments