I have a problem with syntax in cobol. I'm using open-cobol package on Ubuntu 4.2.0-16-generic, and i've got error:
~/cobol$ cobc -free -x -o cal cal.cbl
cal.cbl:6: Error: syntax error, unexpected $undefined, expecting "end of file"
My cal.cbl file:
IDENTIFICATION DIVISION.
PROGRAM-ID. cal.
ENVIRONMENT DIVISION.
DATA DIVISION.
?? OPTION PIC 9 VALUE ZERO.
?? NUM1 PIC 9(5)V9(2) VALUE ZERO.
?? NUM2 PIC 9(5)V9(2) VALUE ZERO.
?? RESULT PIC 9(10)V9(2) VALUE ZERO.
PROCEDURE DIVISION.
ACCEPT OPTION.
DISPLAY "INSERT FIRST OPTION".
ACCEPT NUM1.
DISPLAY "INSERT SECOND OPTION".
ACCEPT NUM2.
STOP RUN.
I'm new in cobolt, i know something about columns and thats why I'm using -free flag to compile, but this error have no sense for me.
Why this error occurs, please help:)
?? is no valid COBOL word and no level number (which is needed in line 6). These messages come from OpenCOBOL/GnuCOBOL 1.1.
Newer GnuCOBOL versions are much better in many ways, including user messages (here with GC 2.2):
cal.cob: 6: Error: Invalid symbol: ? - Skipping word
cal.cob: 6: Error: PROCEDURE DIVISION header missing
cal.cob: 6: Error: syntax error, unexpected Identifier
cal.cob: 7: Error: Invalid symbol: ? - Skipping word
cal.cob: 7: Error: syntax error, unexpected Identifier
cal.cob: 8: Error: Invalid symbol: ? - Skipping word
cal.cob: 8: Error: syntax error, unexpected Identifier
cal.cob: 9: Error: Invalid symbol: ? - Skipping word
cal.cob: 9: Error: syntax error, unexpected Identifier
cal.cob: 11: Error: syntax error, unexpected PROCEDURE
cal.cob: 12: Error: 'OPTION' is not defined
cal.cob: 15: Error: 'NUM1' is not defined
cal.cob: 17: Error: 'NUM2' is not defined
Change ?? to 01 or 77 and you don't have the error any more. Insert WORKING-STORAGE SECTION or LOCAL-STORAGE SECTION after DATA DIVISION and your program compiles fine.
Get the Programmer's Guide for knowing more about COBOL.
Related
File "/tmp/ipykernel_15300/319840370.py", line 18
print(target.size()s_history)
^
SyntaxError: invalid syntax
If target.size() and s_history are two different arguments:
print(target.size(), s_history)
If s_history is an attribute of whatever size()` method returns:
print(target.size().s_history)
I am facing an issue with the execution of following Groovy Script snippet.
GroovyShell sh = new GroovyShell();
sh.evaluate("\"abcd\".length() >= .34");
I am getting the following exceptions. The entire stack trace is mentioned below.
Exception in thread "main" org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unexpected token: >= # line 1, column 17.
"abcd".length() >= .34d
If I change .34 to 0.34, it works. However, because of some limitation, I won't be able to change the script content.
Any help to overcome will be appreciated.
I am getting the following exceptions
Exception in thread "main" org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unexpected token: >= # line 1, column 17.
"abcd".length() >= .34d
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:150)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:120)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:132)
at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:350)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:144)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:110)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:234)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:168)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:943)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:605)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:584)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
at groovytest.Testtest.main(Testtest.java:18)
Your Groovy snippet is incorrect - Groovy does not support notation without leading zero in case of decimal numbers smaller than 1.0. If you try to compile following expression directly using groovyc:
"abcd".length() >= .34
compilation will fail with error like:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 2: Unexpected input: '.' # line 2, column 20.
"abcd".length() >= .34
^
1 error
Java supports such notation, however Groovy from 2.x up to 3.0.0-alpha-3 version does not support it.
Solid solution
Fix the input Groovy code snippet to contain only a valid and compile-ready code. Any invalid Groovy statements or expressions will lead to failures and compilation errors.
Workaround: add leading zeros with replaceAll() method
The only way to compile such incorrect snippet is to replace all .\d+ (dots followed by at least one space and ended with a number) with 0.$1. Consider following example:
def snippet = "\"abcd\".length() >= .34; \"efgh\".length() >= .22; \"xyz\".length() >= 0.11;"
println snippet.replaceAll(' \\.(\\d+)', ' 0.$1')
It adds 0 to all decimal numbers where leading zero is missing. Running this example prints following output to the console:
"abcd".length() >= 0.34; "efgh".length() >= 0.22; "xyz".length() >= 0.11;
If you pass such modified snippet to GroovyShell.evaluate() method it will run with no errors.
Of course this is not a rock-solid solution and it is just a way to automatically fix some of the syntax errors introduced in the code snippet. There are some corner cases where this workaround may cause some side effects, you have to be aware of it.
this is my code
url = "E:\dataset\state_dataset\drug.csv"
dataframe = read_csv(url)
df=dataframe.loc[:,['Product Name','Number of Prescriptions','Total Amount Reimbursed','Medicaid Amount Reimbursed']]
df[(df.Number of Prescriptions >= 100)]
and I faced the error
File "", line 10
df[(df.Number of Prescriptions >= 100)]
^
SyntaxError: invalid syntax
please how can I fixed this error
Attempting to follow along with https://jacobmartins.com/2016/02/29/getting-started-with-oauth2-in-go/
When I run go get golang.org/x/oauth2 nothing weird comes up, but when attempting to run the code using go run main.go
I get the following in my terminal:
# google.golang.org/grpc/credentials
../../../google.golang.org/grpc/credentials/credentials_util_pre_go17.go:58:32: error: reference to undefined field or method ‘GetCertificate’
GetCertificate: cfg.GetCertificate,
^
../../../google.golang.org/grpc/credentials/credentials_util_pre_go17.go:69:32: error: reference to undefined field or method ‘ClientSessionCache’
ClientSessionCache: cfg.ClientSessionCache,
^
../../../google.golang.org/grpc/credentials/credentials_util_pre_go17.go:72:32: error: reference to undefined field or method ‘CurvePreferences’
CurvePreferences: cfg.CurvePreferences,
^
../../../google.golang.org/grpc/credentials/credentials_util_pre_go17.go:58:3: error: unknown field ‘GetCertificate’ in ‘tls.Config’
GetCertificate: cfg.GetCertificate,
^
# golang.org/x/net/http2/hpack
../../../golang.org/x/net/http2/hpack/huffman.go:14:20: error: reference to undefined identifier ‘sync.Pool’
var bufPool = sync.Pool{
^
../../../golang.org/x/net/http2/hpack/huffman.go:14:24: error: expected ‘;’ or newline after top level declaration
var bufPool = sync.Pool{
^
# golang.org/x/net/context/ctxhttp
../../../golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go:36:5: error: reference to undefined field or method ‘Cancel’
req.Cancel = cancel
^
# golang.org/x/oauth2/jws
../../../golang.org/x/oauth2/jws/jws.go:75:17: error: reference to undefined identifier ‘base64.RawURLEncoding’
return base64.RawURLEncoding.EncodeToString(b), nil
^
../../../golang.org/x/oauth2/jws/jws.go:93:16: error: reference to undefined identifier ‘base64.RawURLEncoding’
return base64.RawURLEncoding.EncodeToString(b), nil
^
../../../golang.org/x/oauth2/jws/jws.go:113:16: error: reference to undefined identifier ‘base64.RawURLEncoding’
return base64.RawURLEncoding.EncodeToString(b), nil
^
../../../golang.org/x/oauth2/jws/jws.go:124:25: error: reference to undefined identifier ‘base64.RawURLEncoding’
decoded, err := base64.RawURLEncoding.DecodeString(s[1])
^
../../../golang.org/x/oauth2/jws/jws.go:151:41: error: reference to undefined identifier ‘base64.RawURLEncoding’
return fmt.Sprintf("%s.%s", ss, base64.RawURLEncoding.EncodeToString(sig)), nil
^
../../../golang.org/x/oauth2/jws/jws.go:174:33: error: reference to undefined identifier ‘base64.RawURLEncoding’
signatureString, err := base64.RawURLEncoding.DecodeString(parts[2])
Go version is go version xgcc (Ubuntu 4.9.3-0ubuntu4) 4.9.3 linux/amd64
Running Linux Mint 17.3 Cinnamon
Anyone know what I'm doing wrong?
Looks like you are using go cgo installation. On Linux mint golang-go seems to be the distribution name.
But I would suggest installing the latest version of go (or version go 1.5 atleast) as mentioned in the below link and try again.
https://golang.org/doc/install
Remove your current installation before proceeding with the golang-go installation.
Error-[SE] Syntax error
Following verilog source has syntax error :
"design.sv", 5: token is '['
mux4x1 inst1(.sel[0](k), .sel[1](j), .I[0](q), I[1](0), .I[2](1),
.I[3](qb), .y(W1));
^
1 error
You cannot map a signal to an individual bit of a bus. Instead, you will need to map the concatenation of the signals onto the bus as a whole:
mux4x1 inst1(.sel({k, j}), .I({q, 2'b01, qb}), .y(W1));