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
5
5
CPP = g++
6
6
CPPFLAGS = -std=c++20 -O3
7
7
TARGET = psc
8
+ PROGS = pscexamples
8
9
9
10
AUTOGEN = Parser.hpp Parser.cpp Lexer.cpp Location.hpp
10
11
OBJS = Lexer.o Parser.o main.o
12
+ PROGS_OBJS = pscexamples.o
11
13
12
- all : $(TARGET )
14
+ all : $(TARGET ) $( PROGS )
13
15
14
16
$(AUTOGEN ) : scanner.l grammar.y
15
17
$(BISON ) grammar.y
@@ -21,8 +23,11 @@ $(AUTOGEN): scanner.l grammar.y
21
23
$(TARGET ) : $(AUTOGEN ) $(OBJS )
22
24
$(CPP ) $(CPPFLAGS ) -o $(TARGET ) $(OBJS )
23
25
26
+ $(PROGS ) : $(PROGS_OBJS )
27
+ $(CPP ) $(CPPFLAGS ) -o $(PROGS ) $(PROGS_OBJS )
28
+
24
29
clean :
25
- rm -f $(TARGET ) $(AUTOGEN ) $(OBJS )
30
+ rm -f $(PROGS ) $( PROGS_OBJS ) $( TARGET ) $(AUTOGEN ) $(OBJS )
26
31
27
32
# Static dependencies
28
33
Lexer.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)
13
13
Target = psc.exe
14
14
Objs = Lexer.obj Parser.obj main.obj
15
15
Autogen = Lexer.cpp Parser.hpp Parser.cpp Location.hpp
16
+ Progs = pscexamples.exe
17
+ ProgsObjs = pscexamples.obj
16
18
17
- all: $(Target)
19
+ all: $(Target) $(Progs)
18
20
19
21
$(Autogen): scanner.l grammar.y
20
22
$(Bison) grammar.y
@@ -26,8 +28,11 @@ $(Autogen): scanner.l grammar.y
26
28
$(Target): $(Autogen) $(Objs)
27
29
$(CPP) $(CPPFlags) /Fe$(Target) $(Objs)
28
30
31
+ $(Progs): $(ProgsObjs)
32
+ $(CPP) $(CPPFlags) /Fe$(Progs) $(ProgsObjs)
33
+
29
34
clean:
30
- del $(Target) $(Objs) $(Autogen)
35
+ del $(Progs) $(ProgsObjs) $( Target) $(Objs) $(Autogen)
31
36
32
37
# Static dependencies
33
38
Lexer.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