summaryrefslogtreecommitdiff
path: root/cli/semantics/expression.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'cli/semantics/expression.hxx')
-rw-r--r--cli/semantics/expression.hxx79
1 files changed, 79 insertions, 0 deletions
diff --git a/cli/semantics/expression.hxx b/cli/semantics/expression.hxx
new file mode 100644
index 0000000..00f62da
--- /dev/null
+++ b/cli/semantics/expression.hxx
@@ -0,0 +1,79 @@
+// file : cli/semantics/expression.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CLI_SEMANTICS_EXPRESSION_HXX
+#define CLI_SEMANTICS_EXPRESSION_HXX
+
+#include <string>
+#include <semantics/elements.hxx>
+
+namespace semantics
+{
+ //
+ //
+ class initialized;
+
+ //
+ //
+ class expression: public node
+ {
+ public:
+ enum expression_type
+ {
+ string_lit,
+ char_lit,
+ bool_lit,
+ int_lit,
+ float_lit,
+ call_expr,
+ identifier
+ };
+
+ expression_type
+ type () const
+ {
+ return type_;
+ }
+
+ std::string const&
+ value () const
+ {
+ return value_;
+ }
+
+ public:
+ initialized&
+ initializes () const
+ {
+ return *initializes_;
+ }
+
+ protected:
+ friend class graph<node, edge>;
+
+ expression (path const& file,
+ size_t line,
+ size_t column,
+ expression_type type,
+ std::string const& value)
+ : node (file, line, column), type_ (type), value_ (value)
+ {
+ }
+
+ void
+ add_edge_right (initialized& e)
+ {
+ initializes_ = &e;
+ }
+
+ private:
+ initialized* initializes_;
+
+ expression_type type_;
+ std::string value_;
+ };
+}
+
+#endif // CLI_SEMANTICS_EXPRESSION_HXX