Mishaps
Stephen Leach edited this page Oct 20, 2020
·
1 revision
Inside the compiler, if you wish to raise an error for the user, you should use the Mishap class imported from the mishap module. For example:
from mishap import Mishap
raise Mishap( "Trying to declare a top-level variable as assignable", name=name_of_variable, hint="Top level variables must be val or const" )
The Mishap will propagate to the top-level of the Nutmeg compiler where it is turned into a nice error message for the user. The keyword arguments are printed out together with the message to provide extra context.
As the Mishap propagates out you may want to add extra contextual details. For this use the following idiom:
try:
STATEMENTS
except Mishap as m:
raise m.addDetails( in_procedure=getProcedureName() )
You do not have to worry about name clashes between added details and the original details as each set of keyword-arguments is retained separately.
Design Principles
- Nutmeg Design Goals
- The Spirit of Nutmeg
- Syntax Design
- State Encapsulation
- List of Design Decisions
- Influences
Language Features
- $$-Syntax (Echo Expressions)
- Actors
- Allocators
- Annotations
- Assignments
- Bindings
- Blocks and Modifiers
- Brackets
- Capsules (Proposed)
- Clean Procedures
- Comments
- Copy by Snapshot
- Declarations
- Finesses
- For Syntax
- Futures
- Identifiers
- If Syntax
- Messages
- Pass Syntax
- Queries
- References
- Return Statements
- Sealing
- Semicolons
- Strings
- Switch Syntax
Built-in Libraries and Functions
Implementation
- Architecture in one page
- Autoconversion
- Bundle Files
- Code-Trees
- Compiler Pipeline
- Components of the Compiler
- Installation File Structure
- Mishaps
- Peekable Pushable Generators
- Recursive Descent Parser
- Resolver
- Walkthrough of Hello-World
How-Tos
Process