Comments (4)
If there are warnings but no errors, GCC returns a zero exit code. Using flag -Werror
, GCC treats all warnings like errors and will return a non-zero exit code as well.
I prepared some examples that raise unexpected symbol messages which mostly still compile, but may have interesting effects. GCC rejects all of these examples and retursn exit code 1 because syntax errors are errors:
In this example, Selfie returns exit code 10:
int main() {
uint64_t value;
value = / 10;
return value;
}
This example actually does not compile. However, this is not because the input file is not accepted but rather because compile_simple_expression
expects compile_factor
to allocate a temporary register. However, in line 4556, it merely prints an unexpected symbol message and continues without compiling any factor. Thus, Selfie fails with illegal register access
instead:
int main() {
uint64_t value;
uint64_t* ptr;
ptr = (uint64_t*) 42;
value = ptr --{ 10;
return value;
}
In this example, the integer literal of the former global variable is applied to the latter as well. Thus, Selfie returns 42:
uint64_t initialized = 42;
uint64_t invalid = ;
int main() {
return invalid;
}
from selfie.
@Blazefrost Error handling in the selfie compiler is something that requires more attention. Very true. Do you have any recommendation on how to fix these issues with the least amount of work? I am swamped right now and won't have much time to do this.
from selfie.
As we discussed, it's probably best to continue compilation after encountering a syntax error and return the exit code afterwards so that we can enumerate all syntax errors.
Both the scanner as well as the parser may raise syntax errors. There are some non-recoverable errors that prompt the scanner to immediately exit with EXITCODE_SCANNERERROR
. Maybe we should prefix these errors with fatal
, i.e. fatal syntax error
, to distinguish them from recoverable errors where we can continue to parse the file.
Another open question is the exit code to return. If we encounter syntax errors in both the scanner and the parser, which exit code should we return? I'd propose to either take precedence on the scanner over the parser, or to introduce a new EXITCODE_SYNTAXERROR
.
from selfie.
@Blazefrost I suggest we leave the names of the errors as is, assuming those errors are all limitations of the current implementation and could be avoided with smarter code. Thus SCANNERERROR, PARSERERROR, and COMPILERERROR should only be used when exiting immediately. Then we introduce a new SYNTAXERROR as exitcode for syntax errors from which the compiler actually recovers. What do you think?
from selfie.
Related Issues (20)
- 10) Virtual Memory - Introductory Assignments
- 11) Virtualization - Introductory Assignments
- Compiler warnings with GCC 10.2.0 HOT 3
- Docker Build on Mac
- Clean up gcc/clang toolchain in Dockerselfie image to support 32-bit and 64-bit x86 and RISC-V HOT 10
- `self-assembler` assignment results in timeout HOT 7
- ELF file integrity
- Grader: Replace `threads` task `shared-heap` with thread-safe task HOT 4
- Suggestion: -Werror when self-grading HOT 7
- `characters of assembly` count in disassembler output is incorrect in `printf` branch HOT 10
- Grader not terminating on plain selfie HOT 4
- Order in list of assignments out of sync HOT 1
- Compiler warnings with GCC 11.1.0 HOT 4
- Residual files in selfie root directory in the selfie docker image after machine build HOT 1
- Multiplatform AMD64/ARM64 Support HOT 2
- "palloc out of physical memory" problem with changed "make os" HOT 7
- modeler returns "maximum code size exceeded" or "4712 expected between -4096 and 4095" if code size is increased HOT 7
- 32-bit + mipster + self-self-self [+ gc] is failing HOT 1
- Naming the programming language C* causes some confusion HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from selfie.