aboutsummaryrefslogtreecommitdiff
path: root/src/buildparser.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-08 22:58:28 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-08 22:58:28 +0000
commit52be1ef0d126f09ba943c7afcf367e7d9347f2fd (patch)
treefd4b0dd148751c3c6c1b95296c3b82cb86051b83 /src/buildparser.cpp
parent795d0737fed40d88a7801b451b7750ba90802345 (diff)
downloadbuild-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.tar.gz
build-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.tar.bz2
build-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.tar.xz
build-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.zip
tabconv: it's all spaces now.
Diffstat (limited to '')
-rw-r--r--src/buildparser.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/src/buildparser.cpp b/src/buildparser.cpp
index cf98090..6ab23cd 100644
--- a/src/buildparser.cpp
+++ b/src/buildparser.cpp
@@ -7,9 +7,9 @@
7using Bu::sio; 7using Bu::sio;
8 8
9BuildParser::BuildParser( Ast &rAst ) : 9BuildParser::BuildParser( Ast &rAst ) :
10 xAst( rAst ) 10 xAst( rAst )
11{ 11{
12 lIncludePaths.append("./"); 12 lIncludePaths.append("./");
13 StrList lConds = ConditionPlugger::getInstance().getPluginList(); 13 StrList lConds = ConditionPlugger::getInstance().getPluginList();
14 for( StrList::iterator i = lConds.begin(); i; i++ ) 14 for( StrList::iterator i = lConds.begin(); i; i++ )
15 hConds.insert( *i, true ); 15 hConds.insert( *i, true );
@@ -23,37 +23,37 @@ int build_parse( yyscan_t yyscanner, BuildParser &bld );
23 23
24void BuildParser::load( const Bu::String &sFile ) 24void BuildParser::load( const Bu::String &sFile )
25{ 25{
26 yyscan_t scanner; 26 yyscan_t scanner;
27 27
28 sFilename.push( sFile ); 28 sFilename.push( sFile );
29 FILE *fIn = fopen( sFile.getStr(), "rt" ); 29 FILE *fIn = fopen( sFile.getStr(), "rt" );
30 if( fIn == NULL ) 30 if( fIn == NULL )
31 { 31 {
32 throw Bu::ExceptionBase("Cannot open file: %s", sFile.getStr() ); 32 throw Bu::ExceptionBase("Cannot open file: %s", sFile.getStr() );
33 } 33 }
34 build_lex_init( &scanner ); 34 build_lex_init( &scanner );
35 // build_set_debug( true, scanner ); 35 // build_set_debug( true, scanner );
36 build_set_in( fIn, scanner ); 36 build_set_in( fIn, scanner );
37 37
38 build_parse( scanner, *this ); 38 build_parse( scanner, *this );
39 39
40 build_lex_destroy( scanner ); 40 build_lex_destroy( scanner );
41 fclose( fIn ); 41 fclose( fIn );
42 42
43 // Bu::sio << xAst; 43 // Bu::sio << xAst;
44} 44}
45 45
46bool BuildParser::isKeyword( const Bu::String &sStr ) 46bool BuildParser::isKeyword( const Bu::String &sStr )
47{ 47{
48 if( sStr == "important" ) 48 if( sStr == "important" )
49 return true; 49 return true;
50 if( sStr == "normal" ) 50 if( sStr == "normal" )
51 return true; 51 return true;
52 if( sStr == "hidden" ) 52 if( sStr == "hidden" )
53 return true; 53 return true;
54 if( sStr == "autogenerated" ) 54 if( sStr == "autogenerated" )
55 return true; 55 return true;
56 return false; 56 return false;
57} 57}
58 58
59bool BuildParser::isCond( const Bu::String &sStr ) 59bool BuildParser::isCond( const Bu::String &sStr )
@@ -70,67 +70,67 @@ bool BuildParser::isCond( const Bu::String &sStr )
70 70
71void BuildParser::include( const Bu::String &sStr, void *scanner, YYLTYPE *loc ) 71void BuildParser::include( const Bu::String &sStr, void *scanner, YYLTYPE *loc )
72{ 72{
73 for( StrList::iterator pi = lIncludePaths.begin(); pi; pi++ ) 73 for( StrList::iterator pi = lIncludePaths.begin(); pi; pi++ )
74 { 74 {
75 FILE *fIn = fopen( (*pi + sStr).getStr(), "rt" ); 75 FILE *fIn = fopen( (*pi + sStr).getStr(), "rt" );
76 if( fIn == NULL ) 76 if( fIn == NULL )
77 { 77 {
78 continue; 78 continue;
79 } 79 }
80 sFilename.push( sStr ); 80 sFilename.push( sStr );
81 sLocation.push( *loc ); 81 sLocation.push( *loc );
82 loc->first_line = loc->last_line = 1; 82 loc->first_line = loc->last_line = 1;
83 loc->first_column = loc->last_column = 0; 83 loc->first_column = loc->last_column = 0;
84 build_push_buffer_state( 84 build_push_buffer_state(
85 build__create_buffer( fIn, YY_READ_BUF_SIZE, scanner ), 85 build__create_buffer( fIn, YY_READ_BUF_SIZE, scanner ),
86 scanner 86 scanner
87 ); 87 );
88 Bu::String::const_iterator i = sStr.find('/'); 88 Bu::String::const_iterator i = sStr.find('/');
89 if( i ) 89 if( i )
90 { 90 {
91 for(;;) 91 for(;;)
92 { 92 {
93 Bu::String::const_iterator j = i.find('/'); 93 Bu::String::const_iterator j = i.find('/');
94 if( !j ) 94 if( !j )
95 break; 95 break;
96 i = j+1; 96 i = j+1;
97 } 97 }
98 sio << "Hey, found it from here: " << sStr.getSubStr( sStr.begin(), i ) << sio.nl; 98 sio << "Hey, found it from here: " << sStr.getSubStr( sStr.begin(), i ) << sio.nl;
99 xAst.addNode( AstNode::typePushPrefix, sStr.getSubStr( sStr.begin(), i ) ); 99 xAst.addNode( AstNode::typePushPrefix, sStr.getSubStr( sStr.begin(), i ) );
100 } 100 }
101 else 101 else
102 { 102 {
103 xAst.addNode( AstNode::typePushPrefix, "" ); 103 xAst.addNode( AstNode::typePushPrefix, "" );
104 } 104 }
105 return; 105 return;
106 } 106 }
107 Bu::String msg("Could not open include file: "); 107 Bu::String msg("Could not open include file: ");
108 msg += sStr; 108 msg += sStr;
109 error( 109 error(
110 loc->first_line, loc->last_line, 110 loc->first_line, loc->last_line,
111 loc->first_column, loc->last_column, 111 loc->first_column, loc->last_column,
112 msg 112 msg
113 ); 113 );
114} 114}
115 115
116void BuildParser::endInclude( YYLTYPE *loc ) 116void BuildParser::endInclude( YYLTYPE *loc )
117{ 117{
118 sFilename.pop(); 118 sFilename.pop();
119 memcpy( loc, &sLocation.peek(), sizeof(YYLTYPE) ); 119 memcpy( loc, &sLocation.peek(), sizeof(YYLTYPE) );
120 sLocation.pop(); 120 sLocation.pop();
121 xAst.addNode( AstNode::typePopPrefix ); 121 xAst.addNode( AstNode::typePopPrefix );
122} 122}
123 123
124void BuildParser::error( int iLine1, int iLine2, int iCol1, int iCol2, 124void BuildParser::error( int iLine1, int iLine2, int iCol1, int iCol2,
125 const Bu::String &sMsg ) 125 const Bu::String &sMsg )
126{ 126{
127 throw Bu::ExceptionBase("%s: %d-%d:%d-%d: %s", 127 throw Bu::ExceptionBase("%s: %d-%d:%d-%d: %s",
128 sFilename.peek().getStr(), iLine1, iLine2, iCol1, iCol2, sMsg.getStr() 128 sFilename.peek().getStr(), iLine1, iLine2, iCol1, iCol2, sMsg.getStr()
129 ); 129 );
130} 130}
131 131
132void BuildParser::addIncludePath( const Bu::String &sPath ) 132void BuildParser::addIncludePath( const Bu::String &sPath )
133{ 133{
134 lIncludePaths.append( sPath + "/" ); 134 lIncludePaths.append( sPath + "/" );
135} 135}
136 136