Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ parsing error messages #1780

Open
smu-sc-gj opened this issue May 23, 2024 · 3 comments
Open

C++ parsing error messages #1780

smu-sc-gj opened this issue May 23, 2024 · 3 comments
Assignees
Labels
bug Issue/PR that involves a bug language PR / Issue deals (partly) with new and/or existing languages for JPlag minor Minor issue/feature/contribution/change

Comments

@smu-sc-gj
Copy link

Hi all,

A group of students suspected of working together produced code which compiles, but crashes 5.0 and causes errors on 2.12.1 (which I happened to still have on my machine).

The offending code:

 if (evt.keysym.sym == 'lmb')

The error on 5.0 is:

failed to parse 'projectName_XXXX/Name.cpp'Cannot invoke "de.jplag.cpp.grammar.CPP14Parser$PointerDeclaratorContext.noPointerDeclarator()" because the return value of "de.jplag.cpp.grammar.CPP14Parser$DeclaratorContext.pointerDeclaParsing Submissions    33% [========                 ] 1/3 (0:00:02 / 0:00:04)

The error on 2.12.1 is:

[projectName_XXXX]
  Scanning Error in 'src/Name.cpp':
  Lexical error at line 430, column 29.  Encountered: "m" (109), after : "\'l"

I used this error message to modify the line so it would parse and I now have reports from both. The error message from the older version is much easier to read and allows for exploration, the 5.0 error message less so.

I appreciate this needs further investigation with the latest version etc. I'll try to create a MWE for this when I have more time.

@tsaglam tsaglam added bug Issue/PR that involves a bug minor Minor issue/feature/contribution/change language PR / Issue deals (partly) with new and/or existing languages for JPlag labels May 23, 2024
@TwoOfTwelve TwoOfTwelve self-assigned this Jun 20, 2024
@TwoOfTwelve
Copy link
Contributor

I've tried to replicate the issue using the following code:

void main() {
    if (evt.keysym.sym == 'lmb') {
    }
}

JPlag was able to process this without any problem, so I guess it depends on the surrounding code.

Do you have the option of sending the entire file or can you create a short example that encounters the error?

@smu-sc-gj
Copy link
Author

smu-sc-gj commented Jul 4, 2024

