mirror of
https://github.com/nickmqb/wyre.git
synced 2025-12-06 02:30:42 -08:00
Update line endings
This commit is contained in:
parent
c989b49602
commit
a24c3ebdf4
3 changed files with 124 additions and 124 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
|
||||||
178
compiler/main.mu
178
compiler/main.mu
|
|
@ -1,89 +1,89 @@
|
||||||
//tab_size=4
|
//tab_size=4
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
::currentAllocator = Memory.newArenaAllocator(256 * 1024 * 1024)
|
::currentAllocator = Memory.newArenaAllocator(256 * 1024 * 1024)
|
||||||
|
|
||||||
CrashHandler.enable()
|
CrashHandler.enable()
|
||||||
|
|
||||||
argErrors := new List<CommandLineArgsParserError>{}
|
argErrors := new List<CommandLineArgsParserError>{}
|
||||||
parser := new CommandLineArgsParser.from(Environment.getCommandLineArgs(), argErrors)
|
parser := new CommandLineArgsParser.from(Environment.getCommandLineArgs(), argErrors)
|
||||||
args := parseArgs(parser, true)
|
args := parseArgs(parser, true)
|
||||||
|
|
||||||
if argErrors.count > 0 {
|
if argErrors.count > 0 {
|
||||||
info := parser.getCommandLineInfo()
|
info := parser.getCommandLineInfo()
|
||||||
for argErrors {
|
for argErrors {
|
||||||
Stderr.writeLine(CommandLineArgsParser.getErrorDesc(it, info))
|
Stderr.writeLine(CommandLineArgsParser.getErrorDesc(it, info))
|
||||||
}
|
}
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.printVersion || args.printHelp {
|
if args.printVersion || args.printHelp {
|
||||||
Stdout.writeLine(format("Wyre compiler, version {}", compilerVersion))
|
Stdout.writeLine(format("Wyre compiler, version {}", compilerVersion))
|
||||||
if args.printHelp {
|
if args.printHelp {
|
||||||
Stdout.writeLine("For documentation, see: https://github.com/nickmqb/wyre")
|
Stdout.writeLine("For documentation, see: https://github.com/nickmqb/wyre")
|
||||||
}
|
}
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
comp := new Compilation {
|
comp := new Compilation {
|
||||||
sources: args.sources,
|
sources: args.sources,
|
||||||
errors: new List<Error>{},
|
errors: new List<Error>{},
|
||||||
units: new List<CodeUnit>{},
|
units: new List<CodeUnit>{},
|
||||||
}
|
}
|
||||||
|
|
||||||
for sf, i in comp.sources {
|
for sf, i in comp.sources {
|
||||||
unit := Parser.unit(sf.text, comp.errors, args.indent)
|
unit := Parser.unit(sf.text, comp.errors, args.indent)
|
||||||
unit.path = sf.path
|
unit.path = sf.path
|
||||||
unit.id = i
|
unit.id = i
|
||||||
comp.units.add(unit)
|
comp.units.add(unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
Indexer.comp(comp)
|
Indexer.comp(comp)
|
||||||
|
|
||||||
top := comp.symbols.getOrDefault(args.top)
|
top := comp.symbols.getOrDefault(args.top)
|
||||||
if top.is(ModuleDef) {
|
if top.is(ModuleDef) {
|
||||||
top.as(ModuleDef).flags |= ModuleFlags.top
|
top.as(ModuleDef).flags |= ModuleFlags.top
|
||||||
} else {
|
} else {
|
||||||
comp.errors.add(Error { text: format("Top module not found: {}", args.top) })
|
comp.errors.add(Error { text: format("Top module not found: {}", args.top) })
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeChecker.comp(comp)
|
TypeChecker.comp(comp)
|
||||||
|
|
||||||
es := cast(null, EmulatorState)
|
es := cast(null, EmulatorState)
|
||||||
if comp.errors.count == 0 {
|
if comp.errors.count == 0 {
|
||||||
es = Emulator.init(comp, top.as(ModuleDef))
|
es = Emulator.init(comp, top.as(ModuleDef))
|
||||||
Emulator.reset(es)
|
Emulator.reset(es)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort errors, but always show syntax errors first
|
// Sort errors, but always show syntax errors first
|
||||||
comp.errors.slice(0, comp.nonSyntaxErrorStart).stableSort(ErrorHelper.compareErrors)
|
comp.errors.slice(0, comp.nonSyntaxErrorStart).stableSort(ErrorHelper.compareErrors)
|
||||||
comp.errors.slice(comp.nonSyntaxErrorStart, comp.errors.count).stableSort(ErrorHelper.compareErrors)
|
comp.errors.slice(comp.nonSyntaxErrorStart, comp.errors.count).stableSort(ErrorHelper.compareErrors)
|
||||||
|
|
||||||
if comp.errors.count > 0 {
|
if comp.errors.count > 0 {
|
||||||
for e, i in comp.errors {
|
for e, i in comp.errors {
|
||||||
if i >= args.maxErrors {
|
if i >= args.maxErrors {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if e.unit != null {
|
if e.unit != null {
|
||||||
Stdout.writeLine(ErrorHelper.getErrorDesc(e.unit.path, e.unit.source, e.span, e.text))
|
Stdout.writeLine(ErrorHelper.getErrorDesc(e.unit.path, e.unit.source, e.span, e.text))
|
||||||
} else {
|
} else {
|
||||||
Stdout.writeLine(e.text)
|
Stdout.writeLine(e.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if comp.errors.count > args.maxErrors {
|
if comp.errors.count > args.maxErrors {
|
||||||
Stdout.writeLine(format("{} errors ({} shown)", comp.errors.count, args.maxErrors))
|
Stdout.writeLine(format("{} errors ({} shown)", comp.errors.count, args.maxErrors))
|
||||||
} else {
|
} else {
|
||||||
Stdout.writeLine(format("{} errors", comp.errors.count))
|
Stdout.writeLine(format("{} errors", comp.errors.count))
|
||||||
}
|
}
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
out := VerilogGenerator.comp(comp, es)
|
out := VerilogGenerator.comp(comp, es)
|
||||||
|
|
||||||
if !File.tryWriteString(args.outputPath, out.sb.compactToString()) {
|
if !File.tryWriteString(args.outputPath, out.sb.compactToString()) {
|
||||||
Stderr.writeLine(format("Could not write to output file: {}", args.outputPath))
|
Stderr.writeLine(format("Could not write to output file: {}", args.outputPath))
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
Stdout.writeLine(format("Generated output: {}", args.outputPath))
|
Stdout.writeLine(format("Generated output: {}", args.outputPath))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
../../muon/lib/core.mu
|
../../muon/lib/core.mu
|
||||||
../../muon/lib/basic.mu
|
../../muon/lib/basic.mu
|
||||||
../../muon/lib/stdio.mu
|
../../muon/lib/stdio.mu
|
||||||
../../muon/lib/string.mu
|
../../muon/lib/string.mu
|
||||||
../../muon/lib/containers.mu
|
../../muon/lib/containers.mu
|
||||||
../../muon/lib/memory.mu
|
../../muon/lib/memory.mu
|
||||||
../../muon/lib/environment.mu
|
../../muon/lib/environment.mu
|
||||||
../../muon/lib/random.mu
|
../../muon/lib/random.mu
|
||||||
../../muon/lib/range.mu
|
../../muon/lib/range.mu
|
||||||
../../muon/lib/sort.mu
|
../../muon/lib/sort.mu
|
||||||
cstdlib.mu
|
cstdlib.mu
|
||||||
ast.mu
|
ast.mu
|
||||||
parser.mu
|
parser.mu
|
||||||
command_line_args_parser.mu
|
command_line_args_parser.mu
|
||||||
args_parser.mu
|
args_parser.mu
|
||||||
error_helper.mu
|
error_helper.mu
|
||||||
indexer.mu
|
indexer.mu
|
||||||
type_checker.mu
|
type_checker.mu
|
||||||
type_checker_utils.mu
|
type_checker_utils.mu
|
||||||
type_checker_builtins.mu
|
type_checker_builtins.mu
|
||||||
range_finder.mu
|
range_finder.mu
|
||||||
emulator_init.mu
|
emulator_init.mu
|
||||||
emulator.mu
|
emulator.mu
|
||||||
tape.mu
|
tape.mu
|
||||||
verilog_generator.mu
|
verilog_generator.mu
|
||||||
main.mu
|
main.mu
|
||||||
--output-file wyre.c
|
--output-file wyre.c
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue