Author Topic: Error Parsing "If"  (Read 11950 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Re: Error Parsing "If"
« Reply #15 on: May 28, 2014, 02:08:41 PM »
Option 2 would be consistent with a colon always being interpreted as a soft line break.

2  if a=1 : b=1 : end if   'endif explicit

That leaves case as the slightly odd one out.

case a : b=1

Mike Lobanovsky

  • Guest
Re: Error Parsing "If"
« Reply #16 on: May 28, 2014, 02:14:20 PM »
No oddity seen here, Charles. The case that follows marks unambiguously the end of case immediately preceding it while end select will mark the end of entire block.

Mike Lobanovsky

  • Guest
Re: Error Parsing "If"
« Reply #17 on: May 28, 2014, 02:40:20 PM »
I don't know is there a way to replace UDT variables with ordinary typed...maybe   :-\

Absolutely no problem here, Aurel. Just split each UDT into two simple variables and create two arrays for them. The array sizes will be the same and the indices within them will point to the same elements that they pointed to when each two-member UDT was still a single entity. This would be the easiest problem throughout the entire port. :)

Quote
but this is standard tactic anyway...

But it shouldn't be, at least as far as standard language constructs are concerned. This is why I'm so agitated: Charles is shaking the foundations and I'm already seeing the first bricks fall off the roof and bump on my head. :)
« Last Edit: May 28, 2014, 02:55:00 PM by Mike Lobanovsky »

Charles Pegge

  • Guest
Re: Error Parsing "If"
« Reply #18 on: May 28, 2014, 02:56:36 PM »
I think option 2 tips the balance in your favour, Mike: :)

We can now do expressions like this (if we really want to):

sys a=2, b=0

if a=1 : b=1 : elseif a=2 : b=2 else b=3 : end if

or

if a=1 then : b=1 : elseif a=2 then : b=2 : else : b=3 : end if

print b

« Last Edit: May 28, 2014, 03:04:30 PM by Charles Pegge »

Mike Lobanovsky

  • Guest
Re: Error Parsing "If"
« Reply #19 on: May 28, 2014, 03:02:04 PM »
Are you sure there are no typos here?
sys a=2, b=0
if a=1 : b=1 : elseif a=2 : b=2 else b=3 : end if
print b

And I suppose there may be anything instead of a sys here? (Just asking to be on the safe side, hehe...)

A voice in the wilderness again... yet maybe this is somehow better than nothing at all. :)

Charles Pegge

  • Guest
Re: Error Parsing "If"
« Reply #20 on: May 28, 2014, 03:08:46 PM »
Yes, Any primitive type: int, float or string.

I'm testing as we 'speak'. It works any which way. keywords then / else / elseif : are all expression terminators.

Mike Lobanovsky

  • Guest
Re: Error Parsing "If"
« Reply #21 on: May 28, 2014, 03:13:54 PM »
It works any which way. keywords then / else / elseif : are all expression terminators.

Does that mean :'s after then and before else and elseif (and I suppose, before end too) are optional???

Charles Pegge

  • Guest
Re: Error Parsing "If"
« Reply #22 on: May 28, 2014, 03:21:29 PM »
The colon after then is essential to distinguish it from lines like

if a>1 then b=1


Similarly, a colon must come after an elseif condition.

end if / endif must be preceded by a colon under current parsing rules.

then is optional in these cases

JRS

  • Guest
Re: Error Parsing "If"
« Reply #23 on: May 28, 2014, 03:24:56 PM »
This is why I'm glad Peter Verhas made the wise decision to only allow one statement per line.

This is a legal variable name in SB.

Hi = Hello:World

« Last Edit: May 28, 2014, 03:44:41 PM by John »

Mike Lobanovsky

  • Guest
Re: Error Parsing "If"
« Reply #24 on: May 28, 2014, 03:25:58 PM »
Charles,

Is your

b=2 else b=3

correct?


Hi John,

Quote
one statement per line

No "soft" line breaks (like : here) at all?

JRS

  • Guest
Re: Error Parsing "If"
« Reply #25 on: May 28, 2014, 03:33:39 PM »
Code: [Select]
PRINT test( _
arg1, _
arg2, _
"""
               Multi
               Line
               String
""")

This is one statement.
« Last Edit: May 28, 2014, 03:42:41 PM by John »

Mike Lobanovsky

  • Guest
Re: Error Parsing "If"
« Reply #26 on: May 28, 2014, 03:38:37 PM »
This is one statement.

Got it. The only legit line break is a *nix LF (0xA).

BTW FBSL's multiline string would be

"
Multi
Line
String
"


to be printed as

Multi
Line
String


Yours would be printed to the console as

"
Multi
Line
String
"




Charles,

What about my last question, please?
« Last Edit: May 28, 2014, 03:45:45 PM by Mike Lobanovsky »

Charles Pegge

  • Guest
Re: Error Parsing "If"
« Reply #27 on: May 28, 2014, 03:43:43 PM »
Yes Mike, the else syntax works the same as before. I am almost ready to post an update. Just working through the permutations.

if a=1 then b=1 else b=5

JRS

  • Guest
Re: Error Parsing "If"
« Reply #28 on: May 28, 2014, 03:47:52 PM »
a = _
"""
"Multi",
"Line',
'String'
"""
 :)

Mike Lobanovsky

  • Guest
Re: Error Parsing "If"
« Reply #29 on: May 28, 2014, 03:48:42 PM »
Charles,

Please "yes" or "no":

if a=1 : b=1 : elseif a=2 : b=2 else b=3 : end if

does not require a colon before else, does it?