Scripts - Also watch included files
This commit is contained in:
parent
915d797a77
commit
e8b3188be9
3 changed files with 20 additions and 3 deletions
|
@ -14,6 +14,7 @@ struct T_OpsParserOutput
|
||||||
{
|
{
|
||||||
opast::T_RootNode root;
|
opast::T_RootNode root;
|
||||||
T_KeyValueTable< T_String , opast::E_DataType > types;
|
T_KeyValueTable< T_String , opast::E_DataType > types;
|
||||||
|
ebcl::T_Set< T_FSPath > files{ ebcl::UseTag< ebcl::ArrayBacked< 16 > >( ) };
|
||||||
};
|
};
|
||||||
|
|
||||||
// The actual parser
|
// The actual parser
|
||||||
|
|
20
c-opmgr.cc
20
c-opmgr.cc
|
@ -88,10 +88,11 @@ void T_ScriptManager::loadScript( ) noexcept
|
||||||
// Load SRD data
|
// Load SRD data
|
||||||
T_SRDMemoryTarget srdOut;
|
T_SRDMemoryTarget srdOut;
|
||||||
srdOut.clearComments( true ).clearFlushToken( true );
|
srdOut.clearComments( true ).clearFlushToken( true );
|
||||||
|
const auto fn{ path_.makeRelative( Common::Project( ).basePath( ) ) };
|
||||||
try {
|
try {
|
||||||
T_SRDTextReader srdReader{ srdOut };
|
T_SRDTextReader srdReader{ srdOut };
|
||||||
T_FileInputStream fis{ input };
|
T_FileInputStream fis{ input };
|
||||||
srdReader.read( path_.toString( ) , fis );
|
srdReader.read( fn.toString( ) , fis );
|
||||||
} catch ( X_StreamError const& e ) {
|
} catch ( X_StreamError const& e ) {
|
||||||
T_StringBuilder sb;
|
T_StringBuilder sb;
|
||||||
sb << "could not load: " << e.what( );
|
sb << "could not load: " << e.what( );
|
||||||
|
@ -115,11 +116,24 @@ void T_ScriptManager::loadScript( ) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the fuck
|
// Parse the fuck
|
||||||
if ( !parser_.parse( path_ , srdOut.list( ) ) ) {
|
const bool parsed{ parser_.parse( path_ , srdOut.list( ) ) };
|
||||||
|
auto pOut{ parser_.result( ) };
|
||||||
|
const auto nf{ pOut->files.size( ) };
|
||||||
|
if ( nf ) {
|
||||||
|
watcher_.clear( );
|
||||||
|
for ( auto i = 0u ; i < nf ; i ++ ) {
|
||||||
|
watcher_.watch( pOut->files[ i ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !parsed ) {
|
||||||
errors_.addAll( parser_.errors( ) );
|
errors_.addAll( parser_.errors( ) );
|
||||||
DumpSRDErrors( "Parse errors" , errors_ );
|
DumpSRDErrors( "Parse errors" , errors_ );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
output_ = compiler_.compile( *parser_.result( ) );
|
|
||||||
|
output_ = compiler_.compile( *pOut );
|
||||||
|
|
||||||
// FIXME - errors from compiler
|
// FIXME - errors from compiler
|
||||||
|
|
||||||
|
printf( "Script loaded & compiled\n" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,6 +342,7 @@ void T_ParserImpl_::main(
|
||||||
assert( file.isAbsolute( ) );
|
assert( file.isAbsolute( ) );
|
||||||
curFile = file.canonical( );
|
curFile = file.canonical( );
|
||||||
baseDir = file.parent( );
|
baseDir = file.parent( );
|
||||||
|
output->files.add( file );
|
||||||
parseTopLevel( input )
|
parseTopLevel( input )
|
||||||
&& checkRequiredBlocks( input )
|
&& checkRequiredBlocks( input )
|
||||||
&& checkCalls( )
|
&& checkCalls( )
|
||||||
|
@ -1082,6 +1083,7 @@ void T_ParserImpl_::handleInclude(
|
||||||
// Parse included file
|
// Parse included file
|
||||||
inclStack.add( curFile );
|
inclStack.add( curFile );
|
||||||
curFile = inclPath;
|
curFile = inclPath;
|
||||||
|
output->files.add( inclPath );
|
||||||
parseTLList( srdOut.list( ) );
|
parseTLList( srdOut.list( ) );
|
||||||
curFile = inclStack.last( );
|
curFile = inclStack.last( );
|
||||||
inclStack.removeLast( );
|
inclStack.removeLast( );
|
||||||
|
|
Loading…
Reference in a new issue