Parsing in a particular language?

  • Thread starter Thread starter vivek91m
  • Start date Start date
  • Tags Tags
    Language
AI Thread Summary
Parsing in programming languages like Octave typically involves using context-free grammars (CFGs), which can be defined using Backus-Naur Form (BNF) or Extended Backus-Naur Form (EBNF). These grammars help in checking the structure of expressions and constructing parse trees. Tools exist that automate this process, allowing for the validation of syntax and the creation of structured representations of code. While a standard algorithmic approach is common, custom code can also be developed for specific parsing tasks, such as creating an XML parser that processes tags and attributes. The choice of parsing method ultimately depends on the application's requirements, and those interested in deeper understanding should explore resources on compilers and language parsing.
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top