-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d7fefa
commit caf0edd
Showing
11 changed files
with
491 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* --------------------------------------------------------------------------------- | ||
solver.h | ||
solver for infix automatic-scanner calculator. | ||
MIT License | ||
Copyright (c) 2020 Tomas Sanchez | ||
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. | ||
last modified: 11/13/2020 | ||
------------------------------------------------------------------------------------ */ | ||
|
||
#pragma once | ||
|
||
#include "parser.h" | ||
|
||
/*Token handler*/ | ||
typedef struct Token{ | ||
int token; | ||
token_id_t type; | ||
}token_t; | ||
|
||
/*Object that can solve expressions*/ | ||
typedef struct Solver{ | ||
/*Current token buffered*/ | ||
token_t * token; | ||
/*Queue*/ | ||
t_queue * output_queue; | ||
/*Stack*/ | ||
stack_t * operator_stack; | ||
/*Value obtained after all calculations were applied*/ | ||
int final_result; | ||
}solver_t; | ||
|
||
/*Creates a solver*/ | ||
int solver_create(); | ||
|
||
/*Frees memory usage form solver*/ | ||
int solver_delete(); | ||
|
||
/*Stores next token*/ | ||
int solver_GetNextToken(int, token_id_t); | ||
|
||
/*Solves expression*/ | ||
int solver_update(); | ||
|
||
/*Print results*/ | ||
int solver_print(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
==2575== Memcheck, a memory error detector | ||
==2575== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. | ||
==2575== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info | ||
==2575== Command: ./Calculator.exe | ||
==2575== Parent PID: 2555 | ||
==2575== | ||
==2575== | ||
==2575== HEAP SUMMARY: | ||
==2575== in use at exit: 16,482 bytes in 4 blocks | ||
==2575== total heap usage: 14 allocs, 10 frees, 18,642 bytes allocated | ||
==2575== | ||
==2575== LEAK SUMMARY: | ||
==2575== definitely lost: 0 bytes in 0 blocks | ||
==2575== indirectly lost: 0 bytes in 0 blocks | ||
==2575== possibly lost: 0 bytes in 0 blocks | ||
==2575== still reachable: 16,482 bytes in 4 blocks | ||
==2575== suppressed: 0 bytes in 0 blocks | ||
==2575== Reachable blocks (those to which a pointer was found) are not shown. | ||
==2575== To see them, rerun with: --leak-check=full --show-leak-kinds=all | ||
==2575== | ||
==2575== For counts of detected and suppressed errors, rerun with: -v | ||
==2575== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) | ||
==1772== Memcheck, a memory error detector | ||
==1772== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. | ||
==1772== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info | ||
==1772== Command: ./Calculator.exe | ||
==1772== Parent PID: 1750 | ||
==1772== | ||
==1772== | ||
==1772== HEAP SUMMARY: | ||
==1772== in use at exit: 16,482 bytes in 4 blocks | ||
==1772== total heap usage: 29 allocs, 25 frees, 18,866 bytes allocated | ||
==1772== | ||
==1772== LEAK SUMMARY: | ||
==1772== definitely lost: 0 bytes in 0 blocks | ||
==1772== indirectly lost: 0 bytes in 0 blocks | ||
==1772== possibly lost: 0 bytes in 0 blocks | ||
==1772== still reachable: 16,482 bytes in 4 blocks | ||
==1772== suppressed: 0 bytes in 0 blocks | ||
==1772== Reachable blocks (those to which a pointer was found) are not shown. | ||
==1772== To see them, rerun with: --leak-check=full --show-leak-kinds=all | ||
==1772== | ||
==1772== For counts of detected and suppressed errors, rerun with: -v | ||
==1772== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.