Tag Info

1

This seems impossible if the translator has to be deterministic. Let's clean up the problem and ask the PDA to convert $a^{n+m} b^n$ to $x^m y^n$ (your translator can be converted to such a translator by using a regular transducer). Since your PDA is deterministic, it cannot output anything until it knows whether $m = 0$ or not, which can happen in one of ...

3

It is impossible for one language to be faster than another language, period. A programming language is a set of abstract mathematical rules and restrictions. It is an idea. A piece of paper. You cannot run a language, therefore, you cannot measure its performance. What you can do is run a particular piece of code written in one language using a particular ...

2

Every tree is itself a graph, so of course an AST is a graph -- no mapping is needed, it is already a graph. I don't see any way that this is useful in practice, though. Rather than trying to convert to a graph and then use graph neural networks, I suggest using a more direct approach: e.g., using a neural network on the AST or on the code itself. Since ...

3

Fundamentally, there are only the two: compilation and interpretation. tl;dr: An interpreter runs the program, a compiler translates the program to another language. An interpreter for language X is a program (or a machine, or just some kind of mechanism in general) that executes any program p written in language X such that it performs the effects and ...

1

The difference between NFAs and DFAs is not so huge, because you can trivially convert an NFA into a DFA simply by using the elements of the power set of the states of the NFA as the states of a DFA. Usually, not all the elements of the power set turn out to be accessible, so the DFA is not as huge as this transformation makes it sound. But there are some ...

1

Any piece of code can never be non-deterministic (a non-deterministic process can "multiply itself" by a constant factor every step, and obviously computers can't just multiply by their own free will). Hence it is a DFA. Also, your lexer will start always at the initial state $s_0$, and from it, depending on what it reads - it moves to different ...

7

StatementExpression is described in the same specification document as Expression Statements. I would like to quote this passage specifically: Certain kinds of expressions may be used as statements by following them with semicolons. ExpressionStatement: StatementExpression ; StatementExpression: Assignment PreIncrementExpression ...

6

Edit: previously incorrect. Chapter 18 does not have the correct definition of StatementExpression. The correct definition can be found in 14.8. StatementExpression is a subset of the expression grammar. Justification for statement expression: In java, the statement 1 + 1; is invalid grammatically (unlike most other languages).

1

Are you aiming to simply allow recursive functions or specify only recursive functions. The following grammar allows recursive functions: function := id '(' parameter ')' '=' function_body ; function_body := conditional | expression ; expression := function_call | <other expression types> ...

Top 50 recent answers are included