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.
13 questions from the last 365 days
7
votes
1
answer
864
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
218
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
635
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 ...
2
votes
1
answer
322
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
329
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
357
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 ...
14
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 ...
27
votes
7
answers
12k
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 ...
2
votes
3
answers
1k
views
How to support syntax like `a && b = c` for a conditional assignment expression?
I want the expression a && b = c in my language to mean that the value of c is assigned to ...
1
vote
1
answer
175
views
Does it make sense to track previous tokens literally in a parser generator? [closed]
As a beginner in parser generators, is it memory intensive or not to retain the set of parsed tokens in a collection? Or do actual parser generators refine what was previously parsed from a structure ...
2
votes
0
answers
170
views
Issue with rules for custom DSL
I am struggle with implementing rules for a custom DSL with significant spaces.
The key feature is that it requires spaces to be tracked and re-used. In most languages they are used to split tokens ...
26
votes
4
answers
3k
views
Why don't popular regex engines support complement and intersection?
While regex size blows up when defining a function that take two regexes, and return one regex representing their complement/intersection (see Succinctness of the Complement and Intersection of ...