Skip to content

Commit dff634a

Browse files
committed
Avoid symbol name clashes by marking things as static
The C static keyword sets the scope of the name to the containing file. Signed-off-by: Stefan Marr <[email protected]>
1 parent 53f96e3 commit dff634a

File tree

2 files changed

+100
-100
lines changed

2 files changed

+100
-100
lines changed

src/compiler/Parser.c

+81-81
Original file line numberDiff line numberDiff line change
@@ -221,64 +221,64 @@ static char* symnames[] = {
221221
#pragma mark intern Prototypes
222222

223223

224-
void fillbuffer(void);
225-
bool eob(void);
226-
void skipWhiteSpace(void);
227-
void skipComment(void);
228-
void getsym(void);
229-
void peek(void);
230-
bool symIn(Symbol* ss);
231-
bool acceptXXX(Symbol s);
232-
bool acceptOneOf(Symbol* ss);
233-
bool expect(Symbol s);
234-
bool expectOneOf(Symbol* ss);
235-
void SingleOperator(void);
236-
void classdef(void);
237-
void instanceFields(class_generation_context* cgenc);
238-
void classFields(class_generation_context* cgenc);
239-
void method(method_generation_context* mgenc);
240-
void primitiveBlock(void);
241-
void pattern(method_generation_context* mgenc);
242-
void unaryPattern(method_generation_context* mgenc);
243-
void binaryPattern(method_generation_context* mgenc);
244-
void keywordPattern(method_generation_context* mgenc);
245-
void methodBlock(method_generation_context* mgenc);
246-
pVMSymbol unarySelector(void);
247-
pVMSymbol binarySelector(void);
248-
char* identifier(void);
249-
pString keyword(void);
250-
char* argument(void);
251-
void blockContents(method_generation_context* mgenc);
252-
void locals(method_generation_context* mgenc);
253-
void blockBody(method_generation_context* mgenc, bool seen_period);
254-
void result(method_generation_context* mgenc);
255-
void expression(method_generation_context* mgenc);
256-
void assignation(method_generation_context* mgenc);
257-
void assignments(method_generation_context* mgenc, pList l);
258-
pString assignment(method_generation_context* mgenc);
259-
void evaluation(method_generation_context* mgenc);
260-
void primary(method_generation_context* mgenc, bool* super);
261-
char* variable(void);
262-
void messages(method_generation_context* mgenc, bool super);
263-
void unaryMessage(method_generation_context* mgenc, bool super);
264-
void binaryMessage(method_generation_context* mgenc, bool super);
265-
void binaryOperand(method_generation_context* mgenc, bool* super);
266-
void keywordMessage(method_generation_context* mgenc, bool super);
267-
void formula(method_generation_context* mgenc);
268-
void nestedTerm(method_generation_context* mgenc);
269-
void literal(method_generation_context* mgenc);
270-
void literalNumber(method_generation_context* mgenc);
271-
uint64_t literalDecimal(void);
272-
int64_t negativeDecimal(void);
273-
uint64_t literalInteger(void);
274-
void literalSymbol(method_generation_context* mgenc);
275-
void literalString(method_generation_context* mgenc);
276-
pVMSymbol selector(void);
277-
pVMSymbol keywordSelector(void);
278-
char* string(void);
279-
void nestedBlock(method_generation_context* mgenc);
280-
void blockPattern(method_generation_context* mgenc);
281-
void blockArguments(method_generation_context* mgenc);
224+
static void fillbuffer(void);
225+
static bool eob(void);
226+
static void skipWhiteSpace(void);
227+
static void skipComment(void);
228+
static void getsym(void);
229+
static void peek(void);
230+
static bool symIn(Symbol* ss);
231+
static bool accept(Symbol s);
232+
static bool acceptOneOf(Symbol* ss);
233+
static bool expect(Symbol s);
234+
static bool expectOneOf(Symbol* ss);
235+
static void SingleOperator(void);
236+
static void classdef(void);
237+
static void instanceFields(class_generation_context* cgenc);
238+
static void classFields(class_generation_context* cgenc);
239+
static void method(method_generation_context* mgenc);
240+
static void primitiveBlock(void);
241+
static void pattern(method_generation_context* mgenc);
242+
static void unaryPattern(method_generation_context* mgenc);
243+
static void binaryPattern(method_generation_context* mgenc);
244+
static void keywordPattern(method_generation_context* mgenc);
245+
static void methodBlock(method_generation_context* mgenc);
246+
static pVMSymbol unarySelector(void);
247+
static pVMSymbol binarySelector(void);
248+
static char* identifier(void);
249+
static pString keyword(void);
250+
static char* argument(void);
251+
static void blockContents(method_generation_context* mgenc);
252+
static void locals(method_generation_context* mgenc);
253+
static void blockBody(method_generation_context* mgenc, bool seen_period);
254+
static void result(method_generation_context* mgenc);
255+
static void expression(method_generation_context* mgenc);
256+
static void assignation(method_generation_context* mgenc);
257+
static void assignments(method_generation_context* mgenc, pList l);
258+
static pString assignment(method_generation_context* mgenc);
259+
static void evaluation(method_generation_context* mgenc);
260+
static void primary(method_generation_context* mgenc, bool* super);
261+
static char* variable(void);
262+
static void messages(method_generation_context* mgenc, bool super);
263+
static void unaryMessage(method_generation_context* mgenc, bool super);
264+
static void binaryMessage(method_generation_context* mgenc, bool super);
265+
static void binaryOperand(method_generation_context* mgenc, bool* super);
266+
static void keywordMessage(method_generation_context* mgenc, bool super);
267+
static void formula(method_generation_context* mgenc);
268+
static void nestedTerm(method_generation_context* mgenc);
269+
static void literal(method_generation_context* mgenc);
270+
static void literalNumber(method_generation_context* mgenc);
271+
static uint64_t literalDecimal(void);
272+
static int64_t negativeDecimal(void);
273+
static uint64_t literalInteger(void);
274+
static void literalSymbol(method_generation_context* mgenc);
275+
static void literalString(method_generation_context* mgenc);
276+
static pVMSymbol selector(void);
277+
static pVMSymbol keywordSelector(void);
278+
static char* string(void);
279+
static void nestedBlock(method_generation_context* mgenc);
280+
static void blockPattern(method_generation_context* mgenc);
281+
static void blockArguments(method_generation_context* mgenc);
282282

283283

284284
//
@@ -289,15 +289,15 @@ void blockArguments(method_generation_context* mgenc);
289289
#pragma mark File local variables
290290

291291

292-
FILE* infile;
292+
static FILE* infile;
293293

294-
Symbol sym;
295-
char symc;
294+
static Symbol sym;
295+
static char symc;
296296
static char text[BUFSIZ];
297297

298-
bool peekDone;
299-
Symbol nextSym;
300-
char nextSymc;
298+
static bool peekDone;
299+
static Symbol nextSym;
300+
static char nextSymc;
301301
static char nextText[BUFSIZ];
302302

303303

@@ -307,7 +307,7 @@ static char nextText[BUFSIZ];
307307

308308

309309
static char buf[BUFSIZ];
310-
int bufp;
310+
static int bufp;
311311

312312

313313
#pragma mark Stream handling
@@ -551,7 +551,7 @@ bool symIn(Symbol* ss) {
551551
}
552552

553553

554-
bool acceptXXX(Symbol s) {
554+
bool accept(Symbol s) {
555555
if(sym == s) {
556556
getsym();
557557
return true;
@@ -573,7 +573,7 @@ bool acceptOneOf(Symbol* ss) {
573573

574574

575575
bool expect(Symbol s) {
576-
if(acceptXXX(s))
576+
if(accept(s))
577577
return true;
578578
fprintf(stderr, "Error: unexpected symbol. Expected %s, but found %s",
579579
symnames[s], symnames[sym]);
@@ -676,7 +676,7 @@ void Parser_classdef(class_generation_context* cgenc) {
676676

677677
if(sym == Identifier) {
678678
cgenc->super_name = Universe_symbol_for(text);
679-
acceptXXX(Identifier);
679+
accept(Identifier);
680680
} else
681681
cgenc->super_name = Universe_symbol_for("Object");
682682

@@ -702,7 +702,7 @@ void Parser_classdef(class_generation_context* cgenc) {
702702
method_genc_release(&mgenc);
703703
}
704704

705-
if(acceptXXX(Separator)) {
705+
if(accept(Separator)) {
706706
cgenc->class_side = true;
707707
classFields(cgenc);
708708
while(sym == Identifier || sym == Keyword || sym == OperatorSequence ||
@@ -730,7 +730,7 @@ void Parser_classdef(class_generation_context* cgenc) {
730730

731731

732732
void instanceFields(class_generation_context* cgenc) {
733-
if(acceptXXX(Or)) {
733+
if(accept(Or)) {
734734
while(sym == Identifier) {
735735
char* var = variable();
736736
SEND(cgenc->instance_fields, add, Universe_symbol_for(var));
@@ -742,7 +742,7 @@ void instanceFields(class_generation_context* cgenc) {
742742

743743

744744
void classFields(class_generation_context* cgenc) {
745-
if(acceptXXX(Or)) {
745+
if(accept(Or)) {
746746
while(sym == Identifier) {
747747
char* var = variable();
748748
SEND(cgenc->class_fields, add, Universe_symbol_for(var));
@@ -843,17 +843,17 @@ pVMSymbol unarySelector(void) {
843843
pVMSymbol binarySelector(void) {
844844
pVMSymbol symb = Universe_symbol_for(text);
845845

846-
if(acceptXXX(Or))
846+
if(accept(Or))
847847
;
848-
else if(acceptXXX(Comma))
848+
else if(accept(Comma))
849849
;
850-
else if(acceptXXX(Minus))
850+
else if(accept(Minus))
851851
;
852-
else if(acceptXXX(Equal))
852+
else if(accept(Equal))
853853
;
854854
else if(acceptOneOf(singleOpSyms))
855855
;
856-
else if(acceptXXX(OperatorSequence))
856+
else if(accept(OperatorSequence))
857857
;
858858
else
859859
expect(NONE);
@@ -864,7 +864,7 @@ pVMSymbol binarySelector(void) {
864864

865865
char* identifier(void) {
866866
char* s = internal_allocate_string(text);
867-
if(acceptXXX(Primitive))
867+
if(accept(Primitive))
868868
; // text is set
869869
else
870870
expect(Identifier);
@@ -887,7 +887,7 @@ char* argument(void) {
887887

888888

889889
void blockContents(method_generation_context* mgenc) {
890-
if(acceptXXX(Or)) {
890+
if(accept(Or)) {
891891
locals(mgenc);
892892
expect(Or);
893893
}
@@ -905,7 +905,7 @@ void locals(method_generation_context* mgenc) {
905905

906906

907907
void blockBody(method_generation_context* mgenc, bool seen_period) {
908-
if(acceptXXX(Exit))
908+
if(accept(Exit))
909909
result(mgenc);
910910
else if(sym == EndBlock) {
911911
if(seen_period)
@@ -924,7 +924,7 @@ void blockBody(method_generation_context* mgenc, bool seen_period) {
924924
mgenc->finished = true;
925925
} else {
926926
expression(mgenc);
927-
if(acceptXXX(Period)) {
927+
if(accept(Period)) {
928928
emit_POP(mgenc);
929929
blockBody(mgenc, true);
930930
}
@@ -939,7 +939,7 @@ void result(method_generation_context* mgenc) {
939939
else
940940
emit_RETURN_LOCAL(mgenc);
941941
mgenc->finished = true;
942-
acceptXXX(Period);
942+
accept(Period);
943943
}
944944

945945

0 commit comments

Comments
 (0)