From 5b706542898d5a37f6a7b27128c3c6fcbccc8078 Mon Sep 17 00:00:00 2001 From: Daniel Serpell Date: Sun, 13 Dec 2020 20:03:17 -0300 Subject: [PATCH 1/9] Allows referencing a scope not yet created. Use the "::" syntax at the start of the symbol to force creating a scope if it does not exists yet. Fixes issue #479. --- src/ca65/symbol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ca65/symbol.c b/src/ca65/symbol.c index 982e8c29f..59c228bb7 100644 --- a/src/ca65/symbol.c +++ b/src/ca65/symbol.c @@ -136,10 +136,10 @@ SymTable* ParseScopedIdent (StrBuf* Name, StrBuf* FullName) SB_Append (FullName, Name); /* Search for the child scope */ - Scope = SymFindScope (Scope, Name, SYM_FIND_EXISTING); + Scope = SymFindScope (Scope, Name, SYM_ALLOC_NEW); if (Scope == 0) { /* Scope not found */ - Error ("No such scope: `%m%p'", FullName); + Error ("Can't create scope: `%m%p'", FullName); return 0; } From 76e31e5b7589e479782d0dbd2093645c3da6a2d4 Mon Sep 17 00:00:00 2001 From: Daniel Serpell Date: Sun, 13 Dec 2020 20:15:19 -0300 Subject: [PATCH 2/9] Document usage of scope before definitions. Note that before the last commit, the example did not assemble. --- doc/ca65.sgml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 5e53fb002..019c808e9 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -1319,6 +1319,11 @@ if you want to access the "other" symbol +The above example also shows that to search a scope that is not yet defined in +the code above the usage, you must use the namespace token (Address sizes and memory models