-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
* added new AST structure definition and its syntax - related to ref #35 * updated visitors etc.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,9 +167,11 @@ END 0 "end of file" | |
%type <Definitions::Ptr> Definitions | ||
%type <VariableDefinition::Ptr> Variable AttributedVariable | ||
%type <FunctionDefinition::Ptr> FunctionDefinition | ||
%type <FunctionDefinitions::Ptr> FunctionDefinitions | ||
%type <DerivedDefinition::Ptr> DerivedDefinition | ||
%type <RuleDefinition::Ptr> RuleDefinition | ||
%type <EnumerationDefinition::Ptr> EnumerationDefinition | ||
%type <StructureDefinition::Ptr> StructureDefinition | ||
|
||
// expressions | ||
%type <Expression::Ptr> Expression Term Atom | ||
|
@@ -210,7 +212,7 @@ END 0 "end of file" | |
%type <RelationType::Ptr> RelationType | ||
%type <FixedSizedType::Ptr> FixedSizedType | ||
|
||
// types | ||
// attribute | ||
%type <Attribute::Ptr> Attribute | ||
%type <Attributes::Ptr> Attributes | ||
%type <BasicAttribute::Ptr> BasicAttribute | ||
|
@@ -297,6 +299,10 @@ Definition | |
{ | ||
$$ = $1; | ||
} | ||
| StructureDefinition | ||
{ | ||
$$ = $1; | ||
} | ||
| error // error recovery | ||
{ | ||
$$ = nullptr; | ||
|
@@ -358,6 +364,22 @@ FunctionDefinition | |
; | ||
|
||
|
||
FunctionDefinitions | ||
: FunctionDefinitions COMMA FunctionDefinition | ||
This comment has been minimized.
Sorry, something went wrong. |
||
{ | ||
auto functions = $1; | ||
functions->add( $3 ); | ||
$$ = functions; | ||
} | ||
| FunctionDefinition | ||
{ | ||
auto functions = Ast::make< FunctionDefinitions >( @$ ); | ||
functions->add( $1 ); | ||
$$ = functions; | ||
} | ||
; | ||
|
||
|
||
MaybeInitially | ||
: INITIALLY LCURPAREN MaybeInitializers RCURPAREN | ||
{ | ||
|
@@ -524,6 +546,14 @@ EnumerationDefinition | |
; | ||
|
||
|
||
StructureDefinition | ||
: STRUCTURE Identifier EQUAL LCURPAREN FunctionDefinitions RCURPAREN | ||
This comment has been minimized.
Sorry, something went wrong.
emmanuel099
Member
|
||
{ | ||
$$ = Ast::make< StructureDefinition >( @$, $2, $5 ); | ||
} | ||
; | ||
|
||
|
||
Identifier | ||
: IDENTIFIER | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,3 +306,36 @@ void EnumerationDefinition::accept( Visitor& visitor ) | |
{ | ||
visitor.visit( *this ); | ||
} | ||
|
||
// | ||
// | ||
// StructureDefinition | ||
// | ||
|
||
StructureDefinition::StructureDefinition( const Identifier::Ptr& identifier, | ||
const NodeList< FunctionDefinition >::Ptr& functions ) | ||
This comment has been minimized.
Sorry, something went wrong.
emmanuel099
Member
|
||
: Definition( Node::ID::STRUCTURE_DEFINITION, identifier ) | ||
, m_functions( functions ) | ||
{ | ||
} | ||
|
||
const NodeList< FunctionDefinition >::Ptr& StructureDefinition::functions( | ||
This comment has been minimized.
Sorry, something went wrong.
emmanuel099
Member
|
||
void ) const | ||
{ | ||
return m_functions; | ||
} | ||
|
||
void StructureDefinition::accept( Visitor& visitor ) | ||
{ | ||
visitor.visit( *this ); | ||
} | ||
|
||
// | ||
// Local variables: | ||
// mode: c++ | ||
// indent-tabs-mode: nil | ||
// c-basic-offset: 4 | ||
// tab-width: 4 | ||
// End: | ||
// vim:noexpandtab:sw=4:ts=4: | ||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,8 @@ namespace libcasm_fe | |
UID m_uid; | ||
}; | ||
|
||
using FunctionDefinitions = NodeList< FunctionDefinition >; | ||
|
||
class DerivedDefinition final : public Definition | ||
{ | ||
public: | ||
|
@@ -216,6 +218,22 @@ namespace libcasm_fe | |
private: | ||
const Identifiers::Ptr m_enumerators; | ||
}; | ||
|
||
class StructureDefinition final : public Definition | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr< StructureDefinition >; | ||
|
||
StructureDefinition( const Identifier::Ptr& identifier, | ||
const NodeList< FunctionDefinition >::Ptr& functions ); | ||
This comment has been minimized.
Sorry, something went wrong.
emmanuel099
Member
|
||
|
||
const NodeList< FunctionDefinition >::Ptr& functions( void ) const; | ||
This comment has been minimized.
Sorry, something went wrong.
emmanuel099
Member
|
||
|
||
void accept( Visitor& visitor ) override final; | ||
|
||
private: | ||
const NodeList< FunctionDefinition >::Ptr m_functions; | ||
This comment has been minimized.
Sorry, something went wrong.
emmanuel099
Member
|
||
}; | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,12 @@ void RecursiveVisitor::visit( EnumerationDefinition& node ) | |
node.attributes()->accept( *this ); | ||
} | ||
|
||
void RecursiveVisitor::visit( StructureDefinition& node ) | ||
{ | ||
node.identifier()->accept( *this ); | ||
node.functions()->accept( *this ); | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
emmanuel099
Member
|
||
|
||
void RecursiveVisitor::visit( ValueAtom& node ) | ||
{ | ||
} | ||
|
2 comments
on commit 6997e6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AstDumpDotVisitor
implementation is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed all issues and comments in 452957a...cc64255
I think the
COMMA
should be removed (btw. theAstDumpSourceVisitor
dumps it without commas)