Results 1 to 8 of 8
  1. #1
    PROPA is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Printing Problem

    why isnt this printing anything? I am building a lexical analyzer & need a character lookahead so that i can determine what to do with the characters before.

    Java Code:
    public void readArrange(String file)throws Exception{
           
            fr = new FileReader(file);
           
            int ch;
    
            while((ch = fr.read()) != -1){
               
                char[] c = Character.toChars(ch);
                int i;
                int j;
               
                for(i = 0;i<c.length-1;i++){
                    for(j = i+1; j< c.length;j++){
                        if(Character.isLetter(c[i]) && Character.isLetter(c[j]) || Character.isDigit(c[j])){
                            Character.toChars(Character.toLowerCase(ch));
                            System.out.print("yes");
                           
                            //code.valueOf(c);
                       
                        }
                        else if(Character.isWhitespace(c[i]) && c[i] == ','){ //|| Character.isWhitespace(c[j]) && c[j] == ','){
                            c[i] = '/';
                            c[j] = '/';
                            //code.valueOf(c);
                        }
                        else{
                            System.out.print(Character.toChars(Character.toLowerCase(ch)));
                            //code.valueOf(c);
                        }
                    }  
                }
            }
        }
    Last edited by Eranga; 11-03-2011 at 08:36 AM. Reason: code tags added

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default Re: Printing Problem

    Please use code tags when you are posting code segments next time. Unformated codes are really hard to read.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  4. #4
    PROPA is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Re: Printing Problem

    Quote Originally Posted by Eranga View Post
    Can you show your input string?

    "\\Users\\comet\\Desktop\\testfile.txt"

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default Re: Printing Problem

    No, the input sense the content of that file mate. I don't have that file with me, so how can I evaluate the code without such pattern. Show some part of the file content. :)

  6. #6
    PROPA is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Re: Printing Problem

    sorry, my fault

    {
    define a = 0999;
    integer integera=-12345,vara,b2b,const1, two2, three3;
    a+b-c*d/e=end * ** * ;
    abc+123def()
    ==
    print(print1)}

    its a fake language, this is what im wrting the compiler for.
    Last edited by PROPA; 11-03-2011 at 09:50 AM.

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,734
    Blog Entries
    7
    Rep Power
    21

    Default Re: Printing Problem

    Quote Originally Posted by PROPA View Post
    why isnt this printing anything? I am building a lexical analyzer & need a character lookahead so that i can determine what to do with the characters before.

    Java Code:
    public void readArrange(String file)throws Exception{
           
            fr = new FileReader(file);
           
            int ch;
    
            while((ch = fr.read()) != -1){
               
                char[] c = Character.toChars(ch);
                int i;
                int j;
               
                for(i = 0;i<c.length-1;i++){
                   [ ... ]
    If the codepoint 'ch' is in the set BMP (read the Character class API documentation), char array 'c' contains just one element; your for loop won't run ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    PROPA is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

Similar Threads

  1. Problem in printing
    By justbeller in forum Java 2D
    Replies: 0
    Last Post: 04-26-2011, 03:48 PM
  2. Printing problem
    By justlynn in forum NetBeans
    Replies: 5
    Last Post: 08-03-2010, 03:41 PM
  3. Printing only one page problem
    By AndreiDMS in forum Java 2D
    Replies: 0
    Last Post: 10-09-2009, 04:03 AM
  4. Problem after Printing GUI.
    By coldblood22 in forum AWT / Swing
    Replies: 1
    Last Post: 04-05-2008, 03:43 PM
  5. printing problem
    By ntpl in forum AWT / Swing
    Replies: 0
    Last Post: 11-27-2007, 12:20 PM

Posting Permissions

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