Suloch / chirp

Interpreter in C for rockstar programing language
MIT License
22 stars 5 forks source link

example from the website doesn't work as expected, invalid characters. #19

Open BMaxV opened 1 month ago

BMaxV commented 1 month ago

There is an example rockstar script on the website https://codewithrockstar.com/

That goes like this:

Midnight takes your heart and your soul
While your heart is as high as your soul
Put your heart without your soul into your heart

Give back your heart

Desire is a lovestruck ladykiller
My world is nothing 
Fire is ice
Hate is water
Until my world is Desire,
Build my world up
If Midnight taking my world, Fire is nothing and Midnight taking my world, Hate is nothing
Shout "FizzBuzz!"
Take it to the top

If Midnight taking my world, Fire is nothing
Shout "Fizz!"
Take it to the top

If Midnight taking my world, Hate is nothing
Say "Buzz!"
Take it to the top

Whisper my world

which produces this output:

\m/
syntax error on line 13 at ,
invalid character on line 13 at ,
invalid character on line 13 at ,
fish: Job 2, './chirp example.rock' terminated by signal SIGSEGV (Address boundary error)

upon removing the "," it produces this:

\m/
syntax error on line 15 at Fire
invalid character on line 15 at Fire
invalid character on line 15 at is
invalid character on line 15 at is
invalid character on line 15 at nothing
invalid character on line 15 at and
invalid character on line 15 at taking
invalid character on line 15 at taking
invalid character on line 15 at Hate
FizzBuzz!
not valid statement
syntax error on line 19 at Fire
invalid character on line 19 at Fire
invalid character on line 19 at is
invalid character on line 19 at is
invalid character on line 19 at nothing
Fizz!
not valid statement
syntax error on line 23 at Hate
invalid character on line 23 at Hate
invalid character on line 23 at is
invalid character on line 23 at is
invalid character on line 23 at nothing
Buzz!
not valid statement
Segmentation fault (core dumped)

and I can't make a rhyme on why it would treat regular words or regular characters as invalid?

The examples included in the example folder seem to work fine though.

Suloch commented 1 month ago

Hi, thanks for reporting. There are 2 things going wrong.

  1. The error due to comma at the end of line 13. It is different from rest of the commas as rest are being used for passing arguments but here this is just an extra.
  2. The and operation in conditional operation. I do not remember for sure. But, I believe some of the specs might have changed. Since in the implementation, the "and" keyword is being for list.

Solution:

  1. Ignore comma at the end of line
  2. Add conditional operations 'and' and 'or'

Both are not that difficult, but will require some time to fix. I will try to update as soon as I can.

BMaxV commented 1 month ago

Super cool, thanks for the update!