Feature ASH language server features

I'm still poking at curretLine being "null" in the debugger and still wish I understood while a test that throws an (unexpected) Exception doesn't fail in the IDE.
Do you mean something like this:
Code_5mfeWpF90O.png
With the first line reading something like v currentLine: Parser$Line@<whatever> "null" (with quotes around the null)

If so, it's maybe not an error. The IDE is probably the one not doing the null check; it maybe tries to do
Java:
String stringValueOfField = "\"" + field.toString() + "\"";
, which adds the quotes either way
 
Code:
    [junit] ------------- Standard Output ---------------
    [junit] Script parsing error: we didn't reach the end of the file.
    [junit]
    [junit]
    [junit] -----Lines:-----
    [junit]
    [junit] Current line reads ?    'hello world'
    [junit] from which we have read 0 character(s).
    [junit] First character: ?
    [junit] First character as long integer: 63
    [junit] First code point: 63
    [junit] First code point as long integer: 63
    [junit]
    [junit] Next line is end of file.
    [junit]
    [junit]
    [junit] -----Tokens:-----
    [junit]
    [junit] The value of the Token we currently have in front of us is ?
    [junit] Length: 1
    [junit] First character: ?
    [junit] First character as long integer: 63
    [junit] First code point: 63
    [junit] First code point as long integer: 63
    [junit]
    [junit]
    [junit] -----Byte Order Mark, for reference:-----
    [junit]
    [junit] The BOM (Byte Order Mark) reads ?
    [junit] BOM as long integer: 65279
    [junit]  ()
    [junit] ------------- ---------------- ---------------

with Hindsight 2
 
I was looking at variables and fields in the debugger. A field that was truly null displayed as null and that includes Strings. But the String field currentToken was "null" in the debugger. That seems counterintuitive and could be the result of converting something to a String and then assigning it when the original something was null and perhaps should not have been assigned. I should be smart enough to track that down and ask an intelligent question when I do.
 
No, the error message you showed really looked at the Line itself. It was truly supplied a line starting with a question mark.
 
It seems like the test's arguments were modified between them being fetched from ParserTest.data() and ParserTest.testScriptValidity() being called...
 
I put a watch every time currentToken was written.

This is the most interesting one, IMO.
CaptureD.PNG

If I am not going brain dead I am surprised that the comment talks about an end of file token but the code assigns null.
 
Breakpoint at the constructor. First, and only hit.

Capture1.PNG

buff in the source is the Java String "\ufeff 'hello world'"

Perhaps the issue is the test conversion of it to a stream?
 
I installed OpenJDK 13 on a Windows box and can reproduce.

Interesting idea, frono.

this.script.getBytes()

Oracle docs say:

Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.

!!!!
 
Well then, I guess we can continue.

https://kolmafia.us/threads/ash-language-server-features.26098/post-163315 is waiting for approval
https://kolmafia.us/threads/ash-language-server-features.26098/post-163321 is waiting for approval

For the next method refactor, I would first like to present you this:
java_p4jv0UvRzg.pngjava_RFJoUGUp5O.png
Ash supports naming arrays (or, as it sees it, "maps keyed by integers") with empty brackets (e.g. string[] x).
However, a flawed implementation made it also accept *nothing* if it's at the end of just any bracket group.

So, for example, int [int, int, ] is equivalent to int [int, int, int ] .
More precisely:
type [ [...] , ]
is the same as
type [ [...] , 0 ]
and/or
type [ [...] , int ]

So, what do we do?
A) do we fix this, and only allow empty brackets ("[]")?
B) do we leave this as it is, allowing empty brackets *and* commas followed by closing square bracket?
C) do we give in, and just allow users to chain commas inside brackets (so [,,,] would mean [int,int,int,int])?
 
A script containing
Code:
'\
is an existing NPE in parseString that's not fixed by your patch. Ditto with
Code:
$items[\

Thought you'd like to know.

Looking at parseEscapeSequence.

In what circumstances do you expect to see IndexOutOfBounds? That actually only occurs in the case of "line abruptly terminates after \x" and similar, which will never actually trigger for the octal handling, as far as I can tell.
 
A script containing
Code:
'\
is an existing NPE in parseString that's not fixed by your patch. Ditto with
Code:
$items[\

Thought you'd like to know.

Looking at parseEscapeSequence.
I don't--
Doesn't this prevent it?

Code_cR1gI5WWRE.png


Using your first example: '\
' is character 0
\ is character 1
the line has a length of 2

we enter parseEscapeSequence with i == 1 since
Java:
            char ch = line.charAt( i );

            // Handle escape sequences
            if ( ch == '\\' )
            {
                i = this.parseEscapeSequence( resultString, i );
                continue;
            }

we increment i (so i is now 2)
2 == line's length
we can tell we're at the end of the line.

Did I miss something?
 
Back
Top