aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/gatsc
diff options
context:
space:
mode:
Diffstat (limited to 'c++-libbu++/src/gatsc')
-rw-r--r--c++-libbu++/src/gatsc/main.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/c++-libbu++/src/gatsc/main.cpp b/c++-libbu++/src/gatsc/main.cpp
index c95b914..334131c 100644
--- a/c++-libbu++/src/gatsc/main.cpp
+++ b/c++-libbu++/src/gatsc/main.cpp
@@ -24,6 +24,7 @@ public:
24 Options( int argc, char *argv[] ) : 24 Options( int argc, char *argv[] ) :
25 bCompile( true ), 25 bCompile( true ),
26 bCompress( false ), 26 bCompress( false ),
27 bPrint( false ),
27 bHex( false ) 28 bHex( false )
28 { 29 {
29 addHelpBanner("Gats Compiler\nUsage: gatsc [options] [input]\n"); 30 addHelpBanner("Gats Compiler\nUsage: gatsc [options] [input]\n");
@@ -33,6 +34,8 @@ public:
33 34
34 addOption( bCompile, 'd', "decompile", 35 addOption( bCompile, 'd', "decompile",
35 "Convert binary gats to text gats."); 36 "Convert binary gats to text gats.");
37 addOption( bPrint, 'p', "print",
38 "Print the structure of the input to stdout.");
36 39
37 addOption( bCompress, 'z', "compress", "Compress with deflate."); 40 addOption( bCompress, 'z', "compress", "Compress with deflate.");
38 addOption( bHex, 'x', "hex", "Encode output as hex."); 41 addOption( bHex, 'x', "hex", "Encode output as hex.");
@@ -43,6 +46,7 @@ public:
43 46
44 setOverride("decompile", false ); 47 setOverride("decompile", false );
45 setOverride("compress", true ); 48 setOverride("compress", true );
49 setOverride("print", true );
46 setOverride("hex", true ); 50 setOverride("hex", true );
47 51
48 parse( argc, argv ); 52 parse( argc, argv );
@@ -56,6 +60,7 @@ public:
56 60
57 bool bCompile; 61 bool bCompile;
58 bool bCompress; 62 bool bCompress;
63 bool bPrint;
59 bool bHex; 64 bool bHex;
60 String sInput; 65 String sInput;
61 String sOutput; 66 String sOutput;
@@ -71,6 +76,21 @@ int main( int argc, char *argv[] )
71 return 1; 76 return 1;
72 } 77 }
73 78
79 if( opt.bPrint )
80 {
81 File fIn( opt.sInput, File::Read );
82 Gats::GatsStream gs( fIn );
83 Gats::Object *pObj = gs.readObject();
84 if( pObj == NULL )
85 {
86 println("Error reading input.");
87 return -1;
88 }
89 sio << *pObj << sio.nl << sio.nl;
90 delete pObj;
91 return -1;
92 }
93
74 if( opt.sOutput.isEmpty() ) 94 if( opt.sOutput.isEmpty() )
75 { 95 {
76 opt.sOutput.set( opt.sInput.begin(), opt.sInput.find('.') ); 96 opt.sOutput.set( opt.sInput.begin(), opt.sInput.find('.') );