Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print warning when redefining a word #455

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- Warning when redefining a word.
### Fixed
- POSTPONE error handling.
- Documented DEFCODE.

## [4.0.0] - 2022-07-20

### Changed
- OPEN/CHKIN/CHKOUT no longer return a file number.
- IOABORT no longer accepts a file number.
Expand Down
22 changes: 22 additions & 0 deletions compiler.asm
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ COLON

jmp RBRAC ; enter compile mode

redefined_str
!byte 10
!text "redefined "

; --- HEADER ( name -- )
+BACKLINK "header", 6
Expand All @@ -170,6 +173,25 @@ HEADER
jsr REFILL
jmp -
+

; prints warning when redefining a word
jsr TWODUP
jsr FIND_NAME
inx
lda MSB-1, x
beq +
dex
lda #<redefined_str
sta LSB,x
lda #>redefined_str
sta MSB,x
jsr COUNT
jsr TYPE
jsr TWODUP
jsr TYPE
jsr SPACE
+

; update dictionary pointer
lda LSB, x
sta .putlen+1
Expand Down
5 changes: 5 additions & 0 deletions core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ R_FETCH
BL
+VALUE K_SPACE

+BACKLINK "space", 5
SPACE
jsr BL
jmp EMIT

+BACKLINK "pick", 4
txa
sta + + 1
Expand Down
1 change: 0 additions & 1 deletion forth_src/base.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ dup code lda,# 100/ ldy,#
( to free up space, pad could be
e.g. HERE+34 instead )
$35b constant pad
: space bl emit ;
: spaces ( n -- )
begin ?dup while space 1- repeat ;

Expand Down