why am I getting an error in the identification division? - syntax-error

The following code :
IDENTIFICATION DIVISION.
PROGRAM-ID. tester.
PROCEDURE DIVISION.
greet_program.
DISPLAY "HELLO WORLD !".
STOP RUN.
produces a compiler error which says : Error: syntax error, unexpected WORD, expecting PROGRAM_ID
I am unable to spot the error. Where is it ?
The errors with the program are listed here at ideone

You are compiling using the option of a traditional "fixed" Cobol layout.
That means you need to start each line with seven blanks.
You should have asked yourself why the first error messages referred to column seven. You could also have found some sample Cobol cobde and compare it to yours. Other people you can find with Google who've done the same thing.

Related

How can I make bison return all the syntax errors?

I'm trying to make bison return all the syntax errors that are in a given test file.
But the problem is that the parser stops whenever it encounters a syntax error and report it
Is there any way to make report all the syntax errors directly?
In order to continue parsing after a syntax error, you need to add error recovery rules to the grammar. Understanding how error recovery works really requires understanding the guts of how bison's shift/reduce parser works. The bison manual has a reasonable section on error recovery, which is where you should start.
With good error recovery rules, the parser can can continue after a syntax error and (potentially) find more syntax errors. You do need to be careful about the return value from yyparse after error recovery -- if the error recovery is "successful" and is able to continue parsing, and there are no further errors, yyparse will return 0 (success).

Why in Intellij IDEA presence of ENQ/ESA unicode character in code cause it to show false multiple character literals error?

I was trying to fix some weird PDF Unicode remapping issues when I was stuck by this issue where adding an ENQ Unicode character to some part of the code prevents you from compiling the code and IDE will present you with what I think is a false alarm(error).
Consider this example of completely valid Kotlin code and let's call it Program A where unfortunately you can't see the actual characters here between apostrophes but believe me there's a character in there (if you copy this code into your IDE you can see those characters).
package yamin
fun main() {
val foo = mutableListOf('')
//val bar = mutableListOf('')
println(foo)
}
However, you can see them in the picture.
But if you decide to compile this code somehow IDE fails to compile it and claims that there are 'Too many characters in a character literal' in line 4.
What is interesting is that the sheer presence of ENQ character even in a comment line prevents the IDE to compile this code and if you remove line 5, therefore, removing the presence of ENQ character then you can compile this code (let's call it Program B), observe:
Anyway if you decide to remove line 4 in Program A and uncomment line 5 then you can compile that code too (let's call it Program C).
So let's recap Program A is invalid and line 4 is the culprit of the invalidity but removing line 5 in that program which leaves us with Program B could be compiled successfully and this situation is repeated for Program C.
What am I missing here?
It looks like a bug in Kotlin compiler, because the error happens even if the code is compiled with command-line:
kotlinc enq.kt -include-runtime -d enq.jar
Also, this simple program gives different results on the playground (correct):
and locally (incorrect):
As a workaround you may use Unicode escape sequence syntax (at least for ENQ symbol):
Playground does the same thing when passing this code to the server, so the compiler gets sanitized code:

How to solve RFC_CONVERSION_FIELD error in SAP?

My Python script queries the rows of table AUFK via RFC which have BUKRS=1110, but I get the error:
RFC_CONVERSION_FIELD
Convertion error "rfc_ucs_to_str" from charset 4110 to charset 4103
(translated from german to english by me)
The shortdump seems to show a wrong line number (line 1), but I guess this is not true.
My code works fine since several weeks. That's why I guess there must be something wrong with the data (a database row in AUFK).
Is there a way to debug which line of AUFK is broken? Or is the error in my code, and not the data?
I read the SAP note 2504815, but it does not help. The client is Python (pyRFC) and the server is a 7.40 Unicode system.

invalid syntax in generating a variable in Stata

While creating this variable in stata14 I've got an error (198)
this is the variable that I want to generate:
g ncskew =(-(([_n])*([_n-1])^(1.5)*(sum(returns^3))))///
/(([_n-1])*([_n-2])*(sum(returns^2)^(1.5))
It is quite a puzzle but I think that the brackets are well placed.
Any help or advice would be appreciated.
The problem that jumps out at my eye is that the /// at the end of the first line is not preceded by any whitespace. That is a syntax error.
The other problem is that you have 13 opening parentheses ( and just 12 closing parentheses ). Is this your actual code or a mis-typed copy?
Whether that are the only problems with your code, I cannot say. If that is your actual code, fix that first and see what happens.

When is EOF needed in ANTLR 4?

The TestDriver in ANTLRWorks2 seems kind of finicky about when it'll accept a grammer without and explicit EOF and when it will not. The Hello grammar in the ANTLR4 Getting Started Guide doesn't use EOF anywhere, so I inferred that it's better to avoid explicit EOF if possible.
What is the best practice for using EOF? When do you actually need it?
You should include an explicit EOF at the end of your entry rule any time you are trying to parse an entire input file. If you do not include the EOF, it means you are not trying to parse the entire input, and it's acceptable to parse only a portion of the input if it means avoiding a syntax error.
For example, consider the following rule:
file : item*;
This rule means "Parse as many item elements as possible, and then stop." In other words, this rule will never attempt to recover from a syntax error because it will always assume that the syntax error is part of some syntactic construct that's beyond the scope of the file rule. Syntax errors will not even be reported, because the parser will simply stop.
If instead I had the following rule:
file : item* EOF;
In means "A file consists exactly of a sequence of zero-or-more item elements." If a syntax error is reached while parsing an item element, this rule will attempt to recover from (and report) the syntax error and continue because the EOF is required and has not yet been reached.
For rules where you are only trying to parse a portion of the input, ANTLR 4 often works, but not always. The following issue describes a technical problem where ANTLR 4 does not always make the correct decision if the EOF is omitted.
https://github.com/antlr/antlr4/issues/118
Unfortunately the performance impact of this change is substantial, so until that is resolved there will be edge cases that do not behave as you expect.