Comments (4)
Shorter example:
[ Main; ];
[ LanguageNumber n;
if (n == 0) { print "zero"; rfalse; }
if (n < 0) { print "minus "; n = -n; }
switch (n) {
1: print "one";
19: print "nineteen";
20 to 99: switch (n/10) {
2: print "twenty";
3: print "thirty";
4: print "forty";
5: print "fifty";
6: print "sixty";
7: print "seventy";
8: print "eighty";
9: print "ninety";
}
if (n%10 ~= 0) print "-", (LanguageNumber) n%10;
}
];
[ TestFunc;
return to;
];
line 9: Error: No such constant as "to"
The "to" in the switch statement seems to create a symbol reference, even though it should be a keyword at that point.
from inform6.
Also happens with the keywords on
, off
(in font on/off
) and bold
, underline
, roman
, reverse
, fixed
(in the style...
statement). All of these are from misc_keywords[]
.
Also label names, when used as a value in a different function. (If you use a label as a value within a function, the compiler correctly complaints "Label name used as value".)
from inform6.
Well, this turns out to be kind of a pain. You'd think the answer would be to go into states.c and do something like this:
misc_keywords.enabled = TRUE;
dont_enter_into_symbol_table=TRUE;
get_next_token();
misc_keywords.enabled = FALSE;
dont_enter_into_symbol_table=FALSE;
But this doesn't help, because get_next_token() reads a token ahead. By the time you set the flag, the "underline" token (or whatever) has been parsed.
In fact there are quite a few places in the code that look like
misc_keywords.enabled = TRUE;
get_next_token();
misc_keywords.enabled = FALSE;
...and I'm pretty sure they don't work. This may be a long-standing bug, although I don't know if it causes other problems. (EDIT: I am wrong; it's not a bug. See next comment.)
from inform6.
Okay, right. The "lexical context" feature of lexer.c is meant to fix the general problem. get_next_token() will reinterpret a symbol if the current enabled keywords don't match where we were when the symbol was ahead-read.
However, as noted at lexer.c:587, the lexical context doesn't include the dont_enter_into_symbol_table
flag. There's no way to reinterpret a symbol into a keyword -- that would require deleting it from the symbol table.
The upshot is that this isn't fixable in a nice way without rethinking the whole lexer loop.
from inform6.
Related Issues (20)
- Unterminated array definition causes lots of errors
- illegal (?) give syntax produces a Compiler Error HOT 5
- "@{5E}" and "@{7E}" escapes are wrong in Z-code
- container/surface bug, look code gets called twice? HOT 1
- Conditional compilation fails inside property value array HOT 5
- random in Glulx doesn't match DM4 HOT 3
- Clean up MAX_ABBREV_LENGTH
- Add //~n flag for dict words HOT 2
- Function zchar_weight assigns wrong weight to a space HOT 1
- Feature: singular flag for dict words HOT 2
- Dict flags fail when DICT_WORD_SIZE=31 and DICT_CHAR_SIZE=4
- Feature: Overflow flag for dict words HOT 2
- Add `$GRAMMAR_VERSION` compiler setting HOT 1
- Add `$OMIT_PAGE_PADDING` compiler setting HOT 1
- Add `$IGNORE_INLINE_COMPILER_SETTINGS` compiler setting HOT 2
- Impossible to use custom alphabet for 4 first objects HOT 2
- Grammar version 3 HOT 2
- Meta flag for grammar/action lines HOT 5
- Command-line options should override !% headers HOT 2
- Verb declarations can clash if the verbs encode to the same dict word HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inform6.