Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

What does the word "parse" mean?

by Anonymous Monk
on Aug 08, 2001 at 23:02 UTC ( #103172=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

when someone uses the term parse what does that mean in simple terms or what is usually thought of when someone says they are parsing a file, string or whatever.?

Comment on What does the word "parse" mean?
Re: Parse
by Cubes (Pilgrim) on Aug 08, 2001 at 23:17 UTC
    Parsing used to be done on sentences by schoolchildren (do they still have to draw those diagrams on the chalkboard?), to show that they understood which words were nouns, verbs, and so on, and what part each word played in the sentence. Used in programming, it means much the same thing.

    From dictionary.com:

    4. Computer Science. To analyze or separate (input, for example) into more easily processed components.

    So if you're talking about parsing an HTML file, you'd probably be picking the file apart and somehow identifying which pieces are what HTML tags, which pieces are normal text, etc.

Re: Parse
by scain (Curate) on Aug 08, 2001 at 23:18 UTC
    Roughly, it means taking a bunch of text apart, looking for the pieces your are interested in and doing something with them.

    Is that general enough?

    Scott

      Kinda, now can you list what you can and cant do with parsed data? Or how to parse data?
Re: Parse
by VSarkiss (Monsignor) on Aug 08, 2001 at 23:20 UTC

    You could look it up in a dictionary....

    Basically, it means to take something apart into components, analyzing their relationship.

    Update
    Fixed the link....

Re: Parse
by grinder (Bishop) on Aug 08, 2001 at 23:25 UTC
    Parsing means determining the syntactic structure of an expression, that is written according to the rules of a certain grammar. Suppose you are writing a calculator. You are fed a string like 17*(6+3/7)+sqrt(90+20/2). In order to evaluate that expression (and I don't mean just feeding it to eval), you have to parse it according to the rules of the grammar, which might be the BODMAS rule (brackets of division, multiplication, addition & subtraction).

    To parse that expression, you have to break it down into tokens (17, *, (, 6, +...) and verify that it adheres to the rules. Having done that, you can then start to process the data.

    You usually parse something that can be very free-form in nature. For instance, you don't really parse the format of Unix's /etc/passwd password file, because it has a very rigid definition. Fields are delimited by colons, and each field has a precise defined purpose. You do, on the other hand, have to parse an SQL statement.

    --
    g r i n d e r
Re: Parse
by tshabet (Beadle) on Aug 08, 2001 at 23:53 UTC
    These guys are absolutely right. To take the example further, lets say you have this math expression:
    Z=(A-(C*K))
    when you parse this, it becomes
                                  =
                               /      \
                             -         Z
                           /   \
                         A      *
                               / \
                              C   K   
    
    So parsing something really is about breaking it down into its individual chunks and pieces. For instance, a parser might break your c++ program into functions, or your word into letters. If you have a whole made of parts, the parser looks at those parts. Make sense? Check out the definitions linked above, they're probably better at explaining it than I am. Hope that helped a little. PS The above is a "parse tree", certainly not the only way to parse or represent a parse. Just so you know.
      analysing or separating the text in to processed components known as parsing in computer science field and in general it means that elaborating the given text in to understandable format.
      Alternate parse representation of  $Z=($A-($C*$K)) care of ppi_dumper :) notice how it labels each part :)
      PPI::Document PPI::Statement PPI::Token::Symbol '$Z' PPI::Token::Operator '=' PPI::Structure::List ( ... ) PPI::Statement::Expression PPI::Token::Symbol '$A' PPI::Token::Operator '-' PPI::Structure::List ( ... ) PPI::Statement::Expression PPI::Token::Symbol '$C' PPI::Token::Operator '*' PPI::Token::Symbol '$K'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://103172]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2014-09-24 03:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (244 votes), past polls