Why is print() in Lua behaving like This? - lua

In Lua interpreter when I type
>print (12
>>3)
stdin:2: ')' expected (to close '(' at line 1) near '3'
Why am I getting this error?
When we type
>a=2
>a=a+
>>1
This works fine! Then why not print? What is wrong with print()?

The input is print (12 <NEWLINE> 3), which is a syntax error.
Adding a comma after 12 works fine.

Related

Problem with Computercraft: '=' expected near 'monitor'

I am new to computercraft and have a problem with my code.
The error is
'=' expected near 'monitor'
Do anyone know the problem and can fix it?

Error in printing string with characters and numbers in Fortran [duplicate]

This question already has an answer here:
Error in implicit declaration in Fortran
(1 answer)
Closed 1 year ago.
I am new to Fortran. I am trying to print a line that has some words and numbers. I type the following command for that-
integer i0lcan
integer i0l
integer i0rec
real r1supdomcan(n0l)
integer i0lcan
if(i2lcan(i0l,1).ne.0)then
do i0rec=1,n0rec
i0lcan=i2lcan(i0l,i0rec)
if(i0lcan.ne.0)then
call calc_supcan(i0lcan,demdom(i0lcan),
$ rivout(i0l),envflw(i0l),
$ supdomcan(i0lcan))
print *, 'calculate_humact at the grid: ', supdomcan(i0lcan), 'supplied from the grid no: ', i0lcan
This produces an error that Error: Expected expression in PRINT statement at (1)
However, there is no error if I keep the command as-
print *, 'calculate_humact at the grid: ', supdomcan(i0lcan)
What could be the reason behind that?
Your line is just too long. I supposed we might have a duplicate, but I did not find a good one.
Fixed form requires lines to use only 72 characters. Further characters on the line are just discarded.
The code you show unfortunately does not show the columns correctly.

stdin:1: '=' expected near '<'

So I'm starting to Learn Lua, my problem is that in a tutorial that teaches you to create Guess My Number Game starts with this line:
name = "John"
print<name>
So in the tutorial shows that prints the name but in mine gives this error:
stdin:1: '=' expected near '<'
Please, what am I getting this?
Thank you for all your help.
Functions use parentheses to enclose their arguments, so the second line should be
print (name)

why erlang not supporting expressions like : mysum(32)(1)

I am new in Eralng . get a little query about applying functions
assumming got a funciton defined :
mysum(X) -> fun(Y)-> X + Y end.
then try to calling like this
mysum(32)(332)
getting error
* 1: syntax error before: '('
so I had to
apply(mysum(32),[333])
or
M = mysum(32), M(333)
but I would like to know a little bit more , why it is not supporting , what is the disadvantage
As you expected, mysum return a function. you must enclose the evaluation inside parenthesis to satisfy the erlang parser:
(mysum(32))(332)
this spelling is obviously not ambiguous.
Your expression seems not ambiguous because you know that mysum(32) is a function, but the types are solved at run time in erlang, so the parser has no idea of what is mysum(32), it is expecting some help here to know what it has to do: the parenthesis, the apply or the intermediate variables, but it could be an operator or a separator.

javacc parseException... lookahead problem?

I'm writing a parser for a very simple grammar in javacc. It's beginning to come together but at the moment I'm completely stuck on this error:
ParseException: Encountered "" at line 4, column 15.
Was expecting one of:
The line of input in question is z = y + z + 5
and the production that is giving me problems is my expression which get called from
varDecl():
<ID> <EQL> expression()
Expression looks like this:
<VAR> (<PLUS> expression())?| <NUM> (<PLUS> expression())?
| call() (<PLUS> expression())?
I'm at a loss as to why I'm getting this error - any insight would be greatly appreciated.
Hm, yes, that's not a very helpful error from JavaCC. What version of JavaCC are you using?
Also, it's difficult to troubleshoot these problems without seeing the full grammar... and although I understand you might not be in a position to post that.

Resources