JFlex + BYACC/J: Syntax error - java

I am using JFlex + BYACC/J to parse a small language.
Everything works but the error message for any syntax error (yyerror) is simply
"Error: syntax error".
Is there any (easy) way of generating more verbose error messages? The -v (verbose) flag only generates a y.output file with a description of the state machine.
Goal is to have error messages such as: "Expected X before Y but found Z" or something similar.
EDIT (w.r.t comments):
Above goal can be achieved in Bison but it does not solve my problem with BYACC/J

Related

getting syntax error from nifi ExecuteScript processor inspite of correct python code

I am getting below error inspite of correct python code don't know how to resolve this error. Any help is much appreciated
org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: SyntaxError: no viable alternative at input '*' in <script> at line number 35 at column number 26
python code
def get_match_list(regEx, line):
match = re.search(regEx, line)
print(match)
if match:
match_list = [*match.groups()] # this is the line exception is pointed
return match_list
else:
return []
It looks like jython use python 2.7 and as Unpacking Generalizations is a feature that introduced in python 3.5 you can not use this syntax in jython, so an alternative way to convert a tuple to a list is that use list ( match.groups) it works fine in older versions of python and current version of jython (2.7.2)

Alternative for AnyLogic deprecated method getJComponent()?

I recently updated to AnyLogic PLE 8.4.0 and Java SE 12 on my Windows 10 laptop. And now an AnyLogic model that used to work earlier stops with the error "The method getJComponent() is undefined for the type ShapeTextField." I looked it up in AnyLogic/Help and I notice that getJComponent is identified as "Deprecated" and no alternative is identified. It appears to me that some mismatch happened between AnyLogic and Java updates that resulted in this error. I would appreciate any workarounds to get the model working.
Tried replacing getJComponent() with the following:
by getX() - gave error "cannot cast from double to Jtextfield"
by getPresentable() - gave error "cannot cast from Presentable to Jtextfield"
by getClass() - gave error "Description: Cannot cast from Class to JTextField."
by getComponentGraphics() - gave error "Description: The method getComponentGraphics() is undefined for the type ShapeTextField."
by equals - gave error "Description: The method equals(Object) in the type Object is not applicable for the arguments ()."
The code is:
((JTextField)(editbox.getJComponent())).setHorizontalAlignment(JTextField.LEFT);
This is defined in Simulation - Simulation Experiment / Java Actions/ Initial Experiment Setup field
Expected result: No error message. And the model should proceed to run window.
Thanks to the inputs from #Benjamin and #Felipe the following worked:
I replaced the editbox and buttons with corresponding artifacts from
AL8.4 palette. I copied the code from the earlier artifacts to
corresponding fields in the new artifacts. I deleted the artifacts
that were from AL7.
I commented out the line that was meant to align the editbox since
that capability is not available anymore.
With the above two changes I didn't get the error message about undefined method. The editbox and buttons worked and allowed me to enter XML filename and reading it with an XML parser routine. I have now run into issue with JAXB integration with AL8.4 and haven't been able to get past that yet. I will be posting that as a separate question.

Error "Multiple markers at this line - Syntax error on token " returned when using selenium.setSpeed()

When I included selenium.setSpeed("2000"); inside my void main i got the syntax error "selenium cannot be resolved"
When I placed it outside my void main and inside my class I got the error :
"Multiple markers at this line - Syntax error on token ",", < expected - Syntax error, insert "SimpleName" to complete QualifiedName - Syntax error on token ".", # expected after this token - Syntax error, insert ")" to complete MethodDeclaration - Syntax error, insert "Identifier (" to complete MethodHeaderName"
Please do help me resolve this issue.
The ancient versions of Selenium of-coarse had a method as setSpeed() but this method had been deprecated long back. setSpeed() was used to control the speed of each step of your Automation Script. As the purpose of Automated Testing is to reduce the Validation Time so setting the speed of each line of your script execution through setSpeed() was contradictory. Hence setSpeed() was deprecated.
Incase you want to wait for a certain condition you can use either Implicit Wait or Explicit Wait i.e. WebDriverWait Class in-conjunction with ExpectedConditions.
Scanner input will not work if you try to use it at the beginning of a class. It will show syntax errors like this.
(Multiple markers at this line
- Syntax error, insert ")" to complete MethodDeclaration)
The solution is: You have to use Scanner input within the main method().

apache PIG with datafu: Cannot resolve UDF's

I'm trying the quickstart from here: http://datafu.incubator.apache.org/docs/datafu/getting-started.html
I tried nearly everything, but I'm sure it must be my fault somewhere. I tried already:
exporting PIG_HOME, CLASSPATH, PIG_CLASSPATH
starting pig with -cpdatafu-pig-incubating-1.3.0.jar
registering datafu-pig-incubating-1.3.0.jar locally and in hdfs => both succesful (at least no error shown)
nothing helped
Trying this on pig:
register datafu-pig-incubating-1.3.0.jar
DEFINE Median datafu.pig.stats.StreamingMedian();
data = load '/user/hduser/numbers.txt' using PigStorage() as (val:int);
data2 = FOREACH (GROUP data ALL) GENERATE Median(data);
or directly
data2 = FOREACH (GROUP data ALL) GENERATE datafu.pig.stats.StreamingMedian(data);
I get this name-resolve error:
2016-06-04 17:22:22,734 [main] ERROR org.apache.pig.tools.grunt.Grunt
- ERROR 1070: Could not resolve datafu.pig.stats.StreamingMedian using imports: [, java.lang., org.apache.pig.builtin.,
org.apache.pig.impl.builtin.] Details at logfile:
/home/hadoop/pig_1465053680252.log
When I look into the datafu-pig-incubating-1.3.0.jar it looks OK, everything in place. I also tried some Bag functions, same error then.
I think it's kind of a noob-error which I just don't see (as I did not find particular answers for datafu in SO or google), so thanks in advance for shedding some light on this.
Pig script is proper, the only thing that could break is that while registering datafu there were some class dependencies that coudn't been met.
Try to run locally (pig -x local) and see a detailed log.
Check also the version of pig - it should be newer than 0.14.0.

Viewing a Compiler error output

I am new to Netbeans and I am given a simple exercise by my professor to find the compiler errors in a given program. This is a simple hello world program but all I get is
Compiling 1 source file to D:\UCC\CS6312-Mobile Devices and Systems\Lab\MyFirstMIDlet\build\compiled
D:\UCC\CS6312-Mobile Devices and Systems\Lab\MyFirstMIDlet\src\myfirstmidlet\MyFirstMIDlet.java:12: error: ';' expected
form.addCommand(exit)
1 error
D:\UCC\CS6312-Mobile Devices and Systems\Lab\MyFirstMIDlet\nbproject\build-impl.xml:359: Compile failed; **see the compiler error output for details.**
BUILD FAILED (total time: 0 seconds)
So I want to know where I can find the details of the compiler errors as I have to include those in my assignment. Thank you
The compile error is the first bit of the error message:
D:\UCC\CS6312-Mobile Devices and Systems\Lab\MyFirstMIDlet\src\myfirstmidlet\MyFirstMIDlet.java:12: error: ';' expected
form.addCommand(exit)
This could mean exactly what it says, and that you're missing a semicolon on this line, but doesn't necessarily - it might be something else that's wrong that's causing the compiler to produce that error. You may also run into the case where you fix that error then have to fix some others that come up afterwards - such is the nature of compilers!

Categories

Resources