Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Parsing methods

  • 07-11-2017 12:46pm
    #1
    Closed Accounts Posts: 1,758 ✭✭✭


    I'm reading through a code base and it has a parsing class with many various boolean methods like so...
    final private boolean jj_2_10(int xla) {
    		jj_la = xla;
    		jj_lastpos = jj_scanpos = token;
    		try {
    			return !jj_3_10();
    		} catch (LookaheadSuccess ls) {
    			return true;
    		} finally {
    			jj_save(9, xla);
    		}
    	}
    
    	final private boolean jj_3_7() {
    		if (jj_scan_token(PARAMSTART))
    			return true;
    		if (jj_scan_token(WORD))
    			return true;
    		return false;
    	}
    
    	final private boolean jj_3_5() {
    		if (jj_scan_token(WORD))
    			return true;
    		return false;
    	}
    
    	final private boolean jj_3_4() {
    		if (jj_scan_token(WORD))
    			return true;
    		Token xsp;
    		if (jj_3_3())
    			return true;
    		while (true) {
    			xsp = jj_scanpos;
    			if (jj_3_3()) {
    				jj_scanpos = xsp;
    				break;
    			}
    		}
    		return false;
    	}
    
    	final private boolean jj_3_6() {
    		if (jj_scan_token(PARAMSTART))
    			return true;
    		if (jj_scan_token(WORD))
    			return true;
    		if (jj_scan_token(WORD))
    			return true;
    		return false;
    	}
    

    Can anyone give me an idea what's happening here? The method names appear to have some meaning but google doesn't really help me figure out what.


Comments

  • Registered Users, Registered Users 2 Posts: 768 ✭✭✭14ned


    Pelvis wrote: »
    Can anyone give me an idea what's happening here? The method names appear to have some meaning but google doesn't really help me figure out what.

    It looks to be output from a compiler compiler such as yacc, "yet another compiler compiler"

    (or whatever equivalent php uses)

    Niall


  • Registered Users, Registered Users 2 Posts: 6,286 ✭✭✭Talisman


    The "jj_" prefixes are a dead giveaway that it's code that was originally generated for a Java project. The parser was originally created using the Java Compiler Compiler toolkit, JavaCC.

    It's been a while since I've seen the code but I think you may have an attempted port to PHP of the query parser from the Apache Solr project.


  • Closed Accounts Posts: 1,758 ✭✭✭Pelvis


    Sorry guys, it is actually a java project! Used the wrong tags in my post, oops!


  • Registered Users, Registered Users 2 Posts: 6,286 ✭✭✭Talisman


    Check for a .jj file in the project, it will contain the parsing information. The javacc tool transforms the contents of a .jj grammar file into the Java code for the parser classes.

    Description of the JavaCC Grammar File


  • Closed Accounts Posts: 1,758 ✭✭✭Pelvis


    That's great, thanks. Now I don't feel so bad for not having a clue what's going on in the auto generated files.


  • Advertisement
Advertisement