Skip to content

Commit

Permalink
added some more code for the todos and fixed some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruun committed Jun 13, 2024
1 parent 9dc3b5a commit 593c000
Show file tree
Hide file tree
Showing 38 changed files with 152 additions and 41 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified .vs/.DS_Store
Binary file not shown.
Binary file modified .vs/RuanScript/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/RuanScript/v17/.wsuo
Binary file not shown.
Binary file modified .vs/RuanScript/v17/Browse.VC.db
Binary file not shown.
Binary file removed .vs/RuanScript/v17/Browse.VC.db-shm
Binary file not shown.
Empty file.
Binary file removed .vs/RuanScript/v17/Browse.VC.opendb
Binary file not shown.
37 changes: 27 additions & 10 deletions .vs/RuanScript/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"WorkspaceRootPath": "C:\\Mac\\Home\\Downloads\\RuanScript\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\input\\A12.bat||{3B902123-F8A7-4915-9F01-361F908088D0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:input\\A12.bat||{3B902123-F8A7-4915-9F01-361F908088D0}"
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Reader.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\Reader.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\launch.vs.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\launch.vs.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
}
],
"DocumentGroupContainers": [
Expand All @@ -19,14 +23,27 @@
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "A12.bat",
"DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\input\\A12.bat",
"RelativeDocumentMoniker": "input\\A12.bat",
"ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\input\\A12.bat",
"RelativeToolTip": "input\\A12.bat",
"ViewState": "AQIAAD0AAAAAmpmZmZkewFMAAAAAAAAA",
"Icon": "00000000-0000-0000-0000-000000000000.000000|iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAMDSURBVFhH7ZVbSNNRHMe/C\u002BcNdOrU7OIlSc1LpeWltIt2EUyMokDKjMiHCMosi6UUJtEFgrKXHnrtyYeKqAwiC0pBXWYTN10asxQ056R20/X/b\u002Bv8j0eJcG5zpQ/5gbNz2e/w\u002B/x/5/w3LCh2u52NFlk4RFWy83dIXzE5nXfqlpCPf568sGjfjD2hQqiAvfbqdTafX2ouV0OowILitoCq7wuev2nBq\u002BZ2cDzPVueOSwI8SaQ3mul46JsOVqsVJpMZo2M/wHE8RnTf6XdzwSWBd/IuvG1ToLGpHUaTiQoIra1DiWeNTXjd1IaR0TEW7R5OBYa1YzCZzbCRhAby1FablY4FgYmfFlgsFtjIWnevhu1wD6cC0uBAhEmDwNOkPCJCpdibvxUZ6xNh5SdF/Hx8sDZxNdvhHk4FxF5eSIiNmn7qZUuldC0mcjmdCy0sNAghQRK2wz2cCpjME2iWK2giodSdqk\u002B03PKPXVRKaOq\u002BfijVvWyHezgXGB\u002BHwWiiyQUJvcFIkyvVn\u002Bl9mBLTzvFNcCoQLg1GcnwsfMk5ryJlp0dBXkuhD5IEIHJFBPx9fZFEYlo7FBgcGmY7XcOpgIBwwfYX5CE7IxWSwIDps9\u002B8cR3yc3NQcrAImq8DeFD/ELfv3ad7zOZx2jvDi/Uuk5ayBpqBQdhtdnIhw/H4xUu0vu8gQjx4joOFHFnNjVvQjmghO1eO6MiVbOfMuFSB34kmx5CbnYm8LVl03iL/AIPBAG\u002BxGEeLD2BTeho0/f3Q6/VQdffQmNlwW\u002BBPykqKyU81h6wNqcjOTEdZ6WEESySIj4tFQf4uFuUYjwXqHz2hpe/uUWNUp6NPPTw0hE5FJ542NLAox3gs4OMthpUIdClVOF0pQ\u002B21m\u002BQt4egfmL\u002BfP4tyjMcCx48cguxsOXbv2M4Sc7hyqRpVFyqxMy\u002BXRTnGY4FQaQgSE\u002BKwLSebtmOlJUhJTkJWZgaLmB2PBaaIiY7CqZMnUFS4h624xl8TmCuii7LKOhFEZ9h8XrFDdJcNF/lvAX4BFPtSJL7S3gcAAAAASUVORK5CYII=",
"WhenOpened": "2024-06-12T19:10:43.661Z",
"Title": "Reader.c",
"DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Reader.c",
"RelativeDocumentMoniker": "code\\Reader.c",
"ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Reader.c",
"RelativeToolTip": "code\\Reader.c",
"ViewState": "AQIAANMAAAAAAAAAAAAWwOkAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000423|",
"WhenOpened": "2024-06-13T16:55:18.632Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "launch.vs.json",
"DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\launch.vs.json",
"RelativeDocumentMoniker": "code\\launch.vs.json",
"ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\launch.vs.json",
"RelativeToolTip": "code\\launch.vs.json",
"ViewState": "AQIAAAEAAACazMzMzIwjwAkAAAAIAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
"WhenOpened": "2024-06-12T20:34:20.187Z",
"EditorCaption": ""
}
]
Expand Down
Binary file added .vs/RuanScript/v17/Solution.VC.db
Binary file not shown.
Binary file modified .vs/RuanScript/v17/ipch/AutoPCH/52c9afbe93b57e0d/READER.ipch
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"ExpandedNodes": [
"",
"\\code",
"\\code\\.idea",
"\\code\\out",
"\\input"
],
"SelectedNode": "\\code\\Reader.c",
"PreviewInSolutionExplorer": false
}
Binary file modified .vs/slnx.sqlite
Binary file not shown.
77 changes: 61 additions & 16 deletions code/Reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,26 @@
BufferPointer readerCreate(Rs_intg size, Rs_intg increment, Rs_intg mode) {
BufferPointer readerPointer;
/* TO_DO: Defensive programming */
/* Defensive programming: Check for invalid size or increment */
if (size < 0 || increment < 0) {
return NULL;
}
/* TO_DO: Adjust the values according to parameters */
readerPointer = (BufferPointer)calloc(1, sizeof(Buffer));
if (!readerPointer)
return NULL;
if (size != 0)
readerPointer->size = size;
else
readerPointer->size = READER_DEFAULT_SIZE;
if (increment != 0)
readerPointer->increment = increment;
else
readerPointer->increment = READER_DEFAULT_INCREMENT;
if (mode == MODE_ADDIT || mode == MODE_FIXED || mode == MODE_MULTI)
readerPointer->mode = mode;
else
readerPointer->mode = MODE_FIXED;
readerPointer->content = (Rs_string)malloc(size);

/* TO_DO: Defensive programming */
Expand All @@ -102,18 +115,6 @@ BufferPointer readerCreate(Rs_intg size, Rs_intg increment, Rs_intg mode) {
for(int i =0; i < NCHAR; i++)
readerPointer->histogram[i] = 0;

if (size != 0)
readerPointer->size = size;
else
readerPointer->size = READER_DEFAULT_SIZE;
if (increment!= 0)
readerPointer->increment = increment;
else
readerPointer->increment = READER_DEFAULT_INCREMENT;
if (mode == MODE_ADDIT || mode == MODE_FIXED || mode == MODE_MULTI)
readerPointer->increment = increment;
else
readerPointer->increment = MODE_FIXED;
/* TO_DO: Initialize flags */
readerPointer->flags = READER_DEFAULT_FLAG;
/* TO_DO: The created flag must be signalized as EMP */
Expand Down Expand Up @@ -145,13 +146,18 @@ BufferPointer readerCreate(Rs_intg size, Rs_intg increment, Rs_intg mode) {
*/

BufferPointer readerAddChar(BufferPointer const readerPointer, Rs_char ch) {
// Rs_string tempReader = NULL; to be used later
// Rs_intg newSize = 0; to be used later
Rs_string tempReader = NULL;
Rs_intg newSize = 0;
/* TO_DO: Defensive programming */
/* Defensive programming: Check if readerPointer is NULL */
if (!readerPointer) {
return NULL;
}
/* TO_DO: Reset Realocation */
/* TO_DO: Test the inclusion of chars */
if (readerPointer->position.wrte * (Rs_intg)sizeof(Rs_char) < readerPointer->size) {
/* TO_DO: This buffer is NOT full */
readerPointer->content[readerPointer->position.wrte++] = ch;
} else {
/* TO_DO: Reset Full flag */
switch (readerPointer->mode) {
Expand Down Expand Up @@ -194,6 +200,10 @@ BufferPointer readerAddChar(BufferPointer const readerPointer, Rs_char ch) {
*/
Rs_boln readerClear(BufferPointer const readerPointer) {
/* TO_DO: Defensive programming */
/* Defensive programming: Check if readerPointer is NULL */
if (!readerPointer) {
return FALSE;
}
/* TO_DO: Adjust flags original */
readerPointer->position.wrte = readerPointer->position.mark = readerPointer->position.read = 0;
return TRUE;
Expand All @@ -215,7 +225,14 @@ Rs_boln readerClear(BufferPointer const readerPointer) {
*/
Rs_boln readerFree(BufferPointer const readerPointer) {
/* TO_DO: Defensive programming */
/* Defensive programming: Check if readerPointer is NULL */
if (!readerPointer) {
return FALSE;
}
/* TO_DO: Free pointers */
free(readerPointer->content);
free(readerPointer);
//readerPointer = NULL;
return TRUE;
}

Expand All @@ -235,6 +252,9 @@ Rs_boln readerFree(BufferPointer const readerPointer) {
*/
Rs_boln readerIsFull(BufferPointer const readerPointer) {
/* TO_DO: Defensive programming */
if (!readerPointer) {
return FALSE;
}
/* TO_DO: Check flag if buffer is FUL */
return FALSE;
}
Expand All @@ -256,6 +276,9 @@ Rs_boln readerIsFull(BufferPointer const readerPointer) {
*/
Rs_boln readerIsEmpty(BufferPointer const readerPointer) {
/* TO_DO: Defensive programming */
if (!readerPointer) {
return FALSE;
}
/* TO_DO: Check flag if buffer is EMP */
return FALSE;
}
Expand Down Expand Up @@ -519,8 +542,11 @@ Rs_intg readerGetPosWrte(BufferPointer const readerPointer) {
*/
Rs_intg readerGetPosMark(BufferPointer const readerPointer) {
/* TO_DO: Defensive programming */
if (!readerPointer) {
return READER_ERROR;
}
/* TO_DO: Return mark */
return 0;
return readerPointer->position.mark;
}


Expand Down Expand Up @@ -580,8 +606,11 @@ Rs_intg readerGetInc(BufferPointer const readerPointer) {
*/
Rs_intg readerGetMode(BufferPointer const readerPointer) {
/* TO_DO: Defensive programming */
if (!readerPointer) {
return READER_ERROR;
}
/* TO_DO: Return mode */
return 0;
return readerPointer->mode;
}


Expand Down Expand Up @@ -624,7 +653,23 @@ Rs_byte readerGetFlags(BufferPointer const readerPointer) {
*/
Rs_void readerPrintStat(BufferPointer const readerPointer) {
/* TO_DO: Defensive programming */
/* Defensive programming: Check if readerPointer is NULL */
if(!readerPointer){
fprintf(stderr, "Error: readerPointer is NULL\n");
return;
}
/* Defensive programming: Check if histogram is valid */
if (!readerPointer->histogram) {
fprintf(stderr, "Error: histogram is NULL\n");
return;
}
/* TO_DO: Print the histogram */
for(int i = 0; i < NCHAR; i++){
if(readerPointer->histogram[i] > 0){
printf("Char: %c - Frequency: %d\n", i, readerPointer->histogram[i]);
}
}

}

/*
Expand Down
19 changes: 10 additions & 9 deletions code/launch.vs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
"name": "Compiler.exe",
"args": [
"r",
"C:/Mac/Home/Downloads/RuanScript/input/test.rs",
"C:/Mac/Home/Downloads/RuanScript/input/INPUT0_Empty.rs",
"C:/Mac/Home/Downloads/RuanScript/input/INPUT1_Hello.rs",
"C:/Mac/Home/Downloads/RuanScript/input/INPUT2_Volume.rs",
"C:/Mac/Home/Downloads/RuanScript/input/INPUT3_Factorial.rs",
"C:/Mac/Home/Downloads/RuanScript/input/INPUT4_Datatypes.rs",
"C:/Mac/Home/Downloads/RuanScript/input/INPUT5_General.rs",
"C:/Mac/Home/Downloads/RuanScript/input/INPUT6_Big.rs",
"C:/Mac/Home/Downloads/RuanScript/input/README.txt"
"C:/Mac/Home/Downloads/RuanScript/input/test.rs",
// "C:/Mac/Home/Downloads/RuanScript/input/INPUT0_Empty.rs",
// "C:/Mac/Home/Downloads/RuanScript/input/INPUT1_Hello.rs",
// "C:/Mac/Home/Downloads/RuanScript/input/INPUT2_Volume.rs",
// "C:/Mac/Home/Downloads/RuanScript/input/INPUT3_Factorial.rs",
// "C:/Mac/Home/Downloads/RuanScript/input/INPUT4_Datatypes.rs",
// "C:/Mac/Home/Downloads/RuanScript/input/INPUT5_General.rs",
// "C:/Mac/Home/Downloads/RuanScript/input/INPUT6_Big.rs",
// "C:/Mac/Home/Downloads/RuanScript/input/README.txt",
// "C:/Mac/Home/Downloads/RuanScript/input/INPUT7_Error.rs"
]

}
Expand Down
Binary file modified code/out/build/x64-Debug/.ninja_deps
Binary file not shown.
40 changes: 39 additions & 1 deletion code/out/build/x64-Debug/.ninja_log
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,43 @@
15 185 7394924388314107 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1
22 861 7394976581353249 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
28 205 7394924388505498 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda
14 379 7399236037962701 build.ninja 10add4a6052b72f8
14 379 7400004486892868 build.ninja 10add4a6052b72f8
865 1439 7394976586503191 Compiler.exe 60774a4753864fbb
19 1111 7400010507894955 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
1114 2294 7400010516598619 Compiler.exe 60774a4753864fbb
16 49 0 clean 3807ae1e948da024
17 145 7400012280477514 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1
24 151 7400012280548421 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
30 167 7400012280747799 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda
169 558 7400012283816512 Compiler.exe 60774a4753864fbb
13 39 0 clean 3807ae1e948da024
19 150 7400012502078950 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1
29 166 7400012502253735 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
36 183 7400012502406911 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda
184 579 7400012505447596 Compiler.exe 60774a4753864fbb
18 154 7400013086268399 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
158 492 7400013089065941 Compiler.exe 60774a4753864fbb
18 429 7400024758218857 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
433 801 7400024761226538 Compiler.exe 60774a4753864fbb
20 456 7400031727550684 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
462 844 7400031730642286 Compiler.exe 60774a4753864fbb
22 162 7400032588618450 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
165 492 7400032591301376 Compiler.exe 60774a4753864fbb
28 183 7400035388987964 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
187 663 7400035392898356 Compiler.exe 60774a4753864fbb
21 149 7400035592687588 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
152 544 7400035595852784 Compiler.exe 60774a4753864fbb
22 171 7400036683069618 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
175 557 7400036686167707 Compiler.exe 60774a4753864fbb
16 49 0 clean 3807ae1e948da024
18 179 7400038397713804 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1
27 196 7400038397839743 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
34 210 7400038398014622 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda
213 651 7400038401545536 Compiler.exe 60774a4753864fbb
18 158 7400041344381313 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
161 525 7400041347392272 Compiler.exe 60774a4753864fbb
14 41 0 clean 3807ae1e948da024
19 157 7400043843172586 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1
33 171 7400043843312456 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda
17 150 7400044606921288 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
153 520 7400044609840306 Compiler.exe 60774a4753864fbb
Binary file modified code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Compilers.c.obj
Binary file not shown.
Binary file not shown.
Binary file modified code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Reader.c.obj
Binary file not shown.
Binary file modified code/out/build/x64-Debug/CMakeFiles/Compiler.dir/vc140.pdb
Binary file not shown.
Binary file modified code/out/build/x64-Debug/Compiler.exe
Binary file not shown.
Binary file modified code/out/build/x64-Debug/Compiler.ilk
Binary file not shown.
Binary file modified code/out/build/x64-Debug/Compiler.pdb
Binary file not shown.
4 changes: 2 additions & 2 deletions code/out/build/x64-Debug/Testing/Temporary/LastTest.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Start testing: Jun 12 15:26 Eastern Daylight Time
Start testing: Jun 13 12:47 Eastern Daylight Time
----------------------------------------------------------
End testing: Jun 12 15:26 Eastern Daylight Time
End testing: Jun 13 12:47 Eastern Daylight Time
4 changes: 1 addition & 3 deletions input/INPUT1_Hello.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Rs Example 2:
The program is "lexically" correct
and should not generate any error #
# Rs Example 2: The program is "lexically" correctand should not generate any error #
main& {
data {
}
Expand Down
9 changes: 9 additions & 0 deletions input/INPUT7_Error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
main& {
data {
Rs_intg number; // Define a variable without initialization
}
code {
number = 10;
print&('The number is: ' + number);
}
}

0 comments on commit 593c000

Please sign in to comment.