Parsing HScript Error

I am trying to get a single line of code to parse before it then gets executed later on the JavaScript layer.

I am getting two errors (the latter being the confusing one) in Chrome console:

sd2.js:4196 Error (41 - 41): Was not expecting <eof>
sd2.js:4196 Error (1 - 4): Was not expecting else

The code in question is this:

var gender = ''; if (sex == 'male') { gender = 'man'; } else if (sex == 'female') { gender = 'woman'; }
^  ^ - error 2                       ^ 1st error

I’ve tried both the single and double quote speech marks, but neither made a difference.

It’s obvious to me that the HScript parser is incorrectly providing the wrong positions in the error message, and I’m trying to figure out what’s wrong with that code. Any ideas?

Would the HScript parser behave differently with line breaks?

Currently I don’t support multi-line code blocks in my engine, so in order to test that I’d have to implement it first, which could take a while. I would still ideally like to get a single-line code snippet to parse correctly, though, even in the case where I did support multi-line code blocks.

The way my engine works is it parses information line-by-line, so the interactive story engine parser might parse something like this:

% "Johiah" #0f0
% "Saniyah" #3f9
% "Caroline" #5d3

$ "Start"
: 'This is a new era for the Morrowlands.'
: 'Too long have we suffered the consequences. It is now time to take action.'
: 'We cannot sit around thinking of the atrocities the cultists have done. We must be bold and take a firm stance on these matters.'
: - Johiah, daughter of the royal family
: Saniyah puts the book down onto the nearby table. Caroline, her sister, starts crying.
Saniyah : Shh. It's okay.
: Saniyah picks up her 1 year-old sister and starts feeding her. Caroline stops crying.
Saniyah : I promise you, whatever happens, we will leave far away from here.
: Caroline looks up at Saniyah and gazes with her eyes wide open as she munches on her food.
Saniyah : We will go to Atlantis. We won't be taken by cultists. And we will have a life together.
Saniyah : No matter what happens, you and I will always be together.
: Saniyah starts hugging her sister and Caroline hugs her back.
~ Nine years later.
: A knock comes at the door of Saniyah's home.
Caroline : Who is that?
Saniyah : We will soon find out.
! var gender = ""; if (sex == "male") { gender = "man"; } else if (sex == "female") { gender = "woman"; }
: Saniyah opens the door and looks at a robed $gender who looks at Saniyah.
Saniyah : Who are you?
! showCharacterInput();
__name : My name is $name.

Where % is, is a character definition. $ is a conversation definition with the convo name wrapped in speech marks. : identifies narration. The name of a character followed by a : identifies dialogue. And – you guessed it – ! identifies a single line of code.

I will test the same line of code in a simple project and see if I get the same error, then I can try and boil it down.

I’ve tested the same code (in addition to a trace call) and put it into another basic project.

This is the results as executed and expected:

I removed the interpreter execute part and get the following results:

So no, hscript seems to handle one-liners quite well, so something in my project is causing this error but I’m unsure what.

EDIT: The same basic project also works in my primary target, JavaScript. So not a target-specific problem.

Nevermind, it was part of another line, just wasn’t obvious at first which line it was on my script.