Skip to main content

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
Filter by
Sorted by
Tagged with
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 ...
Joe's user avatar
  • 173
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 ...
FlatAssembler's user avatar
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 ...
John Greene's user avatar
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 ...
Jonas's user avatar
  • 501
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? ...
Silah's user avatar
  • 23
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 ...
warren's user avatar
  • 117
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 ...
FlatAssembler's user avatar
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 ...
Aster's user avatar
  • 3,308
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 ...
CPlus's user avatar
  • 9,143
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 ...
DannyNiu's user avatar
  • 287
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 ...
Hydroper's user avatar
  • 1,027
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 ...
defance's user avatar
  • 129
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 ...
Marisa Kirisame's user avatar