sleyzerzon / soar

Automatically exported from code.google.com/p/soar
1 stars 0 forks source link

strings with uppercase characters are printed with | quotes #68

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
| quoted strings are ugly and difficult to read, so Soar should avoid
printing them whenever possible. Currently, any string with an uppercase
character will be printed with | quotes. Looking at the relevant kernel
code, it seems that this has something to do with rereadability
(Core/SoarKernel/src/lexer.cpp:1217). Does anyone know why strings with
uppercase characters are considered unrereadable?

Original issue reported on code.google.com by joseph...@gmail.com on 20 Apr 2010 at 11:07

GoogleCodeExporter commented 8 years ago
The intent is to put strings that look like identifiers in pipes, so you can 
tell the
difference between, e.g., the identifier S1 and the string S1. However, the 
code to
do this is very sloppy, and simply assumes that any string that contains an 
uppercase
character could be confused for an identifier, which clearly isn't true. I don't
think anyone would complain if this were cleaned up.

Original comment by marin...@gmail.com on 21 Apr 2010 at 12:06

GoogleCodeExporter commented 8 years ago
I see some lines at the end of the string testing function that's explicitly 
testing
for identifiers:

if (isalpha(*ch)) {
    /* --- is the rest of the string an integer? --- */
    ch += 1;
    while (isdigit(*ch)) ch++;         /* string of digits */
    if ((*ch==0)&&(isdigit(*(ch-1)))) *possible_id = TRUE;
}

So is the uppercase testing redundant and safely removable, or is there 
something
else going on there?

Original comment by joseph...@gmail.com on 21 Apr 2010 at 12:34

GoogleCodeExporter commented 8 years ago
I don't know what else could be going on, but perhaps we should be careful. 
Maybe
email soar-group to see if anyone would object to changing the behavior?

Original comment by marin...@gmail.com on 21 Apr 2010 at 12:37

GoogleCodeExporter commented 8 years ago
The rereadability junk, as you know, is only used when printed a string symbol 
and
ensuring that, when read back by the lexer, it'll still be a string. For 
example,
numbers stored as string, strings that look like ids, and strings that look like
variables. The upper case check is definitely bizarre. I'd wager this is a 
vestigial
piece of code from long, long ago that everyone's afraid to "fix":

  http://en.wikipedia.org/wiki/Symbol_%28Lisp%29

In Lisp, caps are treated specially in symbols so maybe that's where it came 
from.

I say, only quote it if it looks like a different type (int, float, id) or 
contains
non-constituent chars like spaces or anything that needs to be escaped.

Original comment by dave...@gmail.com on 21 Apr 2010 at 1:13

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r11966.

Original comment by joseph...@gmail.com on 21 Apr 2010 at 6:13

GoogleCodeExporter commented 8 years ago
I've come up with a little test rule that shows how various strings are quoted. 
A lot
of stuff aren't handled right.

Original comment by joseph...@gmail.com on 21 Apr 2010 at 8:16

Attachments: