$and, $or, $is_const, $assignable, .is_eq, .is_ordered, $defined($vatype(2)) works looking if we can create a type, $defined(foo[0]) $defined(foo()). Remove $checks and @checked. Improvide casting checks to always work without destructive changes.

This commit is contained in:
Christoffer Lerno
2023-10-23 00:21:11 +02:00
committed by Christoffer Lerno
parent 8a12dc5bd4
commit 9af37fe427
46 changed files with 1149 additions and 801 deletions

View File

@@ -2,7 +2,7 @@ module test;
import libc;
/**
* @checked *a = *b, *b = *a
* @require values::@assign_to(*b, *a) && values::@assign_to(*a, *b)
*/
macro void @swap(&a, &b)
{

View File

@@ -39,9 +39,9 @@ int comment_level = 0;
"$alignof" { count(); return(CT_ALIGNOF); }
"$and" { count(); return(CT_AND); }
"$assert" { count(); return(CT_ASSERT); }
"$case" { count(); return(CT_CASE); }
"$checks" { count(); return(CT_CHECKS); }
"$default" { count(); return(CT_DEFAULT); }
"$defined" { count(); return(CT_DEFINED); }
"$echo" { count(); return(CT_ECHO); }
@@ -58,6 +58,7 @@ int comment_level = 0;
"$for" { count(); return(CT_FOR); }
"$foreach" { count(); return(CT_FOREACH); }
"$if" { count(); return(CT_IF); }
"$is_const" { count(); return(CT_IS_CONST); }
"$include" { count(); return(CT_INCLUDE); }
"$nameof" { count(); return(CT_NAMEOF); }
"$offsetof" { count(); return(CT_OFFSETOF); }

View File

@@ -31,9 +31,9 @@ void yyerror(char *s);
%token TRY CATCH SCOPE DEFER LVEC RVEC OPTELSE CT_TYPEFROM CT_TYPEOF TLOCAL
%token CT_VASPLAT INLINE DISTINCT CT_VACONST CT_NAMEOF CT_VAREF CT_VACOUNT CT_VAARG
%token CT_SIZEOF CT_STRINGIFY CT_QNAMEOF CT_OFFSETOF CT_VAEXPR CT_FEATURE
%token CT_EXTNAMEOF CT_EVAL CT_DEFINED CT_CHECKS CT_ALIGNOF ASSERT
%token CT_EXTNAMEOF CT_EVAL CT_DEFINED CT_ALIGNOF ASSERT
%token ASM CHAR_LITERAL REAL TRUE FALSE CT_CONST_IDENT
%token LBRAPIPE RBRAPIPE HASH_CONST_IDENT
%token LBRAPIPE RBRAPIPE HASH_CONST_IDENT CT_CASTABLE CT_ASSIGNABLE CT_AND CT_IS_CONST
%start translation_unit
%%
@@ -71,17 +71,22 @@ local_ident_expr
ct_call
: CT_ALIGNOF
| CT_DEFINED
| CT_EXTNAMEOF
| CT_NAMEOF
| CT_OFFSETOF
| CT_QNAMEOF
;
ct_castable
: CT_ASSIGNABLE
;
ct_analyse
: CT_EVAL
| CT_DEFINED
| CT_SIZEOF
| CT_STRINGIFY
| CT_IS_CONST
;
ct_arg
@@ -140,7 +145,8 @@ base_expr
| ct_analyse '(' expr ')'
| CT_VACOUNT
| CT_FEATURE '(' CONST_IDENT ')'
| CT_CHECKS '(' expression_list ')'
| CT_AND '(' expression_list ')'
| ct_castable '(' expr ',' type ')'
| lambda_decl compound_statement
;