Results 1 to 3 of 3
  1. #1
    Adomini is offline Member
    Join Date
    Aug 2010
    Posts
    70
    Rep Power
    0

    Default <RESOLVED>Passing a Statement Object into a Program Object

    The main issue is that I am having a reference to a non-static type, but Statement must be static.

    Can I ensure that the syntax is at least right? This comes from a parser program. Error marked below in the code

    Java Code:
    public <Program> Program Parser (String fileName) throws FileNotFoundException, LexException
    	{
    		if (fileName == null)
    			throw new IllegalArgumentException ("null string argument");
    		lex = new LexicalAnalyzer2(fileName);
    		
    		 L = StatementList.getStatement();  //  ***this is the error ****
    		Program prog = (L);
    		
    		return prog;
    	}
    StatementList class is shown below:

    Java Code:
    public class StatementList 
    {
     
    	
    /**
     * This method takes the Statement List and returns the getStatement method.
     */
    public StatementList ()
    {
    	getStatement();
    }
    
    // This method will use the Statement class with this project and privatize it and return it. 
    // The Statement class will then use the line number, basic statement, and EOLN token.
     public static void getStatement() 
    {
    	//this.Statement = Statement;
    	
    	while (Parser.lex.moreTokens())
    	{
    		Parser.lex.getNextToken();
    	}
    	 System.out.println("no more tokens");
    	
    	
    }
    
    
    }
    Thoughts?
    Last edited by Adomini; 02-23-2013 at 03:58 PM.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    724
    Rep Power
    2

    Default Re: Passing a Statement Object into a Program Object

    L = StatementList.getStatement() assumes the method returns something but the method is void: public static void getStatement(). This does not return anything.

  3. #3
    Adomini is offline Member
    Join Date
    Aug 2010
    Posts
    70
    Rep Power
    0

    Default Re: Passing a Statement Object into a Program Object

    You are correct. Thank you!

Similar Threads

  1. Object-Parameter passing costs
    By NewEonOrchestra in forum New To Java
    Replies: 1
    Last Post: 05-16-2012, 05:23 PM
  2. java-object passing by value
    By aumkar0406 in forum New To Java
    Replies: 15
    Last Post: 01-04-2012, 02:08 AM
  3. passing an object from one JDialog to Jframe
    By sinha in forum AWT / Swing
    Replies: 7
    Last Post: 12-16-2009, 04:56 PM
  4. Passing SWT object to another class
    By Vinaya Lal Shrestha in forum SWT / JFace
    Replies: 0
    Last Post: 04-03-2009, 01:50 PM
  5. passing object as value for checkbox values??
    By Pooja Deshpande in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-17-2009, 11:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •