Skip to content

Commit

Permalink
new typeinfo syntax in both old and new parser
Browse files Browse the repository at this point in the history
minus one s\r error in new parser
  • Loading branch information
borisbat committed Oct 31, 2024
1 parent 63826a8 commit 06c8312
Show file tree
Hide file tree
Showing 8 changed files with 28,706 additions and 27,981 deletions.
17 changes: 17 additions & 0 deletions examples/test/misc/hello_world.das
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,23 @@ def test_pipes() {
};
}

///////////
// typeinfo

[comment (i=1,f=2.0,s="three",b=false)]
struct Event {
i : int;
}

[export]
def test_typeinfo( arg : int ) {
let a = typeinfo sizeof(arg);
debug(a);
let b = typeinfo has_field<add>(type<Baz>);
debug(b);
let c = typeinfo struct_get_annotation_argument<comment;s>(type<Event>);
debug(c);
}

///////
// main
Expand Down
2,860 changes: 1,408 additions & 1,452 deletions src/parser/ds2_parser.cpp

Large diffs are not rendered by default.

3,257 changes: 1,576 additions & 1,681 deletions src/parser/ds2_parser.output

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/parser/ds2_parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ expr_type_decl
;

expr_type_info
: DAS_TYPEINFO[loc] '(' name_in_namespace[trait] expr[subexpr] ')' {
: DAS_TYPEINFO[loc] name_in_namespace[trait] '(' expr[subexpr] ')' {
if ( $subexpr->rtti_isTypeDecl() ) {
auto ptd = (ExprTypeDecl *)$subexpr;
$$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,ptd->typeexpr);
Expand All @@ -1445,7 +1445,7 @@ expr_type_info
}
delete $trait;
}
| DAS_TYPEINFO[loc] '(' name_in_namespace[trait] '<' NAME[subtrait] '>' expr[subexpr] ')' {
| DAS_TYPEINFO[loc] name_in_namespace[trait] '<' NAME[subtrait] '>' '(' expr[subexpr] ')' {
if ( $subexpr->rtti_isTypeDecl() ) {
auto ptd = (ExprTypeDecl *)$subexpr;
$$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,ptd->typeexpr,*$subtrait);
Expand All @@ -1456,7 +1456,7 @@ expr_type_info
delete $trait;
delete $subtrait;
}
| DAS_TYPEINFO[loc] '(' name_in_namespace[trait] '<' NAME[subtrait] ';' NAME[extratrait] '>' expr[subexpr] ')' {
| DAS_TYPEINFO[loc] name_in_namespace[trait] '<' NAME[subtrait] ';' NAME[extratrait] '>' '(' expr[subexpr] ')' {
if ( $subexpr->rtti_isTypeDecl() ) {
auto ptd = (ExprTypeDecl *)$subexpr;
$$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,ptd->typeexpr,*$subtrait,*$extratrait);
Expand Down
7,563 changes: 3,820 additions & 3,743 deletions src/parser/ds_parser.cpp

Large diffs are not rendered by default.

Loading

0 comments on commit 06c8312

Please sign in to comment.