33 |
34 |
35 |
36 | // class Logger
37 | // {
38 |
39 | // public:
40 |
41 | // /// Retrieves the singleton pointer
42 | // static Logger & get()
43 | // {
44 | // static Logger logger;
45 | // return logger;
46 | // }
47 |
48 | // private:
49 |
50 | // /// Private constructor
51 | // Logger();
52 |
53 | // *
54 | // * Factory method for creating a logger object
55 | // * @param name : Name of logger object
56 | // * @param debug_flag : True to set debug level to info, false for all levels
57 |
58 | // void create(const std::string & name, const bool debug_flag);
59 |
60 | // };
61 |
--------------------------------------------------------------------------------
/unused/wci/intermediate/ICode.h:
--------------------------------------------------------------------------------
1 | /**
2 | * ICode
3 | *
4 | * The framework interface that represents the intermediate code.
5 | *
6 | * Copyright (c) 2017 by Ronald Mak
7 | * For instructional purposes only. No warranties.
8 | */
9 | #ifndef WCI_INTERMEDIATE_ICODE_H_
10 | #define WCI_INTERMEDIATE_ICODE_H_
11 |
12 | namespace wci { namespace intermediate {
13 |
14 | class ICodeNode; // forward declaration
15 |
16 | class ICode
17 | {
18 | public:
19 | /**
20 | * Destructor.
21 | */
22 | virtual ~ICode() {};
23 |
24 | /**
25 | * Get the root node.
26 | * @return the root node.
27 | */
28 | virtual ICodeNode *get_root() const = 0;
29 |
30 | /**
31 | * Set and return the root node.
32 | * @param node the node to set as root.
33 | * @return the root node.
34 | */
35 | virtual ICodeNode *set_root(ICodeNode *node) = 0;
36 | };
37 |
38 | }} // namespace wci::intermediate
39 |
40 | #endif /* WCI_INTERMEDIATE_ICODE_H_ */
41 |
--------------------------------------------------------------------------------
/unused/wci/intermediate/ICodeFactory.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * ICodeFactory
3 | *
4 | * A factory for creating objects that implement the intermediate code.
5 | *
6 | * Copyright (c) 2017 by Ronald Mak
7 | * For instructional purposes only. No warranties.
8 | */
9 | #include "ICodeFactory.h"
10 | #include "ICode.h"
11 | #include "ICodeNode.h"
12 | #include "icodeimpl/ICodeImpl.h"
13 | #include "icodeimpl/ICodeNodeImpl.h"
14 |
15 | namespace wci { namespace intermediate {
16 |
17 | using namespace wci::intermediate::icodeimpl;
18 |
19 | ICode *ICodeFactory::create_icode()
20 | {
21 | return new ICodeImpl();
22 | }
23 |
24 | ICodeNode *ICodeFactory::create_icode_node(const ICodeNodeType type)
25 | {
26 | return new ICodeNodeImpl(type);
27 | }
28 |
29 | }} // namespace wci::intermediate
30 |
--------------------------------------------------------------------------------
/unused/wci/intermediate/ICodeFactory.h:
--------------------------------------------------------------------------------
1 | /**
2 | * ICodeFactory
3 | *
4 | * A factory for creating objects that implement the intermediate code.
5 | *
6 | * Copyright (c) 2017 by Ronald Mak
7 | * For instructional purposes only. No warranties.
8 | */
9 | #include "ICode.h"
10 | #include "ICodeNode.h"
11 |
12 | #ifndef ICODEFACTORY_H_
13 | #define ICODEFACTORY_H_
14 |
15 | namespace wci { namespace intermediate {
16 |
17 | class ICodeFactory
18 | {
19 | public:
20 | /**
21 | * Create and return an intermediate code implementation.
22 | * @return the intermediate code implementation.
23 | */
24 | static ICode *create_icode();
25 |
26 | /**
27 | * Create and return a node implementation.
28 | * @param type the node type.
29 | * @return the node implementation.
30 | */
31 | static ICodeNode *create_icode_node(const ICodeNodeType type);
32 | };
33 |
34 | }} // namespace wci::intermediate
35 |
36 | #endif /* ICODEFACTORY_H_ */
37 |
--------------------------------------------------------------------------------
/unused/wci/intermediate/SymTabFactory.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * SymTabFactory
3 | *
4 | * A factory for creating objects that implement the symbol table.
5 | *
6 | * Copyright (c) 2017 by Ronald Mak
7 | * For instructional purposes only. No warranties.
8 | */
9 | #include "SymTabFactory.h"
10 | #include "SymTab.h"
11 | #include "SymTabEntry.h"
12 | #include "SymTabStack.h"
13 | #include "symtabimpl/SymTabImpl.h"
14 | #include "symtabimpl/SymTabEntryImpl.h"
15 | #include "symtabimpl/SymTabStackImpl.h"
16 |
17 | namespace wci { namespace intermediate {
18 |
19 | using namespace std;
20 | using namespace wci::intermediate::symtabimpl;
21 |
22 | SymTabStack *SymTabFactory::create_symtab_stack()
23 | {
24 | return new SymTabStackImpl();
25 | }
26 |
27 | SymTab *SymTabFactory::create_symtab(int nesting_level)
28 | {
29 | return new SymTabImpl(nesting_level);
30 | }
31 |
32 | SymTabEntry *SymTabFactory::create_symtab_entry(string name, SymTab *symtab)
33 | {
34 | return new SymTabEntryImpl(name, symtab);
35 | }
36 |
37 | }} // namespace wci::intermediate
38 |
--------------------------------------------------------------------------------
/unused/wci/intermediate/SymTabFactory.h:
--------------------------------------------------------------------------------
1 | /**
2 | * SymTabFactory
3 | *
4 | * A factory for creating objects that implement the symbol table.
5 | *
6 | * Copyright (c) 2017 by Ronald Mak
7 | * For instructional purposes only. No warranties.
8 | */
9 | #ifndef WCI_INTERMEDIATE_SYMTABFACTORY_CPP_
10 | #define WCI_INTERMEDIATE_SYMTABFACTORY_CPP_
11 |
12 | #include "symtabimpl/SymTabImpl.h"
13 | #include "symtabimpl/SymTabEntryImpl.h"
14 | #include "symtabimpl/SymTabStackImpl.h"
15 |
16 | namespace wci { namespace intermediate {
17 |
18 | using namespace std;
19 |
20 | class SymTabFactory
21 | {
22 | public:
23 | /**
24 | * Create and return a symbol table stack implementation.
25 | * @return the symbol table implementation.
26 | */
27 | static SymTabStack *create_symtab_stack();
28 |
29 | /**
30 | * Create and return a symbol table implementation.
31 | * @param nesting_level the nesting level.
32 | * @return the symbol table implementation.
33 | */
34 | static SymTab *create_symtab(int nesting_level);
35 |
36 | /**
37 | * Create and return a symbol table entry implementation.
38 | * @param name the identifier name.
39 | * @param symtab the symbol table that contains this entry.
40 | * @return the symbol table entry implementation.
41 | */
42 | static SymTabEntry *create_symtab_entry(string name, SymTab *symtab);
43 | };
44 |
45 | }} // namespace wci::intermediate
46 |
47 | #endif /* WCI_INTERMEDIATE_SYMTABFACTORY_CPP_ */
48 |
--------------------------------------------------------------------------------
/unused/wci/intermediate/TypeFactory.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * TypeFactory
3 | *
4 | * A factory for creating type specifications.
5 | *
6 | * Copyright (c) 2017 by Ronald Mak
7 | * For instructional purposes only. No warranties.
8 | */
9 | #include
10 | #include "TypeFactory.h"
11 | #include "TypeSpec.h"
12 | #include "typeimpl/TypeSpecImpl.h"
13 |
14 | namespace wci { namespace intermediate {
15 |
16 | using namespace std;
17 | using namespace wci::intermediate::typeimpl;
18 |
19 | TypeSpec *TypeFactory::create_type(const TypeFormImpl form)
20 | {
21 | return new TypeSpecImpl(form);
22 | }
23 |
24 | TypeSpec *TypeFactory::create_string_type(const string value)
25 | {
26 | return new TypeSpecImpl(value);
27 | }
28 |
29 | }} // namespace wci::intermediate
30 |
--------------------------------------------------------------------------------
/unused/wci/intermediate/TypeFactory.h:
--------------------------------------------------------------------------------
1 | /**
2 | * TypeFactory
3 | *
4 | * A factory for creating type specifications.
5 | *
6 | * Copyright (c) 2017 by Ronald Mak
7 | * For instructional purposes only. No warranties.
8 | */
9 | #ifndef TYPEFACTORY_H_
10 | #define TYPEFACTORY_H_
11 |
12 | #include
13 | #include "TypeSpec.h"
14 |
15 | namespace wci { namespace intermediate {
16 |
17 | using namespace std;
18 |
19 | class TypeFactory
20 | {
21 | public:
22 | /**
23 | * Create a type specification of a given form.
24 | * @param form the form.
25 | * @return the type specification.
26 | */
27 | static TypeSpec *create_type(const TypeFormImpl form);
28 |
29 | /**
30 | * Create a string type specification.
31 | * @param value the string value.
32 | * @return the type specification.
33 | */
34 | static TypeSpec *create_string_type(const string value);
35 | };
36 |
37 | }} // namespace wci::intermediate
38 |
39 | #endif /* TYPEFACTORY_H_ */
40 |
--------------------------------------------------------------------------------
/unused/wci/intermediate/icodeimpl/ICodeImpl.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * ICodeImpl
3 | *
4 | * An implementation of the intermediate code as a parse tree.
5 | *
6 | * Copyright (c) 2017 by Ronald Mak
7 | * For instructional purposes only. No warranties.
8 | */
9 | #include "ICodeImpl.h"
10 | #include "../ICodeNode.h"
11 |
12 | namespace wci { namespace intermediate { namespace icodeimpl {
13 |
14 | using namespace wci::intermediate;
15 |
16 | ICodeNode *ICodeImpl::get_root() const { return root; }
17 |
18 | ICodeNode *ICodeImpl::set_root(ICodeNode *node)
19 | {
20 | root = node;
21 | return node;
22 | }
23 |
24 | }}} // namespace wci::intermediate::icodeimpl
25 |
--------------------------------------------------------------------------------
/unused/wci/intermediate/icodeimpl/ICodeImpl.h:
--------------------------------------------------------------------------------
1 | /**
2 | * ICodeImpl
3 | *
4 | * An implementation of the intermediate code as a parse tree.
5 | *
6 | * Copyright (c) 2017 by Ronald Mak
7 | * For instructional purposes only. No warranties.
8 | */
9 | #ifndef ICODEIMPL_H_
10 | #define ICODEIMPL_H_
11 |
12 | #include "../ICode.h"
13 |
14 | namespace wci { namespace intermediate { namespace icodeimpl {
15 |
16 | class ICodeImpl : public ICode
17 | {
18 | public:
19 | /**
20 | * Get the root node.
21 | * @return the root node.
22 | */
23 | ICodeNode *get_root() const;
24 |
25 | /**
26 | * Set and return the root node.
27 | * @param node the node to set as root.
28 | * @return the root node.
29 | */
30 | ICodeNode *set_root(ICodeNode *node);
31 |
32 | private:
33 | ICodeNode *root;
34 | };
35 |
36 | }}} // namespace wci::intermediate::icodeimpl
37 |
38 | #endif /* ICODEIMPL_H_ */
39 |
--------------------------------------------------------------------------------