-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
147 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module CPP-DECL-ENUM-SYNTAX | ||
imports BOOL-SYNTAX | ||
imports LIST | ||
imports COMMON-SORTS | ||
imports CPP-SORTS | ||
imports CPP-TYPING-SYNTAX | ||
endmodule | ||
|
||
module CPP-DECL-ENUM | ||
imports CPP-DECL-ENUM-SYNTAX | ||
imports C-CONFIGURATION | ||
imports COMMON-SYNTAX | ||
imports COMPAT-SYNTAX | ||
imports CPP-ABSTRACT-SYNTAX | ||
imports CPP-DYNAMIC-SYNTAX | ||
imports CPP-ENV-SYNTAX | ||
imports CPP-SYNTAX | ||
imports CPP-BITSIZE-SYNTAX | ||
|
||
syntax CPPEnumType ::= declareEnumName(ns: Namespace, id: CId, ut: CPPIntegerType, scoped: Bool) [function] | ||
rule declareEnumName(N::Namespace, X::CId, UT::CPPIntegerType, false) => t(noQuals, .Set, unscopedEnum(enumId(N::Namespace :: X), UT)) | ||
rule declareEnumName(N::Namespace, X::CId, UT::CPPIntegerType, true) => t(noQuals, .Set, scopedEnum(enumId(N::Namespace :: X), UT)) | ||
|
||
syntax KItem ::= addToCurrentNamespace(CId, CPPEnumType) | ||
rule <k> addToCurrentNamespace(X::CId, E::CPPEnumType) => . ... </k> | ||
<curr-scope> namespaceScope(N::Namespace) </curr-scope> | ||
<curr-tu> Tu::String </curr-tu> | ||
<tu-id> Tu </tu-id> | ||
<ns-id> N </ns-id> | ||
<ntypes> NT::Map => NT[X, Enum() <- E] </ntypes> | ||
|
||
// second param -underlying type | ||
syntax KItem ::= newEnum(CPPEnumType) | ||
|
||
rule <k> newEnum(E:CPPEnumType) => . ... </k> | ||
<curr-tu> Tu::String </curr-tu> | ||
<tu-id> Tu </tu-id> | ||
(.Bag => <cppenum>... | ||
<enum-id> getEnumId(E) </enum-id> | ||
<enum-type> E </enum-type> | ||
<scoped> getScoped(E) </scoped> | ||
...</cppenum>) | ||
|
||
syntax KItem ::= enumContext(CId, CPPEnumType) [strict(2)] | ||
|
||
// We do not support enumerators yet | ||
rule <k> EnumDef(X::CId, NoNNS(), Scoped::Bool, Fixed::Bool, UT::CPPIntegerType, .List) | ||
=> enumContext(X, declareEnumName(N, X, UT, Scoped)) ...</k> | ||
<curr-scope> namespaceScope(N::Namespace) </curr-scope> | ||
<curr-tu> Tu::String </curr-tu> | ||
<tu-id> Tu </tu-id> | ||
|
||
rule enumContext(X::CId, E::CPPEnumType) => newEnum(E) ~> addToCurrentNamespace(X, E) | ||
|
||
endmodule | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extern "C" void abort(); | ||
|
||
enum E : int {}; | ||
|
||
E e; | ||
|
||
int main() { | ||
E f = e; | ||
E * g = nullptr; | ||
|
||
if (sizeof(e) != sizeof(int)) | ||
abort(); | ||
} |