Skip to content

Commit 5089f5d

Browse files
committed
Update CVector, c_utils and README
Moved a fix from modifying cvec_free_void_heap to free_statement(), see TODO.
1 parent cd3607e commit 5089f5d

File tree

6 files changed

+1041
-1108
lines changed

6 files changed

+1041
-1108
lines changed

README.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ C_Interpreter
44
[![Build Status](https://travis-ci.org/rswinkle/C_Interpreter.svg?branch=master)](https://travis-ci.org/rswinkle/C_Interpreter)
55
[![Coverity Scan Build Status](https://scan.coverity.com/projects/3624/badge.svg)](https://scan.coverity.com/projects/3624)
66

7-
[![Contact me on Codementor](https://cdn.codementor.io/badges/contact_me_github.svg)](https://www.codementor.io/rswinkle)
8-
97
[http://www.robertwinkler.com/projects/c_interpreter.html](http://www.robertwinkler.com/projects/c_interpreter.html)
108

119
This started as C port of an old college assignment
@@ -17,6 +15,13 @@ Now my goal is to make something approaching scriptable
1715
C. I'll consider it done when it can run itself ...
1816
so it'll probably never be completely done.
1917

18+
Download
19+
========
20+
Get the source from [Github](https://github.com/rswinkle/C_Interpreter).
21+
22+
23+
Alternatives
24+
============
2025
If you're looking for something more professional there's
2126

2227
* [Cling](http://root.cern.ch/drupal/content/cling)
@@ -27,25 +32,26 @@ fast and self-contained they have a command line switch -run to immediately
2732
run it after compiling so you can use C as a JIT scripting language,
2833

2934

30-
35+
Tests
36+
=====
3137
I've kept the old tests around (updating them so they
3238
keep working) but I've been adding new tests for
3339
new features. They're not comprehensive and they
3440
don't test every edge case but they're growing.
3541

42+
43+
Misc
44+
====
3645
I'm using the 5th edition of C: A Reference Manual for
3746
all the nitty gritty details and the very convenient
3847
complete C grammar/syntax in the appendix.
3948

40-
The grammar below is the current status more or less.
41-
It'll be interesting to see how it grows and which
42-
parts converge with full syntax first.
43-
4449
I've also added a BNF spec for C I found online just
4550
to have something for reference in the repository.
4651

47-
I've now added a preprocessor which currently supports
48-
the following (and of course actually using the macros):
52+
Current Grammar (work in progress)
53+
==================================
54+
### Preprocessor
4955

5056
#include "relative path based on current directory"
5157
#define name
@@ -54,9 +60,9 @@ the following (and of course actually using the macros):
5460
#undef name
5561
# (null directive)
5662

63+
It also of course supports actually using the macros.
5764

58-
Current Grammar (work in progress)
59-
==================================
65+
### C language
6066

6167
translation_unit -> top_level_declaration
6268
translation_unit top_level_declaration
@@ -261,21 +267,9 @@ all my tests at once.
261267
Usage: ./cinterpreter [-E] script
262268
~/C_Interpreter/build $ ./cinterpreter ../tests/switch.txt
263269
[ouhput from switch.txt here]
264-
~/C_Interpreter/build $ ../runtests.sh
265-
running normal tests
266-
==================
267-
executing ../tests/backslash.txt
268-
executing ../tests/break_continue.txt
269-
executing ../tests/problem6.txt
270-
...
271-
comparing output of ../tests/backslash.txt
272-
comparing output of ../tests/break_continue.txt
273-
comparing output of ../tests/problem6.txt
274-
...
275-
~/C_Interpreter/build $ ../runtests_valgrind.sh | grep ERROR
276-
==30652== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
277-
==30652== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
278-
==30655== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
279-
...
270+
~/C_Interpreter/build $ ../runtests.py
271+
Should be nothing here, only failures produce output
272+
~/C_Interpreter/build $ ../run_valgrind_tests.py
273+
Same here. Note this make take a minute, valgrind makes things slow
280274
~/C_Interpreter/build $
281275

run_valgrind_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def main():
1818
parser = argparse.ArgumentParser(description="Run C_Interpreter tests")
1919
parser.add_argument("-E", "--run-preproc", action="store_true", help="Run preprocessor tests too")
2020
args = parser.parse_args()
21-
print(args)
21+
#print(args)
2222

2323
ret = 0
2424
for f in language_tests:

runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def main():
1717
parser = argparse.ArgumentParser(description="Run C_Interpreter tests")
1818
parser.add_argument("-E", "--run-preproc", action="store_true", help="Run preprocessor tests too")
1919
args = parser.parse_args()
20-
print(args)
20+
#print(args)
2121

2222

2323
ret = rc1 = rc2 = rc3 = 0

src/c_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,10 +1031,10 @@ char* int_to_str(int num, int base)
10311031
char *pos = buf + INT_MAX_LEN-1;
10321032
int tmp = (num < 0) ? -num : num;
10331033

1034-
while (tmp != 0) {
1034+
do {
10351035
*pos-- = digits[tmp % base];
10361036
tmp /= base;
1037-
}
1037+
} while (tmp != 0);
10381038

10391039
if (num < 0) {
10401040
*pos = '-';

0 commit comments

Comments
 (0)