luciotato / LiteScript

Compile-to-js and compile-to-c language, highly readable, keep it simple philosophy
GNU Affero General Public License v3.0
147 stars 7 forks source link

ERROR: test.lite:2:1. Module: found ' '(EOF) but 'NEWLINE' required #10

Open mationai opened 10 years ago

mationai commented 10 years ago

I have a simple test.lite file, created simply via vi:

print "hi"

lite -run test.lite gave me:

ERROR: test.lite:3:1. Module: found ' '(EOF) but 'NEWLINE' required

Again, the file is created simply with vi, so file encoding is the standard unix (on OSX). Also, why does it say line 3? The file only as a single line, w/o any CRs.

running the latest v0.8.8 Build

luciotato commented 10 years ago

Try indenting 4 spaces the line. code is always indented at least 4 spaces. (Note: ''' won't do).

$ echo "    print 'hi'">test.lite
$ lite -v 0 -run test.lite
hi

$ echo "print 'hi'">test.lite
$ lite -v 0 -run test.lite
 ERROR: test.lite:3:1. Module: found ' '(EOF) but 'NEWLINE' required 
 test.lite:3:1. Module: found ' '(EOF) but 'NEWLINE' required 
mationai commented 10 years ago

Would separating the requirement to have 4 indented spaces to only .md files be worth while? I like liteScript for its smart static type system and other goodies, not for the .md part, so forcing 4 spaces everywhere is a bad idea for my use case (and I imagine for many or perhaps most people too). I tried to remove that requirement from Grammar and Parser, but blockIndent <= parentIndent still failed in ASTBase. So currently I'm adding a step in my gulp process to insert indentations. If I didn't have to do that, it would be great.