Parsing in a particular language?

  • Thread starter Thread starter vivek91m
  • Start date Start date
  • Tags Tags
    Language
Click For Summary
SUMMARY

The discussion focuses on parsing in programming languages, specifically using Octave as an example. It emphasizes the use of context-free grammars (CFGs), particularly Backus-Naur Form (BNF) and Extended Backus-Naur Form (EBNF), for parsing and tree construction. The conversation highlights that while standard algorithms exist for parsing, custom code can be developed for specific applications, such as XML parsing, where a compact code can create a tree structure representing markup contexts. For deeper understanding, the discussion recommends studying compiler design and language parsing techniques.

PREREQUISITES
  • Understanding of context-free grammars (CFGs)
  • Familiarity with Backus-Naur Form (BNF) and Extended Backus-Naur Form (EBNF)
  • Basic knowledge of XML structure and parsing
  • Awareness of compiler design principles
NEXT STEPS
  • Study context-free grammars in detail, focusing on BNF and EBNF
  • Learn about XML parsing techniques and tree structure generation
  • Explore compiler design principles and parsing algorithms
  • Investigate tools for grammar definition and parsing, such as ANTLR
USEFUL FOR

Software developers, particularly those working with language parsers, compiler developers, and anyone interested in understanding parsing techniques in programming languages.

vivek91m
Messages
8
Reaction score
0
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
 
Technology news on Phys.org
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.
 

Similar threads

  • · Replies 25 ·
Replies
25
Views
2K
Replies
42
Views
9K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
86
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
22
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K