syntax error near unexpected token ( in Lua - lua

I'm playing with lua, using the following link: https://www.lua.org/pil/8.html and got confused about this syntax error.
So, the file foo.lua is as the following:
function foo (x)
print(x)
end
Then,
~$ f = loadfile("foo.lua")
bash: syntax error near unexpected token `('
Any comments are greatly appreciated.

Related

Yii2 - syntax error - while loading the index page

I am Getting a syntax error, while installing yeesoft/yii2-yee-core through composer.
ERROR: Parse error: syntax error, unexpected ';', expecting ']' in C:\new\htdocs\mysite.com\common\config\main.php on line 19
Code Snippet:
code snippet part1 and
code snippet part2
On line 19 you have:
'rules' => array[
This is syntactically incorrect. You should change this to:
'rules' => [
Since you typically define an array in either one of two ways:
$array = ['value_one', 'value_two'];
$another_array = array('value_one', 'value_two');
See Array Syntax in the PHP documentation.
In my case it was a syntax error, with a bracket at a location missing.
If you have any other points to add, please do.

Syntax error, unexpected tSTRING_BEG ROR

Below is my code:
gem_package 'cucumber' do
clear_sources true
source https://chefrubyaehq.kdc.example.com/
gem_binary '/opt/chef/embedded/bin/gem'
action :install
end
And I am getting the following error:
FATAL: zng937-test/recipes/default.rb:43: unknown regexp options - chfrbyahq
FATAL: zng937-test/recipes/default.rb:44: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
FATAL: gem_binary '/opt/chef/embedded/bin/gem'
Does anyone have any idea why I would be getting this?
You need to put the source (https://chefrubyaehq.kdc.capitalone.com/) inside quotes to make it a string. Either single or double quotes is fine for this case.
Just as the message says.
Your regex //chefrubyaehq is invalid. Ruby regex only has i, o, x, m options.
You forgot to put a period after your regex /\n gem_binary '/ before the method opt.
And when you fix those, you will still encounter more errors.

ROBLOX Lua Error in script: '=' expected near '<eof>'

Hello I am writing a scipt on ROBLOX and I have encountered a problem.
function showVictoryMessage(playerName)
local message = Instance.new("Message")
message.Text = playerName .." has won!"
message.Parent = game.Workspace
wait (2)
message.Destroy()
end
Upon running this function, or more specifically the "message.Destroy" command, I get the error: Error in script: '=' expected near '< eof >'
I have never seen this error before, and the ROBLOX wiki page on Lua errors doesn't mention it.
I would very much appreciate help in this, because I don't personally know anyone who has coded in Lua.
Looks like a syntax error. message.Destroy() should be message:Destroy() according to this Roblox wiki page http://wiki.roblox.com/index.php?title=API:Class/Instance/Destroy
Also see the section Explosions, Messages, and More at URL http://wiki.roblox.com/index.php?title=Basic_Scripting which provides similar syntax using the colon (:) operator.
See also Difference between . and : in Lua and explanation of "possible side-effects of calculations/access are calculated only once" with colon notation.
Instead of message.Destroy() it should be message:Destroy()
Remember that '.' are used directory-wise and ":' are used for inbuilt functions.
WOOOOOOOO! It was a syntax error. The correct command is message:Destroy. Cause why would object.Destroy work and message.Destroy not?

Determining ANTLR version to use, or converting between?

I want to take the .g files from Apache Hive and build a parser (targeting JavaScript) -- initially, as just a way to validate user-input Hive queries. The files I'm using come from apache-hive-1.0.0-src\ql\src\java\org\apache\hadoop\hive\ql\parse from the Hive tgz: HiveLexer.g, HiveParser.g, FromClauseParser.g, IdentifiersParser.g, SelectClauseParser.g.
I see no indication within the grammar files which version of ANTLR to use, so I've tried running antlr (from apt-get pccts), antlr3 and antlr4. they all throw errors of some sort, so I have no clue which one to run or if I can (or need to) convert the .g files between versions.
The errors I'm getting are as follows:
antlr -Dlanguage=JavaScript HiveParser.g (looks like it doesn't support JS anyway):
warning: invalid option: '-Dlanguage=JavaScript'
HiveParser.g, line 17: syntax error at "grammar" missing { QuotedTerm PassAction ! \< \> : }
HiveParser.g, line 17: syntax error at "HiveParser" missing { QuotedTerm PassAction ! \< \> : }
HiveParser.g, line 17: syntax error at ";" missing Eof
HiveParser.g, line 28: lexical error: invalid token (text was ',')
antlr3 -Dlanguage=JavaScript HiveParser.g:
error(10): internal error: Exception FromClauseParser.g:302:85: unexpected char: '-'#org.antlr.grammar.v2.ANTLRLexer.nextToken(ANTLRLexer.java:347): unexpected stream error from parsing FromClauseParser.g
error(150): grammar file FromClauseParser.g has no rules
error(100): FromClauseParser.g:0:0: syntax error: assign.types: <AST>:299:68: unexpected AST node: ->
error(100): FromClauseParser.g:0:0: syntax error: define: <AST>:299:68: unexpected AST node: ->
error(106): SelectClauseParser.g:151:18: reference to undefined rule: tableAllColumns
antlr4 -Dlanguage=JavaScript HiveParser.g:
warning(202): HiveParser.g:30:0: tokens {A; B;} syntax is now tokens {A, B} in ANTLR 4
error(50): HiveParser.g:636:34: syntax error: '->' came as a complete surprise to me while looking for rule element
error(50): HiveParser.g:636:37: syntax error: '^' came as a complete surprise to me
error(50): HiveParser.g:638:50: syntax error: '->' came as a complete surprise to me while looking for rule element
error(50): HiveParser.g:638:53: syntax error: '^' came as a complete surprise to me
The antlr3 error referencing #org.antlr.grammar.v2.ANTLRLexer.nextToken seems suspect. Is it using the v2 lexer instead of v3? If so, maybe v3 is what I should target, but it's somehow not hitting it?
Or is this not an issue with versioning and instead with invocation? Or is Hive built in a way that provides additional files needed?
According to Hive source code, they use ANTLR 3.4. But before you start remove the last string from FromClauseParser.g
//------------------------------------------------------------------------

Rails generate model syntax error

I'm trying to generate a model from the command line. Here is my command:
rails generate model User first_name:string last_name:string email_address:string age:integer
And it keeps giving me this error:
SyntaxError: (irb):2: syntax error, unexpected tLABEL, expecting keyword_do or '{' or '('
User first_name:str last_name:**str** email_address:str age:int
(irb):2: syntax error, unexpected tLABEL, expecting keyword_do or '{' or '('
name:str email_address:str age:**integer**
I'm lost. I learned this yesterday and the syntax is exactly the same as before when it worked fine.
Thanks
Edit: StackOverflow wouldnt let me post this unless I formatted that error as code FYI
You should put this command in your system console, not Rails console.

Resources