puffnfresh / roy

Small functional language that compiles to JavaScript.
http://roy.brianmckenna.org/
MIT License
834 stars 74 forks source link

Multi line repl #193

Closed joneshf closed 10 years ago

joneshf commented 10 years ago

Can someone put some fresh eyes on this. I haven't had enough sleep to just merge this into master all fast and loose.

If it's mergable, it should close #29 and #147.

taku0 commented 10 years ago
// This shows the help for metacommands. Replacing /:/ with /^:/ will fix it. 
":"

// Regarded as a start of a block.
// Replacing \b(do|match).+? to \b(do|match)\b.+? will fix it.
let maching = 1

let doc = 1

// Regarded as a start of a block.
// No simple fix.
"do"

"match"
joneshf commented 10 years ago

Thanks for taking a look.

Good catch on the colon, it was showing the help for things like {a: 17}.

I'm not entirely sure what to do about do and match. I'm thinking we have access to the tokens, could just tokenize the line and check for a do or match. Any thoughts about that approach? As it stands now, both of those statements require a block in order to parse correctly.

joneshf commented 10 years ago

Hmm, so now : is parsed as an invalid command, in fact anything that begins with : and isn't in the list of commands parses as invalid. As for the do/match hangup, if I understand the grammar properly. It's gotta be

do <expr>
  <block>

or

match <expr>
  <block>

So, I updated it to work better with that.

I tried the tests in the repl, and they seemed to pass with just pasting them in there.

Any other suggestions? If not I'm calling this good and merging it in.