4Th, the Friendly Forth Compiler
Total Page:16
File Type:pdf, Size:1020Kb
4tH, the friendly Forth compiler J.L. Bezemer May 3, 2012 Contents 1 What's new 16 1.1 What's new in version 3.61.5 . 16 1.2 What's new in version 3.61.4 . 17 1.3 What's new in version 3.61.3 . 19 1.4 What's new in version 3.61.2 . 21 1.5 What's new in version 3.61.1 . 24 1.6 What's new in version 3.61.0 . 25 1.7 What's new in version 3.60.1 . 28 1.8 What's new in version 3.60.0 . 29 1.9 What's new in version 3.5d, release 3 . 31 1.10 What's new in version 3.5d, release 2 . 33 1.11 What's new in version 3.5d . 34 1.12 What's new in version 3.5c, release 3 . 35 1.13 What's new in version 3.5c, release 2 . 36 1.14 What's new in version 3.5c . 38 1.15 What's new in version 3.5b, release 2 . 39 1.16 What's new in version 3.5b . 40 1.17 What's new in version 3.5a, release 2 . 40 1.18 What's new in version 3.5a . 41 1.19 What's new in version 3.3d, release 2 . 46 1.20 What's new in version 3.3d . 47 1.21 What's new in version 3.3c . 49 1.22 What's new in version 3.3a . 51 1.23 What's new in version 3.2e . 52 1.24 What's new in version 3.1d . 55 1 CONTENTS 2 I Getting Started 58 2 Overview 59 2.1 Introduction . 59 2.2 History . 59 2.3 Applications . 60 2.4 Architecture . 60 2.4.1 The 4tH language . 62 2.4.2 H-code . 62 2.4.3 H-code compiler . 64 2.4.4 Error handling . 64 2.4.5 Interfacing with C . 65 3 Installation Guide 66 3.1 About this package . 66 3.1.1 Example code . 66 3.1.2 Main program . 66 3.1.3 Unix package . 67 3.1.4 Linux package . 68 3.1.5 Android package . 71 3.1.6 MS-DOS package . 73 3.1.7 MS-Windows package . 73 3.2 Setting up your working directory . 74 3.3 Now what? . 74 3.4 Pedigree . 75 3.5 Contributors . 75 3.6 Questions . 76 3.6.1 4tH Website . 76 3.6.2 4tH Google group . 76 3.6.3 Newsgroup . 76 4 A guided tour 77 4.1 4tH interactive . 77 4.2 Starting up 4tH . 77 4.3 Running a program . 77 4.4 Starting an editing session . 78 4.5 Writing your first 4tH program . 79 4.6 A more complex program . 82 CONTENTS 3 4.7 Advanced features . 86 4.8 Suspending a program . 93 4.9 Calculator mode . 95 4.10 Epilogue . 95 5 Frequently asked questions 96 II Primer 98 6 Introduction 99 7 4tH fundamentals 100 7.1 Making calculations without parentheses . 100 7.2 Manipulating the stack . 101 7.3 Deep stack manipulators . 102 7.4 Passing arguments to functions . 102 7.5 Making your own words . 103 7.6 Adding comment . 104 7.7 Text-format of 4tH source . 104 7.8 Displaying string literals . 104 7.9 Creating variables . 105 7.10 Using variables . 105 7.11 Built-in variables . 105 7.12 What is a cell? . 106 7.13 What is a literal expression? . 106 7.14 Declaring arrays of numbers . 106 7.15 Using arrays of numbers . 106 7.16 Declaring and using constants . 107 7.17 Built-in constants . 108 7.18 Using booleans . 108 7.19 IF-ELSE constructs . 108 7.20 FOR-NEXT constructs . 109 7.21 WHILE-DO constructs . 110 7.22 REPEAT-UNTIL constructs . 110 7.23 Infinite loops . 110 7.24 Including source files . 111 7.25 Getting a number from the keyboard . 111 CONTENTS 4 8 4tH arrays 112 8.1 Aligning numbers . 112 8.2 Creating arrays of constants . 112 8.3 Using arrays of constants . 112 8.4 Using values . 113 8.5 Creating string variables . 114 8.6 What is an address? . 114 8.7 String literals . 115 8.8 String constants . 115 8.9 Initializing string variables . 116 8.10 Initializing a NULL string variable . 116 8.11 Getting the length of a string variable . 116 8.12 Printing a string variable . 117 8.13 Copying a string variable . 117 8.14 The string terminator . 117 8.15 Slicing strings . 118 8.16 Appending strings . 119 8.17 Comparing strings . 119 8.18 Finding a substring . 120 8.19 Replacing substrings . 121 8.20 Deleting substrings . 121 8.21 Removing trailing spaces . 122 8.22 Removing leading spaces . 122 8.23 Upper and lower case . ..