Error: "Declaration expected but identifier 'SysUtils' found" - delphi-7

I am trying to use multiple identifiers in Delphi 7 receiving error
uses
Math;
SysUtils;
I am however receiving the error above.
Any help would be amazing.

Should be:
uses
Math,
SysUtils;
Semicolon (;) is a end of statement character, comma (,) separates items.

Related

Making a customized error message in yacc tool

Hi I just started working on lex and yacc tools.
I realized that yyerror recieves only the string "syntax error" from yacc.
I was wondering if I can customize this string.
Oh and also can I differentiate different types of errors? (tyring to have missing token and additional token as different erros.)
If so, how should I..?
Many thanks.
You're free to print any message you want to in yyerror (or even no message at all), so you can customise messages as you see fit. A common customisation is to add the line number (and possibly column number) of the token which triggered the error. You can certainly change the text if you want to, but if you just want to change it to a different language, you should probably use the gettext mechanism. You'll find .po files in the runtime-po subdirectory of the source distribution. If this facility is enabled, bison will arrange for the string to be translated before it is passed to yyerror, but of course you could do the translation yourself in yyerror if that is more convenient for you.
I suspect that what you actually want is for bison to produce a more informative error message. Bison only has one alternative error message format, which includes a list of "expected" tokens. You can ask Bison to produce such an error message by including
%define parse.error verbose
in your prologue. As the manual indicates, the bison parsing algorithm can sometimes produce an incorrect list of expected tokens (since it was not designed for this particular purpose); you can get a more precise list by enabling lookahead correction by also including
%define parse.lac full
This does have a minor performance penalty. See the linked manual section for details.
The list of tokens produced by this feature uses the name of the token as supplied in the bison file. These names are usually not very user-friendly, so you might find yourself generating error messages such as the infamous PHP error
syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
(Note: more recent PHP versions produce a different but equally mysterious message.)
To avoid this, define double-quoted aliases for your tokens. This can also make your grammar a lot more readable:
%type <string> TOK_ID "identifier"
%token TOK_IF "if" TOK_ELSE "else" TOK_WHILE "while"
%token TOK_LSH "<<"
/* Etc. */
%%
stmt: expr ';'
| while
| if
| /* ... */
while: "while" '(' expr ')' stmt
expr: "identifier"
| expr "<<" expr
/* ... */
The quoted names will not be passed through gettext. That's appropriate for names which are keywords, but it might be desirable to translate descriptive token aliases. A procedure to do so is outline in this answer.

Weird behaviour in elixir with whitespace character

I'm encountering a weird behaviour in Elixir when defining for example function default arguments or using head|tail in a list definitions.
This does not work and results in an error unexpected token: " ":
def a(b \\ "test") do
b
end
But this one does:
def a(b \\"test") do
b
end
The difference being the whitespace character " " preceding the default string argument "test"
Also this does not work and results in an error unexpected token: " ":
[0 | [1,2,3,4,5]]
But this one does work:
[0 |[1,2,3,4,5]]
Once again the difference being the whitespace character " " preceding the tail list definition [1,2,3,4,5]
The problem exists in IEX and compiled code. I'm running Elixir 1.4. My system is macOS Sierra and I'm using iTerm as my terminal app.
So the question is: is this the correct behaviour or is there something wrong for example in my environment and what it could possibly be? All the examples and guides allow whitespace in these positions but for some reason my environment does not. Is there something I can do about this?
Thank you in advance!
Issue got resolved as stated in the comments.
On macOS alt+space provides Non-breaking space character instead of normal space. The issue described occurred most of the times after inserting any character with alt-combination following whitespace because I just wasn't fast enough to release the alt-key and thus wrong whitespace was provided.
For instructions to resolve this on macOS (in case if you want to disable the alternative space) check out this question: https://superuser.com/questions/78245/how-to-disable-the-option-space-key-combination-for-non-breaking-spaces

What does "(...) interpreted as grouped expression" mean?