While the original code is only a few files, there were some really big dependencies. The relevant one here being Ogre (the evt.keysym.sym comes from OgreBites. I've managed to re-create the issue with the following code:

#include <iostream>
#include <stdlib.h>

typedef int Keycode;

struct Keysym {
    Keycode sym;
    unsigned short mod;
};

struct KeyboardEvent {
    int type;
    Keysym keysym;
    unsigned char repeat;
};

bool keyProcessing(const KeyboardEvent& evt)
{
    std::cout << "Processing Key" << std::endl;

    if(evt.keysym.sym == 'w')
    {
        std::cout << "W" << std::endl;
    }
    
    /* I know this doesn't make sense ... but it's 
       what they original code was trying to do. */
       
    if(evt.keysym.sym == 'lmb')
    {
        std::cout << "Left Mouse Button" << std::endl;
    }
  
    return true;
}

int main(int argc, char** argv) 
{
  KeyboardEvent test;
  test.keysym.sym = 'w';
  
  keyProcessing(test);

  exit(EXIT_SUCCESS);
}

I created three copies of this file as a sample.

  • Latest version (5.1.0) language set to cpp, I have a note that says this only works if the code is C++14 compatible throughout, the samples are but I'm not sure the student submission are.
java -jar ~/Applications/JPlag/jplag-5.1.0-jar-with-dependencies.jar -l cpp .
Loading Submissions   100% [=========================] 3/3 (0:00:00 / 0:00:00) 
Parsing Submissions   100% [=========================] 3/3 (0:00:00 / 0:00:00) 
Comparing Submissions 100% [=========================] 3/3 (0:00:00 / 0:00:00) 
2024-07-04-10:04:23_440 [INFO] JPlag - Total time for comparing submissions: 0h 00min 00s 024ms
2024-07-04-10:04:23_442 [INFO] ClusteringFactory - Calculating clusters via spectral clustering with cumulative distribution function pre-processing...
Finding clusters  < <+>                            > 0:00:00
2024-07-04-10:04:24_006 [INFO] ReportObjectFactory - Start writing report...
2024-07-04-10:04:24_007 [INFO] ReportObjectFactory - Start to export results...
2024-07-04-10:04:24_100 [INFO] ReportObjectFactory - Total Comparisons: 3. Comparisons in Report: 3. Omitted Comparisons: 0.
2024-07-04-10:04:24_153 [INFO] OutputFileGenerator - Successfully written the result: results.zip
2024-07-04-10:04:24_154 [INFO] OutputFileGenerator - View the result using --mode or at: https://jplag.github.io/JPlag/
  • Latest version (5.1.0) with language set to c:
java -jar ~/Applications/JPlag/jplag-5.1.0-jar-with-dependencies.jar -l c .
Loading Submissions   100% [=========================] 4/4 (0:00:00 / 0:00:00) 
Parsing Submissions     0% [                               ] 0/4 (0:00:00 / ?) 
2024-07-04-10:04:53_285 [WARN] Submission - Failed to parse submission three.cpp:
failed to parse 'three.cpp'Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"
2024-07-04-10:04:53_287 [WARN] Submission - Failed to parse submission two.cpp:
failed to parse 'two.cpp'Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"
2024-07-04-10:04:53_288 [WARN] Submission - Failed to parse submission one.cpp:
failed to parse 'one.cpp'Lexical error at line 29, column 28.  Encountered: "m" Parsing Submissions   100% [=========================] 4/4 (0:00:00 / 0:00:00) 
2024-07-04-10:04:53_296 [INFO] Submission - Summary of all errors:
2024-07-04-10:04:53_271 [ERROR] Submission - ERROR: nothing to parse for submission "results.zip"
2024-07-04-10:04:53_310 [INFO] SubmissionSetBuilder - Summary of all errors:
2024-07-04-10:04:53_227 [ERROR] SubmissionSetBuilder - Ignore submission with invalid suffix: results.zip
2024-07-04-10:04:53_310 [INFO] Scanner - Summary of all errors:
2024-07-04-10:04:53_285 [ERROR] Scanner - Scanning Error in 'three.cpp': Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"
2024-07-04-10:04:53_287 [ERROR] Scanner - Scanning Error in 'two.cpp': Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"
2024-07-04-10:04:53_288 [ERROR] Scanner - Scanning Error in 'one.cpp': Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"
2024-07-04-10:04:53_310 [INFO] CLI - Summary of all errors:
2024-07-04-10:04:53_296 [ERROR] CLI - Not enough valid submissions! (found 0 valid submissions)
2024-07-04-10:04:53_310 [INFO] SubmissionSet - Summary of all errors:
2024-07-04-10:04:53_271 [ERROR] SubmissionSet - ERROR -> Submission results.zip removed
2024-07-04-10:04:53_286 [ERROR] SubmissionSet - ERROR -> Submission three.cpp removed
2024-07-04-10:04:53_287 [ERROR] SubmissionSet - ERROR -> Submission two.cpp removed
2024-07-04-10:04:53_288 [ERROR] SubmissionSet - ERROR -> Submission one.cpp removed
  • Legacy version (2.12.1) with language set to c/c++
java -jar ~/Applications/JPlag/jplag-2.12.1-SNAPSHOT-jar-with-dependencies.jar -l c/c++ .
Language accepted: C/C++ Scanner [basic markup]
Command line: -l c/c++ . 
initialize ok
3 submissions
  Scanning Error in 'one.cpp':
  Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"
  Scanning Error in 'three.cpp':
  Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"
  Scanning Error in 'two.cpp':
  Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"

0 submissions parsed successfully!
3 parser errors!


Error: Not enough valid submissions! (only 0 are valid):
[one.cpp]
  Scanning Error in 'one.cpp':
  Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"

[three.cpp]
  Scanning Error in 'three.cpp':
  Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"

[two.cpp]
  Scanning Error in 'two.cpp':
  Lexical error at line 29, column 28.  Encountered: "m" (109), after : "\'l"

I hope this helps!

@tsaglam
Copy link
Member

tsaglam commented Jul 4, 2024

* Latest version (5.1.0) language set to `cpp`, I have a note that says this only works if the code is C++14 compatible throughout, the samples are but I'm not sure the student submission are.

Seems to work with the cpp language module.

* Latest version (5.1.0) with language set to `c`:

This language module is the former c/c++ module from the JPlag legacy version. We still provide it with JPlag, however we are not actively working on it. If anyone wants to provide a fix here, feel free to create a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue/PR that involves a bug language PR / Issue deals (partly) with new and/or existing languages for JPlag minor Minor issue/feature/contribution/change
Projects
None yet
Development

No branches or pull requests

3 participants