[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to read thru a script file from C a line at a time.
- From: "Edward Mitchell" <emitchell@...>
- Date: Wed, 18 Oct 2006 21:57:18 -0400
"Nick Gammon" <nick@gammon.com.au> wrote in message
B21202B7-1612-4546-BD00-4740D4CC7A05@gammon.com.au">news:B21202B7-1612-4546-BD00-4740D4CC7A05@gammon.com.au...
>
> On 18/10/2006, at 6:39 AM, Edward Mitchell wrote:
>
>> Is there a way I can pass line by line of a script to Lua.
>
> I don't think you can do this reliably. Take this example:
>
> a = 2 + 2
> + 3
> print (a)
>
> The first line (a = 2 + 2) is a complete statement, which will compile
> OK. However if you do that, then the "+ 3" line won't make sense.
>
> However the whole thing is semantically correct and should print 7.
>
Nick,
You're right, without a sentence terminator it's not possible to determine
whether there is some text missing. I was used to a sentence in the
language either being terminated with a semicolon or a curly brace. Since
Lua ignores new lines effectively (and doesn't require a sentence
terminator), the entire input file has be read before a decision can be made
on the correctness of the Lua program that the file (or string) contains.
Ed