The general idea seems to be working.
I also went with "{}" syntax.
Now to see about pre-parsing ints for speed?
This commit is contained in:
@ -10,7 +10,7 @@ namespace
|
||||
|
||||
namespace C
|
||||
{
|
||||
constexpr bool debug= false or true;
|
||||
constexpr bool debug= false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,11 +52,12 @@ namespace Dillo::Hydrogen::JavaScriptForge ::detail:: StackMachine_m
|
||||
StackMachine::runWord( const std::string_view word )
|
||||
{
|
||||
if( C::debug ) std::cerr << "Processing token: " << word << std::endl;
|
||||
if( C::debug ) std::cerr << "Conditional depth is: " << conditionals.size() << std::endl;
|
||||
const bool inConditional= not conditionals.empty();
|
||||
|
||||
if( false );
|
||||
else if( word.empty() );
|
||||
else if( word == "@enddef" )
|
||||
else if( word == "}" )
|
||||
{
|
||||
if( not definition.has_value() )
|
||||
{
|
||||
@ -85,7 +86,7 @@ namespace Dillo::Hydrogen::JavaScriptForge ::detail:: StackMachine_m
|
||||
}
|
||||
else if( inConditional and currentState != conditionals.back() )
|
||||
{
|
||||
if( word != "@if" )
|
||||
if( word == "@if" )
|
||||
{
|
||||
conditionals.push_back( Skipped );
|
||||
resumeConditionals.push_back( currentState );
|
||||
@ -169,11 +170,11 @@ namespace Dillo::Hydrogen::JavaScriptForge ::detail:: StackMachine_m
|
||||
resumeConditionals.push_back( currentState );
|
||||
currentState= If;
|
||||
}
|
||||
else if( word == "@define" )
|
||||
else if( word == "{" )
|
||||
{
|
||||
if( definition.has_value() ) throw std::runtime_error{ "Nested definitions not supported." };
|
||||
|
||||
definition= next();
|
||||
definition= pop();
|
||||
|
||||
if( C::debug ) std::cerr << "Starting function definition for " << definition.value() << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user