Skip to content

Commit

Permalink
SCParser update (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerjenigeUberMensch authored Sep 24, 2024
1 parent 6aa04fc commit 9ad634f
Show file tree
Hide file tree
Showing 16 changed files with 2,786 additions and 175 deletions.
418 changes: 243 additions & 175 deletions src/parser.c

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions tools/DynamicArray/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Joseph

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
101 changes: 101 additions & 0 deletions tools/DynamicArray/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# GArray

A small (300 lines) dynamic array.

## Example
```C

#include <stdio.h>
#include <stdlib.h>

#include "dynamic_array.h"


int
main(void)
{
uint32_t item_size = sizeof(int);
uint32_t initial_size = 10;
uint32_t i;

GArray *array = GArrayCreate(item_size, initial_size);
if (array == NULL)
{ return EXIT_FAILURE;
}

/* make all data 0's to show it works */
for(i = GArrayStart(array); i < GArrayEnd(array); ++i)
{ GArrayReplace(array, NULL, i);
}

int value = 42;
if (GArrayPushBack(array, &value) != EXIT_SUCCESS)
{
GArrayWipe(array);
free(array);
return EXIT_FAILURE;
}


int *p = (int *)GArrayAt(array, 0);

if (p)
{ printf("Previous Value at index 0: %d\n", *p);
}
else
{
GArrayWipe(array);
free(array);
return EXIT_FAILURE;
}

int new_value = 99;
if (GArrayReplace(array, &new_value, 0) != EXIT_SUCCESS)
{
GArrayWipe(array);
free(array);
return EXIT_FAILURE;
}

p = (int *)GArrayAt(array, 0);
if (p)
{ printf("New value at index 0: %d\n", *p);
}
else
{
GArrayWipe(array);
free(array);
return EXIT_FAILURE;
}

int insert_value = 55;
if (GArrayInsert(array, &insert_value, 1) != EXIT_SUCCESS)
{
GArrayWipe(array);
free(array);
return EXIT_FAILURE;
}

printf("Value at index %d: %d\n", 1, *(int *)GArrayAt(array, 1));
printf("Deleting Index %d\n", 1);

if (GArrayDelete(array, 1) != EXIT_SUCCESS)
{
GArrayWipe(array);
free(array);
return EXIT_FAILURE;
}

for (i = GArrayStart(array); i < GArrayEnd(array); ++i)
{
p = (int *)GArrayAt(array, i);
if (p)
{ printf("Value at index %d: %d\n", i, *p);
}
}

GArrayWipe(array);
free(array);
return EXIT_SUCCESS;
}

12 changes: 12 additions & 0 deletions tools/DynamicArray/array.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef __F____ARRAY__H__
#define __F____ARRAY__H__


#include "dynamic_array.h"
#include "array8.h"
#include "array16.h"
#include "array32.h"
#include "array64.h"
#include "array_p.h"

#endif
Loading

0 comments on commit 9ad634f

Please sign in to comment.