Oh, this whole approach to operator parsing is totally wrong! Making a backup commit...
[fridhskrift.git] / frith / intermediary.hpp
blob1da3c0ff1a0dcc98e5ef7215c5f54911515e18a0
1 #pragma once
3 #include <string>
4 #include <vector>
5 #include <frith/symbol.hpp>
7 namespace frith
9 namespace match_result
11 enum type
13 no_match,
14 match,
15 error,
19 namespace process_line_result
21 enum type
23 ok,
24 end_of_block,
25 error,
29 namespace operator_precedence
31 enum type
33 selection,
35 negation,
36 logical_not,
37 binary_not,
39 exponentiation,
41 multiplication,
42 division,
43 modulo,
45 addition,
46 subtraction,
48 shift_left,
49 shift_right,
51 less_than,
52 less_than_or_equal,
54 greater_than,
55 greater_than_or_equal,
57 equal,
58 not_equal,
60 binary_and,
61 binary_or,
63 logical_and,
64 logical_or,
68 struct sorted_binary_operator_entry
71 std::size_t index;
74 class intermediary_translator
76 public:
77 intermediary_translator();
78 bool load_module(std::string const & path, std::string const & name, std::string & error_message);
80 private:
81 bool running;
83 module main_module;
84 std::vector<module> modules;
86 std::size_t
87 line_offset,
88 line_end;
90 uword indentation_level;
92 std::size_t
93 lexeme_offset,
94 lexeme_end;
96 std::string error_message;
98 uword nested_class_level;
100 std::vector<line_of_code> lines;
102 symbol_tree_node * current_node;
104 bool name_is_used(std::string const & name);
105 std::string const & get_declaration_name();
106 bool name_collision_check();
107 symbol_tree_node & add_name(symbol::type symbol_type);
108 match_result::type process_body(function * current_function = 0);
110 bool parse_statement(lexeme_container & lexemes, std::size_t offset, std::size_t end, symbol_tree_node & output);
112 match_result::type process_class();
113 match_result::type process_function();
114 bool process_statement(function & current_function);
115 process_line_result::type process_line(function * active_function = 0);
117 bool translate_data(module & target_module, std::string const & data, std::string const & module_name, std::string & error_message_output);
119 bool error(std::string const & message);
122 void lexeme_to_argument_node(lexeme & input, parse_tree_node & output);
123 void lexeme_to_unary_operator_node(lexeme & input, parse_tree_node & output, parse_tree_node & argument);
124 void lexeme_to_binary_operator_node(lexeme & input, parse_tree_node & output, parse_tree_node & left_argument, parse_tree_node & right_argument);