compiler-construction

What are the tools for semantic analysis phase of compiler construction?

喜欢而已 提交于 2020-02-27 09:21:49
问题 Compiler construction can be divided into several phases such as Lexical analysis, Syntax analysis, Semantic analysis and etc. In lexical analysis, there are tools such as Lex, Flex and etc. In syntax analysis, there are tools such as Yacc, Bison, etc. I'm just curious what are the tools available for semantic analysis phase? 回答1: To the best of my knowledge there are no language-agnostic tools to perform type checking and if there were, they'd certainly not be generally applicable as many

Is eclipse's ecj compiler extensible?

筅森魡賤 提交于 2020-02-25 06:32:16
问题 I am interested in modifying java syntax and some implicit paradigms. Since I develop with eclipse which provides it's own compiler, which can also be used standalone, I was wondering if it wasn't possible to extend ecj to respect additional grammar rules (and correctly handle them). My syntactical changes are all resolvable by removing elements from the AST and creating some new ones, so I assume that what I want to do is possible without diving into bytecode. Essentially, what I want to do

Finding an efficient shift/add/LEA instruction sequence to multiply by a given constant (avoiding MUL/IMUL)

假装没事ソ 提交于 2020-02-24 09:59:45
问题 I'm trying to write a C program mult.c that has a main function that receives 1 int argument (parsed with atoi(argv[1]) ), that is some constant k we want to multiply by. This program will generate an assembly file mult.s that implements int mult(int x) { return x * k; } for that constant k . (This is a followup to Efficient Assembly multiplication) For example: if main() in mult.c gets 14 as argument it may generate (though it is not minimal as later emphasized): .section .text .globl mult

Java compiler automatically renaming parameters (obfuscating)

纵然是瞬间 提交于 2020-02-23 11:30:31
问题 When I compile the code I am writing, then look at in a a JD Gui, methods show up with headers such as the following: public void growSurface(Random paramRandom, int paramInt1, int paramInt2){ I am compiling through a .bat file. Is there a way to specify that I don't want to obfuscate the code. 回答1: By default javac is not including debug information in generated class files. This information is e.g. method parameter names (but method and field names are always stored to allow reflection).

Java compiler automatically renaming parameters (obfuscating)

Deadly 提交于 2020-02-23 11:29:30
问题 When I compile the code I am writing, then look at in a a JD Gui, methods show up with headers such as the following: public void growSurface(Random paramRandom, int paramInt1, int paramInt2){ I am compiling through a .bat file. Is there a way to specify that I don't want to obfuscate the code. 回答1: By default javac is not including debug information in generated class files. This information is e.g. method parameter names (but method and field names are always stored to allow reflection).

Java compiler automatically renaming parameters (obfuscating)

淺唱寂寞╮ 提交于 2020-02-23 11:29:10
问题 When I compile the code I am writing, then look at in a a JD Gui, methods show up with headers such as the following: public void growSurface(Random paramRandom, int paramInt1, int paramInt2){ I am compiling through a .bat file. Is there a way to specify that I don't want to obfuscate the code. 回答1: By default javac is not including debug information in generated class files. This information is e.g. method parameter names (but method and field names are always stored to allow reflection).

gcc compiler flag to suppress template expansion for template errors during compilation?

梦想的初衷 提交于 2020-02-21 13:20:57
问题 I'm wondering if there is a flag or modification for the gcc compiler that will return a line number and sentence explaining the type of error when it encounters an error involving templates, but will not print the page of template expansion code spaghetti that invariably follow such errors. For example, instead of an error like this: temp.cc:9: error: ‘class std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std:

gcc compiler flag to suppress template expansion for template errors during compilation?

僤鯓⒐⒋嵵緔 提交于 2020-02-21 13:18:49
问题 I'm wondering if there is a flag or modification for the gcc compiler that will return a line number and sentence explaining the type of error when it encounters an error involving templates, but will not print the page of template expansion code spaghetti that invariably follow such errors. For example, instead of an error like this: temp.cc:9: error: ‘class std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std:

gcc compiler flag to suppress template expansion for template errors during compilation?

落花浮王杯 提交于 2020-02-21 13:18:42
问题 I'm wondering if there is a flag or modification for the gcc compiler that will return a line number and sentence explaining the type of error when it encounters an error involving templates, but will not print the page of template expansion code spaghetti that invariably follow such errors. For example, instead of an error like this: temp.cc:9: error: ‘class std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std:

Overhead in unused code

本小妞迷上赌 提交于 2020-02-13 04:35:09
问题 I am wondering what the overhead is of having unused functions in your code. Say for example you have some debug logging, and you then give most of your objects a ToString() function that is being used in the debug logs. In a release build that debug logging is not being used. Is it then worth it removing the source code of those ToString() functions? (e.g. via Macro?) Or do they just make the executable marginally larger and otherwise don't impact performance? e.g. no speed impact? Or does