Skip to content

Commit

Permalink
some work on parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed Oct 16, 2023
1 parent 523c210 commit 05779a9
Show file tree
Hide file tree
Showing 8 changed files with 393 additions and 30 deletions.
3 changes: 3 additions & 0 deletions include/dlplan/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,9 @@ class VocabularyInfo {
const Predicate& add_predicate(const std::string &name, int arity, bool is_static=false);
const Constant& add_constant(const std::string& name);

const std::unordered_map<std::string, PredicateIndex> get_predicates_mapping() const;
const std::unordered_map<std::string, ConstantIndex> get_constants_mapping() const;

const std::vector<Predicate>& get_predicates() const;
const std::vector<Constant>& get_constants() const;

Expand Down
6 changes: 2 additions & 4 deletions include/dlplan/core/parsers/elements/stage_1/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ namespace dlplan::core::parsers::elements::stage_1::ast
struct SumConceptDistanceNumerical;
struct SumRoleDistanceNumerical;
struct AndRole;
struct Arg1Role;
struct Arg2Role;
struct Arg3Role;
struct ComposeRole;
struct DiffRole;
struct IdentityRole;
Expand Down Expand Up @@ -171,7 +168,8 @@ namespace dlplan::core::parsers::elements::stage_1::ast
};

struct InclusionBoolean : x3::position_tagged {
ConceptOrRole element;
ConceptOrRole element_left;
ConceptOrRole element_right;
};

struct NullaryBoolean : x3::position_tagged {
Expand Down
8 changes: 4 additions & 4 deletions include/dlplan/core/parsers/elements/stage_2/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@

namespace dlplan::core::parsers::elements::stage_2::parser {

extern std::shared_ptr<const Boolean> parse_boolean(
extern std::shared_ptr<const Boolean> parse(
const stage_1::ast::Boolean& node,
const error_handler_type& error_handler,
SyntacticElementFactory& element_factory);

extern std::shared_ptr<const Numerical> parse_numerical(
extern std::shared_ptr<const Numerical> parse(
const stage_1::ast::Numerical& node,
const error_handler_type& error_handler,
SyntacticElementFactory& element_factory);

extern std::shared_ptr<const Concept> parse_concept(
extern std::shared_ptr<const Concept> parse(
const stage_1::ast::Concept& node,
const error_handler_type& error_handler,
SyntacticElementFactory& element_factory);

extern std::shared_ptr<const Role> parse_role(
extern std::shared_ptr<const Role> parse(
const stage_1::ast::Role& node,
const error_handler_type& error_handler,
SyntacticElementFactory& element_factory);
Expand Down
8 changes: 4 additions & 4 deletions src/core/element_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ std::shared_ptr<const Concept> SyntacticElementFactoryImpl::parse_concept(Syntac
}

/* Stage 2 parse */
auto feature = parsers::elements::stage_2::parser::parse_concept(ast, error_handler, parent);
auto feature = parsers::elements::stage_2::parser::parse(ast, error_handler, parent);

return feature;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ std::shared_ptr<const Role> SyntacticElementFactoryImpl::parse_role(SyntacticEle
}

/* Stage 2 parse */
auto feature = parsers::elements::stage_2::parser::parse_role(ast, error_handler, parent);
auto feature = parsers::elements::stage_2::parser::parse(ast, error_handler, parent);

return feature;
}
Expand Down Expand Up @@ -176,7 +176,7 @@ std::shared_ptr<const Boolean> SyntacticElementFactoryImpl::parse_boolean(Syntac
}

/* Stage 2 parse */
auto feature = parsers::elements::stage_2::parser::parse_boolean(ast, error_handler, parent);
auto feature = parsers::elements::stage_2::parser::parse(ast, error_handler, parent);

return feature;
}
Expand Down Expand Up @@ -217,7 +217,7 @@ std::shared_ptr<const Numerical> SyntacticElementFactoryImpl::parse_numerical(Sy
}

/* Stage 2 parse */
auto feature = parsers::elements::stage_2::parser::parse_numerical(ast, error_handler, parent);
auto feature = parsers::elements::stage_2::parser::parse(ast, error_handler, parent);

return feature;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/parsers/elements/stage_1/ast_adapted.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BOOST_FUSION_ADAPT_STRUCT(dlplan::core::parsers::elements::stage_1::ast::Role, r
BOOST_FUSION_ADAPT_STRUCT(dlplan::core::parsers::elements::stage_1::ast::Element, element)
BOOST_FUSION_ADAPT_STRUCT(dlplan::core::parsers::elements::stage_1::ast::ConceptOrRole, inner)
BOOST_FUSION_ADAPT_STRUCT(dlplan::core::parsers::elements::stage_1::ast::EmptyBoolean, element)
BOOST_FUSION_ADAPT_STRUCT(dlplan::core::parsers::elements::stage_1::ast::InclusionBoolean, element)
BOOST_FUSION_ADAPT_STRUCT(dlplan::core::parsers::elements::stage_1::ast::InclusionBoolean, element_left, element_right)
BOOST_FUSION_ADAPT_STRUCT(dlplan::core::parsers::elements::stage_1::ast::NullaryBoolean, predicate)
BOOST_FUSION_ADAPT_STRUCT(dlplan::core::parsers::elements::stage_1::ast::AllConcept, role, concept_)
BOOST_FUSION_ADAPT_STRUCT(dlplan::core::parsers::elements::stage_1::ast::AndConcept, concept_left, concept_right)
Expand Down
3 changes: 2 additions & 1 deletion src/core/parsers/elements/stage_1/parser_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ namespace dlplan::core::parsers::elements::stage_1::parser

const auto empty_boolean_def = lit("b_empty") > lit('(') > concept_or_role > lit(')');

const auto inclusion_boolean_def = lit("b_inclusion") > lit('(') > concept_or_role > lit(')');
// could change this to two_concept_or_two_role to produce more verbose error
const auto inclusion_boolean_def = lit("b_inclusion") > lit('(') > concept_or_role > lit(',') > concept_or_role > lit(')');

const auto nullary_boolean_def = lit("b_nullary") > lit('(') > predicate > lit(')');

Expand Down
Loading

0 comments on commit 05779a9

Please sign in to comment.