Results 1 to 3 of 3

Thread: Lexical analysis using stack implementation

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    228

    Lexical analysis using stack implementation

    My goal is to scan a file and check whether the given file is well-formed or not.

    for example

    Code:
    <test>
    <yeah>
    <yahoo> bla blabla </yahoo>
    </yeah>
    what ever <s> it is </s>
    <br/> test
    </test>

    i have parsed every single tag into the stack now I'm at the point where I have to check whether all the tag is paired except the tag without closing like <br/>

    now my stack look like the following
    [8] = </test>
    [7] = <br/>
    [6] = </s>
    [5] = <s>
    [4] = </yeah>
    [3] = </yahoo>
    [2] = <yahoo>
    [1] = <yeah>
    [0] = <test>
    .......
    and so on.

    Can you guys help me good algorithm to check whether or not all the tag is paired.
    I'm not expecting the code to make this happen and I'm sure you won't give that to me, I just need good algorithm or steps that can make this happen. Been thinking for quite sometime but I cant figure the easy way to do this.

    Thank you in advance
    Last edited by ayahnabunda; Sep 17th, 2008 at 06:54 AM.
    effort effort effort and still effort

Posting Permissions

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



Click Here to Expand Forum to Full Width