Questions tagged [parsing]

Parsing is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar.

Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term parsing comes from Latin pars (orationis), meaning part (of speech).

The term has slightly different meanings in different branches of linguistics and computer science. Traditional sentence parsing is often performed as a method of understanding the exact meaning of a sentence or word, sometimes with the aid of devices such as sentence diagrams. It usually emphasizes the importance of grammatical divisions such as subject and predicate.

Within computational linguistics the term is used to refer to the formal analysis by a computer of a sentence or other string of words into its constituents, resulting in a parse tree showing their syntactic relation to each other, which may also contain semantic and other information. Some parsing algorithms may generate a parse forest or list of parse trees for a syntactically ambiguous input.

Within computer science, the term is used in the analysis of computer languages, referring to the syntactic analysis of the input code into its component parts in order to facilitate the writing of compilers and interpreters. The term may also be used to describe a split or separation.

30 questions
8
votes
3 answers

Parsing absolute value signs: Does $|x|x|x| =|x|\cdot x \cdot |x|$ or $ {\large|} x\cdot |x| \cdot x{ \large |}$?

I am writing an equation parser for fun and I kinda thought parsing absolute value signs would be like parsing ordinary bracktets - but this is not so as there is no 'open' or 'close' version of $|$. In particular there are two potential…
Slugger
  • 5,736
  • 1
  • 29
  • 58
7
votes
1 answer

Is First Order Logic Syntax Context Free?

If I were to build a first order logic parser could I do it using a context free parser generator (like bison)? I found some articles where First Order Logic Syntax is described with EBNF notation, usually like this: :=
4
votes
0 answers

Can first-order logic be recognized by a pushdown automaton?

I have the belief that first-order logic cannot be recognized by a pushdown automaton because the automaton will have no way to keep track of the variables that are currently in scope. More precisely, I have the belief that the language of…
4
votes
0 answers

How to read an expression that is ambiguous?

(1) How should I parenthesize $\log n \log \log n$? Also: (2) What general rule/rationale is used to do this parenthesization? To elaborate; I see why $\log\log n$ is unambiguous, but $\log n \log ...$ could mean at least 2 different…
mormegil
  • 141
3
votes
1 answer

Eliminating Epsilon Production for Left Recursion Elimination

Im following the algorithm for left recursion elimination from a grammar.It says remove the epsilon production if there is any I have the following grammer S-->Aa/b A-->Ac/Sd/∈ I can see after removing the epsilon productions the grammer becomes …
3
votes
1 answer

How to prove CYK algorithm has $O(n^3)$ running time

I have a final coming up in few days, and the professor mentioned the CYK algorithm. I want to be prepared for the final. I'm trying to find out how to prove the algorithm has worst case running time of $n^3$. Thanks
2
votes
0 answers

What is the notation for a sub-expression?

For set theory, we have notation to denote subsets, e.g.: $$S \subset X$$ When working with expressions (arithmetic, Boolean, etc.), is there a notation to denote expression $S$ is a valid sub-expression of $X$? For instance, if we have $X := 5…
bbarker
  • 123
2
votes
3 answers

Parenthesize expressions.

Can someone tell me how to add parenthesis to this expression $a + b \cdot c \cdot d + e$. where $a,b,c,d,e$ are algebraic variables, where addition and multiplication is as usual there. :-) If you have any other complicated examples please…
qwertynik
  • 23
  • 5
2
votes
2 answers

Interpreting "pairwise"

I have the following exercise. Can four lines in space (not necessarily passing through the same point) be pairwise perpendicular? Does it mean (given 4 lines $a$, $b$, $c$, and $d$): $a\perp b$; $b\perp c$; $c\perp d$; and $d\perp…
2
votes
0 answers

Relationships between $\operatorname{LL}(k)$, $\operatorname{LR}(k)$ language sets

I'm trying to establish (through constructing a Hasse diagram) the subset relationship between the classes of languages that can be parsed by $\operatorname{LL}(k)$ and $\operatorname{LR}(k)$ parsers. My guess is that $$\operatorname{LL}(0) \subset…
lynn
  • 3,418
1
vote
1 answer

Direct reduction of unit resolution to context-free grammar membership?

This compendium of P-complete problems asserts that unit resolution (section A.6.1 in the book) and context-free grammar parsing (A.7.1) are P-Complete. But it does not provide a direct reduction. What does the direct reduction from unit resolution…
1
vote
1 answer

Parsing this wff efficiently

I have the wff: $$\alpha = (((\neg(A_1\rightarrow (A_3\vee (\neg A_2))))\wedge(A_4\wedge(\neg A_1)))\rightarrow((\neg(A_3\vee A_2))\rightarrow(((\neg A_1)\wedge A_4)\vee A_3)))$$ I've already parsed through $12$ of the $16$ possibilities in the…
1
vote
0 answers

Ambiguity in order of operations

I am working on a toy parser for arithmetic expressions and I am having trouble getting it to parse something like 2^-2. The reason for this is because my production rules look like: Expression -> Expression ("+" | "-") Multiply | Multiply ... leave…
Chris_F
  • 175
1
vote
1 answer

Is there really a proof that all context-free grammars can be parsed using a LL(1) grammar without backtracking?

I was watching a youtube video on a parsing library that I have an interest in that you can find here: https://www.youtube.com/watch?v=wreCg30pyts&t=1272s. What is interesting though is that at 30:57 someone new comes on and references an…
1
vote
1 answer

An explicit algorithm to test whether a string of symbols is or is not well-formed in this language.

Consider the set of five symbols, $\{ (, ), p, ', *\}$. A variable is defined as $p$ followed by zero or more $'$s. A wff is inductively defined as follows: $1$. Every variable is a wff. $2$. If $x$ and $y$ are formulas, so is $(x*y)$. $3$. Nothing…
user107952
  • 23,768
1
2