diff options
| author | Raymaekers Luca <luca@spacehb.net> | 2025-03-18 11:26:40 +0100 | 
|---|---|---|
| committer | Raymaekers Luca <luca@spacehb.net> | 2025-03-18 11:26:40 +0100 | 
| commit | fee81a2dbda7791f462adc70e080e4bb6e96365f (patch) | |
| tree | 22eeb8e39ecf018bbad00a7e327d47bf8e389c14 | |
| parent | c1cbf799aef1393fecd707b6121c8a3d94d0a773 (diff) | |
Bug fixes
Fixed not outputting '@' if no keyword follows
Fixed not outputting newline after @expand expression
| -rwxr-xr-x | build/metac | bin | 32816 -> 28576 bytes | |||
| -rw-r--r-- | examples/table.c (renamed from source/table.c) | 12 | ||||
| -rwxr-xr-x | examples/table.meta | bin | 0 -> 15488 bytes | |||
| -rw-r--r-- | examples/table.meta.c (renamed from source/table.meta.c) | 12 | ||||
| -rw-r--r-- | source/expected.c | 7 | ||||
| -rw-r--r-- | source/meta.c | 16 | ||||
| -rwxr-xr-x | source/table.meta | bin | 21088 -> 0 bytes | 
7 files changed, 15 insertions, 32 deletions
diff --git a/build/metac b/build/metac Binary files differindex cac4e03..790907c 100755 --- a/build/metac +++ b/build/metac diff --git a/source/table.c b/examples/table.c index d2ec1ad..63edb16 100644 --- a/source/table.c +++ b/examples/table.c @@ -3,25 +3,25 @@  @table(name, str) MyEnumTable  {      { A "A" } -    { B "B" } +    { B "Beau Gosse" }      { C "C" }  }  typedef enum {  @expand(MyEnumTable a) -    `MyEnum_$(a.name),` -MyEnum_Count +`    MyEnum_$(a.name),` +    MyEnum_Count  } MyEnum;  char *StringTable[MyEnum_Count] = { -@expand(MyEnumTable a) `$(a.str),` +@expand(MyEnumTable a) +`    $(a.str),`  }; -  int  main(int Argc, char *Args[])  { -    printf("%s\n", StringTable[MyEnum_B]); +    printf("@: %s\n", StringTable[MyEnum_B]);      return 0;  } diff --git a/examples/table.meta b/examples/table.meta Binary files differnew file mode 100755 index 0000000..2976f54 --- /dev/null +++ b/examples/table.meta diff --git a/source/table.meta.c b/examples/table.meta.c index 4f38e0e..5534457 100644 --- a/source/table.meta.c +++ b/examples/table.meta.c @@ -3,19 +3,15 @@  typedef enum { -MyEnum_A, -MyEnum_B, -MyEnum_C, -MyEnum_Count +    MyEnum_A, // "A"    MyEnum_B, // "Beau Gosse"    MyEnum_C, // "C"    MyEnum_Count  } MyEnum;  char *StringTable[MyEnum_Count] = { -"A", -"B", -"C", +    "A", +    "Beau Gosse", +    "C",  }; -  int  main(int Argc, char *Args[])  { diff --git a/source/expected.c b/source/expected.c deleted file mode 100644 index 6db128a..0000000 --- a/source/expected.c +++ /dev/null @@ -1,7 +0,0 @@ -typedef enum { -    MyEnum_A, -    MyEnum_B, -    MyEnum_C, -    MyEnum_Count -} MyEnum; - diff --git a/source/meta.c b/source/meta.c index 1eb643d..9b7faff 100644 --- a/source/meta.c +++ b/source/meta.c @@ -180,12 +180,11 @@ main(int ArgC, char *Args[])      {          Filename = Args[1];      } -#if 1      else      { -        Filename = "table.c"; +        fprintf(stderr, "Usage: %s [filename]\n", Args[0]); +        return 1;      } -#endif      // NOTE(luca): The memory is assumed to stay mapped until program exits, because we will use      // pointers into that memory. @@ -239,7 +238,6 @@ main(int ArgC, char *Args[])                  }                  Assert(ExpressionTable); -                // TODO: not used yet                  while (IsWhitespace(In[At]) && At < InSize) At++;                  Assert(At < InSize);                  ExpressionTableArgumentAt = At; @@ -309,17 +307,13 @@ main(int ArgC, char *Args[])                              memcpy(Out, Expansion.Memory, Expansion.Size);                              Out += Expansion.Size;                          } -                        else if (In[At] == '`') -                        { -                            // ERROR: When the last character is '`' does not print. -                            *Out++ = '\n'; -                        } -                        else +                        else if (In[At] != '`')                          {                              *Out++ = In[At++];                          }                      } +                    *Out++ = '\n';                  }                  Assert(At < InSize); @@ -486,7 +480,7 @@ main(int ArgC, char *Args[])              }              else              { -                // ERROR: What if the code contains a non meta-"@_expand" tag ??? +                *Out++ = '@';                  *Out++ = In[At];              } diff --git a/source/table.meta b/source/table.meta Binary files differdeleted file mode 100755 index 63edbd2..0000000 --- a/source/table.meta +++ /dev/null  | 
