Parsing in a particular language?

  • Thread starter vivek91m
  • Start date
  • #1
8
0

Main Question or Discussion Point

Hello everyone,
I would like to ask how exactly Parsing is done in a particular language? Let's say Octave for an example. And if there is parsing error from where it is called?

Thank you in advance.

Regards,
Vivek
 

Answers and Replies

  • #2
chiro
Science Advisor
4,790
132
Hey vivek91m and welcome to the forums.

The standard way of parsing something is by using context-free grammars. BNF and EBNF are good examples of what constitutes these CFG's for parsing and tree construction purposes:

http://en.wikipedia.org/wiki/Backus–Naur_Form

http://en.wikipedia.org/wiki/Extended_Backus–Naur_Form

There are tools that take a grammar definition and not only check that expressions are in the form of the grammar, but they also build trees that structure the terms.

This is the structured algorithmic approach of handling this, but you can use custom code that deals with specific structures to handle specific kinds of applications and definitions.

For example if you want to say implement an XML parser, you can write some code that is very compact that will parse the contents of a tag and the tag itself (with the tag attribute) and then generate a simple tree structure to represent the entire state of the markup context.

You can then overload say each tag type to have a callback function that has access to the tag tree and the data and it can do what it needs to do.

In short though it depends on the application and it's needs and there is no one thing that is used, but certainly if you want to understand how computer scientists deal with the problem get a book on compilers and and language parsing.
 

Related Threads on Parsing in a particular language?

Replies
3
Views
2K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
5
Views
2K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
18
Views
5K
Replies
11
Views
1K
Replies
10
Views
1K
Replies
7
Views
3K
  • Last Post
Replies
13
Views
1K
Top