Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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.?

Replies are listed 'Best First'.
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 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.


    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 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:
    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.
      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'
      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.
      Parsing information is a management attribute, that defines the ability to select the salient points from a large amount of submitted information. The ability enables the discovery of the needle in the haystack.
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.

    Fixed the link....

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?


      Kinda, now can you list what you can and cant do with parsed data? Or how to parse data?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://103172]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2017-05-22 15:46 GMT
Find Nodes?
    Voting Booth?