I'm using a Ruby linter in Atom and for some lines it gives the following warning:
(...) interpreted as grouped expression
An example of a line that get's this warning is this:
elsif not (params[:vacancy].nil? or params[:vacancy]['company_id'].nil? or params[:vacancy]['company_id'] == "0" )
How should that line be improved to make the warning go away?
The warning is
(...) interpreted as grouped expression
And it means exactly what it says: in Ruby, parentheses can be used for three purposes, expression grouping, parameter lists and argument lists. This warning is emitted when Ruby thinks that you want an argument list but wrote a grouped expression instead. The most common cause is whitespace between the name of the message and the argument list in a message send like this:
foo.bar (1, 2)
This will be interpreted not as an argument list for the message send, but rather a grouped expression, which, in this particular case, is a SyntaxError.
In your particular case, the warning seems to be a false positive.
Try to Remove the space between not and the parenthesis
The warning I get is from from MRI Ruby itself (with options -wc), and I think you have a typo in there. The message I get doesn't have the word "grounded" but "grouped".
Parenthesis in Ruby can be used for one of two things, to group expressions or to mark the argument list of a function or method.
What that error message is saying is that of these two options, Ruby is treating it like an expression. Note that it in Ruby is possible for you to define a method called "not".
And In this particular case it doesn't matter which way Ruby interprets the parenthesis.
One way to get rid of the message is to remove the space between "not (". If you think this is screwy, I agree with you.

Pig on EMR: how to include semicolon in regex argument of EXTRACT function

I'm working with some data in Pig that includes strings of interest, optionally separated by semicolons and in random order, e.g.
test=12345;foo=bar
test=12345
foo=bar;test=12345
The following code should extract the value of the string for the test 'key':
blah =
FOREACH
data
GENERATE
FLATTEN (
EXTRACT (
str_of_interest,
'test=(\\S+);?'
)
)
AS (
test: chararray
)
;
However, when running the code, I encounter the following error:
<line 46, column 0> mismatched character '<EOF>' expecting '''
2013-04-16 04:46:05,245 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <line 46, column 0> mismatched character '<EOF>' expecting '''
I thought I had my regex escape syntax off at first, but that doesn't appear to be the problem. The only information I get from a Google search is a bug report that appears to have been recently fixed, but it's still an issue on the Amazon EMR cluster I'm running (spun up ad hoc, just now, for this analysis).
As in the bug report and as suggested elsewhere, replacing the semicolon with its Unicode equivalent (\u003B) yields the same error.
I could be crazy and this could be a syntax issue, so I'm hoping someone might be able to point me in the right direction or confirm that this is an existing problem. If the latter, are there any workarounds (either in Pig, or for matching the string I want)?
Cheers
This is a bug which will be fixed in 0.12 (see http://issues.apache.org/jira/browse/PIG-2507)
If you can't change the delimiter or wait for the new version to be released (on EMR this can take longer than the actual Apache release), I'd Implement my own UDF and hardcode the regular expression in some way. You can use RegexExtract as a starting point.
Obviously you could also build your own version of pig by applying the patch but I guess that's a bit more complicated.
It looks like you are using Amazon's String Manipulation and DateTime Functions For Pig, since EXTRACT() isn't a built-in function.
Try switching over to using the built-in function REGEX_EXTRACT_ALL()

Significance of an ampersand in VB6 function name?

I just got a bunch of legacy VB6 (!) code dumped on me and I keep seeing functions declared with an ampersand at the end of the name, for example, Private Declare Function ShellExecute& . . ..
I've been unable to find an answer to the significance of this, nor have I been able to detect any pattern in use or signature of the functions that have been named thusly.
Anyone know if those trailing ampersands mean anything to the compiler, or at least if there's some convention that I'm missing? So far, I'm writing it off as a strange programmer, but I'd like to know for sure if there's any meaning behind it.
It means that the function returns a Long (i.e. 32-bit integer) value.
It is equivalent to
Declare Function ShellExecute(...) As Long
The full list of suffixes is as follows:
Integer %
Long &
Single !
Double #
Currency #
String $
As Philip Sheard has said it is an indentifier type for a Long. They are still present in .Net, see this MSDN link and this VB6 article
From the second article:
The rules for forming a valid VB variable name are as follows:
(1) The first character must be a letter A through Z (uppercase or
lowercase letters may be used). Succeeding characters can be letters,
digits, or the underscore (_) character (no spaces or other characters
allowed).
(2) The final character can be a "type-declaration character". Only
some of the variable types can use them, as shown below:
Data Type Type Declaration Character
String $
Integer %
Long &
Single !
Double #
Currency #
Use of type-declaration
characters in VB is not encouraged; the modern style is to use the
"As" clause in a data declaration statement.

Resources