Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
wichtounet committed Apr 16, 2014
1 parent b2087e0 commit ab0a2b7
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/parser_x3/SpiritParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,8 @@ using namespace eddic;

namespace x3_ast {

struct function_declaration;
struct import;

struct nil {};

typedef x3::variant<
x3::forward_ast<import>,
x3::forward_ast<function_declaration>
> block;

struct source_file {
std::vector<block> blocks;
};

struct function_declaration {
std::string type;
std::string name;
Expand All @@ -49,6 +37,15 @@ struct import {
std::string file;
};

typedef x3::variant<
function_declaration,
import
> block;

struct source_file {
std::vector<block> blocks;
};

} //end of x3_ast namespace

BOOST_FUSION_ADAPT_STRUCT(
Expand Down Expand Up @@ -80,17 +77,19 @@ namespace x3_grammar {
x3::rule<import_id, x3_ast::import> const import("import");

auto const import_def =
x3::lit("import")
x3::eps
>> x3::lit("import")
>> '"'
>> *x3::alpha
>> '"';
>> '"' ;

auto const function_declaration_def = *x3::alpha >> *x3::alpha >> '(' >> ')';

auto const source_file_def =
*(
import
| function_declaration
x3::eps >>
*(
function_declaration
| import
);

auto const parser = x3::grammar(
Expand Down

0 comments on commit ab0a2b7

Please sign in to comment.