amath  1.8.5
Simple command line calculator
LoadStatement Class Reference

#include <load.h>

Inheritance diagram for LoadStatement:
Collaboration diagram for LoadStatement:

Public Member Functions

 LoadStatement (const char *file)
 ~LoadStatement ()
char * Execute ()
- Public Member Functions inherited from StatementNode
 StatementNode ()
 StatementNode (const char *text)
virtual ~StatementNode ()
NodeType GetNodeType ()
virtual SyntaxNodeGetNext ()
virtual char * GetTextCode ()
void Attach (SyntaxNode *node)
void Detach (SyntaxNode *node)
void Replace (SyntaxNode *n, SyntaxNode *x)
- Public Member Functions inherited from SyntaxNode
 SyntaxNode ()
virtual ~SyntaxNode ()
void SetFirstNode ()
bool GetFirstNode () const
SyntaxNodeGetParent () const
void SetParent (SyntaxNode *node)
virtual ReductionType GetReductionType ()
virtual void ResetIterator ()

Private Attributes

char * file

Additional Inherited Members

- Protected Attributes inherited from StatementNode
char * statementText
- Protected Attributes inherited from SyntaxNode
bool leftBottom

Detailed Description

Definition at line 35 of file load.h.

Constructor & Destructor Documentation

◆ LoadStatement()

LoadStatement::LoadStatement ( const char *  file)

Definition at line 36 of file load.cpp.

References AllocAndCopy(), file, and StatementNode::StatementNode().

Referenced by Parser::ParseFileStatement().

37  : StatementNode()
38 {
39  AllocAndCopy(&this->file, file);
40 }
unsigned int AllocAndCopy(char **destination, const char *source)
Allocate memory and copy a string into the array.
Definition: alloccpy.c:40
char * file
Definition: load.h:43
Definition: node.cpp:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~LoadStatement()

LoadStatement::~LoadStatement ( )

Definition at line 42 of file load.cpp.

References file.

43 {
44  delete [] file;
45 }
char * file
Definition: load.h:43

Member Function Documentation

◆ Execute()

char * LoadStatement::Execute ( )

Implements StatementNode.

Definition at line 47 of file load.cpp.

References SyntaxNode::Execute(), file, Program::Filesystem, CharBuffer::GetString(), FilesystemBase::LoadTextFile(), Parser::Parse(), and Parser::Parser().

48 {
50  if (input == nullptr)
51  {
52  return static_cast<char*>(MSGNOFILE);
53  }
55  Parser* parser = new Parser(input->GetString());
56  delete input;
58  SyntaxNode* node = parser->Parse();
59  delete parser;
61  node->Execute();
62  delete node;
64  return static_cast<char*>(HELPLOADSUCC);
65 }
Master control class.
Definition: program.h:55
char * GetString() const
Definition: charbuf.cpp:306
Base class for all nodes in a syntax tree.
Definition: nodes.h:65
class FilesystemBase * Filesystem
Definition: program.h:74
Definition: text.h:93
virtual char * Execute()=0
virtual CharBuffer * LoadTextFile(const char *name)=0
char * file
Definition: load.h:43
Definition: text.h:102
SyntaxNode * Parse()
Parses the input into a syntax tree.
Definition: parser.cpp:56
Encapsulate an character array which can be used as a string.
Definition: charbuf.h:44
Encapsulates a recursive descent parser.
Definition: parser.h:49
Here is the call graph for this function:

Member Data Documentation

◆ file

char* LoadStatement::file

Definition at line 43 of file load.h.

Referenced by Execute(), LoadStatement(), and ~LoadStatement().

The documentation for this class was generated from the following files: