Questions tagged [parsing]
For questions related to the parsing stage of code compilation or interpretation. Parsing is the process of converting text-based code into the constituent logic.
65 questions
11
votes
4
answers
6k
views
Why does the do-while loop in C-like languages require the curly brackets `{` and `}`? Wouldn't the grammar be perfectly parsable without them?
So, nearly all (or perhaps all) C-like languages require us to use curly brackets { and } when writing a do-while loop of more ...
0
votes
0
answers
111
views
Object type definition from JSON - CFG design
In a "managed memory" language that I'm designing, I'm constructing grammar for the description of arbitrary object type that can simultaneously be used for initialization of objects with ...
3
votes
1
answer
255
views
Alternatives to ANTLR 3 for LL(1) Grammar verification
I'm developing an expression language using a LL(1) recursive descent parser. Technically it's actually LL(2) since I need an extra lookahead in one place. I'm using ANTLR 3 (ANTLRWorks) to verify ...
7
votes
2
answers
356
views
Why can't a parser for C++ be realized with a DPDA?
In the book of Wilhelm, Seidl and Hack, " Compiler Design, Syntactic and Semantic Analysis" they write on p. 10 (bold face emphasis is mine)
Most designers of programming languages have ...
12
votes
4
answers
5k
views
Why not make all keywords soft in python?
In Python we have the concept of a soft keyword, which makes some keywords reserved only in some special cases (e.g. match, case ...
2
votes
2
answers
140
views
DCFG without using state table
I'd like to confirm whether a sketch of procedure over a DCFG (deterministic context-free grammar) can maintaining full functional equivalence over building a full states transition table and loop ...
8
votes
1
answer
1k
views
How are CFG and BNF different?
I've been learning about formal languages and grammars, and I came across two terms while studying my textbook:
Context-Free Grammar (CFG) and Backus-Naur Form (BNF). They both seem to be related to ...
8
votes
1
answer
2k
views
Why is the "scan backwards" method of parsing right-associative operators considered to be anti-pattern? What alternatives are recommended?
My previous question was about how the tokenizers for programming languages which support both the ternary conditional operator ?: and labels (with the syntax ...
3
votes
1
answer
255
views
What do you call the act of rebalance an parse tree so simplistic regex are closest to the root node over variables/identifiers?
What is this step called to convert a parse tree into a pattern tree?
I need to understand terminologies on the act of conversion/rebalancing the parse tree such that the most simplistic regular ...
11
votes
1
answer
874
views
What are good reasons for using a more complex grammar than LL(1)?
Programming languages can come quite far with an easy grammar like LL(1), and parsers both in the compiler and tooling can be constructed with hand-written Predictive Parsers (or be generated).
When ...
3
votes
1
answer
395
views
How is a python namespace implemented in terms of memory under Cpython implementation? [closed]
I am confused about the implementation of a global namespace in python .
How are variable names mapped as keys to the objects they reference as values ,since namespace is implemented as a dictionary? ...
0
votes
1
answer
389
views
From a parsing perspective, which is more efficient? Right-to-left or left-to-right argument parsing?
C (and other languages which allow variable argument lists) process function arguments from right-to-left.
Pascal (and other languages with fixed-length argument lists) process function arguments from ...
2
votes
1
answer
759
views
How is the VHDL operator `<=`, which can be both right-associative (signal assignment) and left-associative (less-than-or-equal), parsed?
One of the most confusing things to me about VHDL is that the <= operator can mean both "less than or equal to" and it can be a signal assignment ...
16
votes
4
answers
2k
views
Why do we need to divide lexing and parsing stages
Why do many typical parsers need to have two stages: tokenization and parsing?
This isn't just a helping hand for manually-constructed parsers, as even generation tools do the same. For example, the ...
28
votes
7
answers
13k
views
Why do compilers typically convert code into abstract syntax/parse trees before the final product?
When I started researching parsing and compiling I started with simple mathematical expression parsers. Many of the existing implementations I found have an intermediate step of converting a string ...