What’s the difference between parse trees and abstract syntax trees (ASTs)?

This is based on the Expression Evaluator grammar by Terrence Parr. The grammar for this example: grammar Expr002; options { output=AST; ASTLabelType=CommonTree; // type of $stat.tree ref etc… } prog : ( stat )+ ; stat : expr NEWLINE -> expr | ID ‘=’ expr NEWLINE -> ^(‘=’ ID expr) | NEWLINE -> ; expr … Read more

What does the clang -cc1 option do?

The Clang compiler front-end has several additional Clang specific features which are not exposed through the GCC compatibility driver interface. The -cc1 argument indicates that the compiler front-end is to be used, and not the driver. The clang -cc1 functionality implements the core compiler functionality. So, simply speaking. If you do not give -cc1 then … Read more

Compiler vs Interpreter vs Transpiler

Compiler – compiles code to a lower level code. Example: “Developer code” -> “Machine code” PHP -> C Java -> bytecode Transpiler – compiles code to same level of code/abstraction. Example: “Developer code” -> “Another developer code or version” JavaScript ES2015+ -> JavaScript ES5 Interpreter – interprets code, not really in the same class/league/context with … Read more

Why is writing a compiler in a functional language easier? [closed]

Often times a compiler works a lot with trees. The source code is parsed into a syntax tree. That tree might then be transformed into another tree with type annotations to perform type checking. Now you might convert that tree into a tree only containing core language elements (converting syntactic sugar-like notations into an unsugared … Read more

How to approach creating a JVM programming language?

I would also recommend ASM, but have a look at Jasmin, I used it (or, rather, had to use it) for a university project, and it worked quite well. I wrote a lexer-parser-analyzer-optimizer-generator combination for a programing language using Java and Jasmin, so it was generating JVM Code. I uploaded the code here; the interesting … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)