Skip to content

Instantly share code, notes, and snippets.

@jasondown
Created August 3, 2021 13:47
Show Gist options
  • Save jasondown/62ccd3298ad2680c85f5ec48d72c4d7f to your computer and use it in GitHub Desktop.
Save jasondown/62ccd3298ad2680c85f5ec48d72c4d7f to your computer and use it in GitHub Desktop.
public class GlobalVariablesState : ParserState
{
private bool _readyForVariableDeclarations;
public GlobalVariablesState(Parser parser)
: base(parser)
{
}
public override void ReadLine(string line)
{
if (line.StartsWith("procedure ", StringComparison.OrdinalIgnoreCase))
{
Parser.SetState(Parser.ProceduresState);
}
else if (line.IndexOf("=var", StringComparison.OrdinalIgnoreCase) > 0)
{
_readyForVariableDeclarations = true;
}
else if (_readyForVariableDeclarations)
{
// Uses ParseVariables from ParserState base class ParseVariable(line);
}
}
public override void Reset()
{
_readyForVariableDeclarations = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment