GithubHelp home page GithubHelp logo

Comments (4)

erkyrath avatar erkyrath commented on August 23, 2024 2

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.

erkyrath avatar erkyrath commented on August 23, 2024

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.

erkyrath avatar erkyrath commented on August 23, 2024

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.

erkyrath avatar erkyrath commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.