Skip to content
Snippets Groups Projects
Commit 8420a071 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Begin module interface

First module will be the math module which will provide standard math
functions (sin, cos, ...)
parent 64e803fb
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -54,6 +54,8 @@ struct character : if_must_else< one< '\\' >, escaped_c, ascii::any> {};
struct literal : if_must< one< '"' >, until< one< '"' >, character > > {};
struct import_kw : TAO_PEGTL_KEYWORD("import") {};
struct LITERAL : seq< literal, ignored >{};
struct REAL : seq< real, ignored >{};
......@@ -108,9 +110,14 @@ struct cout_kw : TAO_PEGTL_KEYWORD("cout") {};
struct cerr_kw : TAO_PEGTL_KEYWORD("cerr") {};
struct clog_kw : TAO_PEGTL_KEYWORD("clog") {};
struct keywork : sor < basic_type, true_kw, false_kw, do_kw, while_kw, for_kw, if_kw, else_kw, and_kw, or_kw, xor_kw, break_kw, continue_kw, cout_kw, cerr_kw, clog_kw > {};
struct keywork : sor < basic_type, import_kw, true_kw, false_kw, let_kw, do_kw, while_kw, for_kw, if_kw, else_kw, and_kw, or_kw, xor_kw, break_kw, continue_kw, cout_kw, cerr_kw, clog_kw > {};
struct identifier_minus_keyword : minus< identifier, keywork > {};
struct name : minus< identifier, keywork > {};
struct module_name : identifier_minus_keyword {};
struct MODULE_NAME : seq< module_name, ignored > {};
struct name : identifier_minus_keyword {};
struct NAME : seq< name, ignored > {};
struct right_arrow_kw : seq< one< '-' >, one< '>' > > {};
......@@ -269,8 +276,14 @@ struct for_statement_block : seq< sor< braced_instruction_list,
instruction >,
ignored >{};
struct IMPORT : seq< import_kw, ignored >{};
struct import_instruction : if_must< IMPORT, MODULE_NAME , semicol >{};
struct IMPORT_INSTRUCTION : seq<import_instruction, ignored> {};
struct import_list : star< IMPORT_INSTRUCTION > {};
struct instruction_list : star< INSTRUCTION >{};
struct grammar : must<ignored, instruction_list, eof>{};
struct grammar : must<ignored, import_list, instruction_list, eof>{};
template <typename Rule>
struct errors : public normal<Rule>
......@@ -288,6 +301,11 @@ struct errors : public normal<Rule>
template <typename Rule>
inline const std::string errors<Rule>::error_message = "parse error matching "+ internal::demangle< Rule >();
template <>
inline const std::string errors<language::module_name>::error_message = "parse error, missing module name";
template <>
inline const std::string errors<language::MODULE_NAME>::error_message = "parse error, missing module name";
template <>
inline const std::string errors<language::semicol>::error_message = "parse error, missing ';'";
template <>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment