Typing multiline expressions in nix repl - read-eval-print-loop

This PR seems to indicate that it was at least a feature in nix repl's predecessor, nix-repl.
When I try to replicate the example in the PR, I get errors.
nix-repl> rec {
error: syntax error, unexpected end of file, at (string):1:6
nix-repl> a = b.foo;
error: syntax error, unexpected ';', expecting end of file, at (string):1:7
nix-repl> b.foo.bar = 12;
error: syntax error, unexpected '=', expecting end of file, at (string):1:23
nix-repl> }
error: syntax error, unexpected '}', at (string):1:11
nix-repl>

Related

compilation Error: unexpected TOKEN_Function

This is the error i get:
Error [mod0000_mergedfiles]game\gui\main_menu\ingamemenu.ws(2179): syntax error, unexpected TOKEN_FUNCTION, expecting '{' or ';', near 'function'.
To clarify the line with the syntax error is 2179.
And here is the entire script: https://pastebin.com/UsUjJ1rY.
function ShouldHideDLCIcons():bool
{
return theGame.GetInGameConfigWrapper().GetVarValue('fhudMainMenu', 'fhudHideDLC');
}

How to get file name that causes GraphQLError: Syntax Error: Unterminated string

In our team we sometimes get an GraphQl syntax error, when modifying our schema.
However, we don't seem to get the name of file causing the issue? The error looks like this:
GraphQLError: Syntax Error: Unterminated string.
at syntaxError (<full-path-to-project>>node_modules/graphql/error/syntaxError.js:15:10)
at readString (<full-path-to-project>>node_modules/graphql/language/lexer.js:513:38)
at readToken (<full-path-to-project>>node_modules/graphql/language/lexer.js:267:14)
at Object.lookahead (<full-path-to-project>>node_modules/graphql/language/lexer.js:54:43)
at Object.advanceLexer [as advance] (<full-path-to-project>>node_modules/graphql/language/lexer.js:44:33)
at Parser.parseStringLiteral (<full-path-to-project>>node_modules/graphql/language/parser.js:519:17)
at Parser.parseDescription (<full-path-to-project>>node_modules/graphql/language/parser.js:728:19)
at Parser.parseFieldDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:856:28)
at Parser.optionalMany (<full-path-to-project>>node_modules/graphql/language/parser.js:1497:28)
at Parser.parseFieldsDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:846:17)
at Parser.parseObjectTypeDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:798:23)
at Parser.parseTypeSystemDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:696:23)
at Parser.parseDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:146:23)
at Parser.many (<full-path-to-project>>node_modules/graphql/language/parser.js:1518:26)
at Parser.parseDocument (<full-path-to-project>>node_modules/graphql/language/parser.js:111:25)
at parse (<full-path-to-project>>node_modules/graphql/language/parser.js:36:17) {
message: 'Syntax Error: Unterminated string.',
locations: [ { line: 27, column: 51 } ]
}
Is this normal - and how do I get the file causing the problem?

syntax error near unexpected token in a case

I am trying to compare in bash using case (in a Jenkinsfile) a given value and act upon it. However, the case fails due to:
syntax error near unexpected token `Manager'
The error happens here:
...
...
def microServicesList = microServicesToUpdate.tokenize(",")
...
...
for (String microserviceName : microServicesList) {
sh """
...
...
case ${microserviceName} in
"Instances Manager")
// do something
;;
esac
"""
}
Had to surround it with double quotes:
case "${microserviceName}" in

VHDL syntax error using when

I have the following code:
DATA_LCD <= DATA_ROM when SW(1)='0' or char_code<97 or char_code>122 else
std_logic_vector(char_code-32); -- no modification in this code
DATA_ROM when SW(2)='0' else
std_logic_vector(char_code+1);
But when i try to compile it i get following errors:
Error (10500): VHDL syntax error at LCD_FSM.vhd(57) near text "="; expecting "(", or "'", or "."
Error (10500): VHDL syntax error at LCD_FSM.vhd(57) near text "when"; expecting "(", or "'", or "."
How can I fix it?
Brian is right, line 3 is a new (malformed) statement.
You forgot to put another DATA_LCD <= at the beginning of it.
DATA_LCD <= DATA_ROM when SW(2)='0' else std_logic_vector(char_code+1);

Ruby block comment and profile questions

I have written a Ruby version of Erik Demaine's (MIT) docdist8.py. This is available on github as docdist-v3.rb. I faced two weird kind of situations:
1) In the function inner_product there is a block comment:
Inner product between two vectors, where vectors
are repeated as dictionaries of (word, freq) pairs.
Example : inner_product({"and":3, "of":2, "the":5},
{"and":4, "in":1, "of":1, "this":2}) = 14.0
If I wrap this with =begin and =end there is no problem, but if I wrap it with triple double-quotes """, I get errors as follows:
./docdist-v3.rb:71: syntax error, unexpected tIDENTIFIER, expecting kEND
Example : inner_product({"and":3, "of":2, "the":5},
^
./docdist-v3.rb:71: syntax error, unexpected tIDENTIFIER, expecting kEND
Example : inner_product({"and":3, "of":2, "the":5},
^
./docdist-v3.rb:72: syntax error, unexpected kIN, expecting kEND
... {"and":4, "in":1, "of":1, "this":2}) = 14.0
^
./docdist-v3.rb:72: syntax error, unexpected tIDENTIFIER, expecting kEND
... {"and":4, "in":1, "of":1, "this":2}) = 14.0
^
./docdist-v3.rb:72: syntax error, unexpected tIDENTIFIER, expecting kEND
..."and":4, "in":1, "of":1, "this":2}) = 14.0
^
Are there rules / allowed entries for """ that are different from =begin and =end?
2) When I run my program with the time command it executes in about 0.3 seconds. However, if I put require 'profile' the time it takes becomes very high in comparison - 30 seconds. Hence I don't get the correct output at all. This doesn't seem to be the case with the original Python version, where it takes only a marginal extra time to profile. How do I get the same profile run in Ruby?
Note: The two files I used to run the Ruby program are t2.bobsey.txt and t3.lewis.txt. They are available at http://ocw.mit.edu/ans7870/6/6.006/s08/lecturenotes/dd_data.htm
1) Block comments always have the form:
=begin
Comment
=end
You are actually creating a string that is never used:
"""
Not a comment
"""
# => "\nNot a comment\n"
That's why you get an error when adding another quote and that's why the syntax highlighting renders them as strings.
2) It's slower with profiler but I get identical results:
ruby docdist-v3.rb t2.bobsey.txt t3.lewis.txt
File t2.bobsey.txt:262111 lines,49785 words,3354 distinct words
File t3.lewis.txt:1015474 lines,182355 words,8530 distinct words
The distance between the documents is: 0.574160 (radians)

Resources