steven-r / oberon0compiler Goto Github PK
View Code? Open in Web Editor NEWAn implementation of N. Wirths Oberon 0 language implemented with C# and ANTLR. Currently compiler output is generated as MSIL code
License: MIT License
An implementation of N. Wirths Oberon 0 language implemented with C# and ANTLR. Currently compiler output is generated as MSIL code
License: MIT License
Eases build and use "official" runtime.
Also:
IToken
referenceThis allows interchange to C/C++ and other languages besides oberon0 itself.
Currently LLVM 15 is planned
Tasks:
Required to allow #29 …
oberon0.exe source-file.ob0 [/output target.exe] [/asm:<path to ilasm.exe>] [/syslib:<pathtosystem.dll>]
IO
conversions
Operations like "+", ...
Others
The following is not possible:
VAR r: REAL;
BEGIN
r := 1;
END;
complaining that left and right side types are not compatible.
There should be a generic mechanismn to allow compatible assignments, aka
Target | Source | valid |
---|---|---|
REAL | INT | ok |
BOOL | INT | ok |
INT | REAL | not ok |
For types the base types need to have the same name.
For complex types the underlying types need to be the same.
For arrays the length and base type need to be the same.
The following code create an error while generating MSIL:
MODULE ProcTest;
CONST
true = TRUE;
END ProcTest.
The error is
error : syntax error at token 'true' in: .data true = int32 (1)
[ ] Generator
[ ] Tests
They are translated by true
and false
during compilation and create an uneccessary warning during compilation
The following code shoudl give an compilation error (Array index out of range):
VAR a: ARRAY 5 OF INTEGER;
BEGIN
a[0] := 1;
END test.
Error in app configuration:
Exception while parsing configuration YAML: name of an alias node must contain at least one character at line 16, column 13:
- label: *
^
Please check the syntax of your .issue-branch.yml
Dependabot couldn't find a package.json for this project.
Dependabot requires a package.json to evaluate your project's current JavaScript dependencies. It had expected to find one at the path: /package.json
.
If this isn't a JavaScript project, or if it is a library, you may wish to disable updates for it from within Dependabot.
Code:
MODULE Test;
VAR
x: ARRAY 5 OF INTEGER;
BEGIN
y[1] := 2
END Test.
Exception:
System.NullReferenceException : Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei Oberon0.Compiler.Oberon0CompilerListener.ExitSelector(SelectorContext context)
bei Oberon0.Compiler.OberonGrammarParser.SelectorContext.ExitRule(IParseTreeListener listener)
bei Antlr4.Runtime.Parser.TriggerExitRuleEvent()
bei Antlr4.Runtime.Parser.ExitRule()
bei Oberon0.Compiler.OberonGrammarParser.module()
bei Oberon0.Compiler.Oberon0Compiler.CompileString(String source, Oberon0CompilerOptions options)
bei Oberon0.TestSupport.TestHelper.CompileString(String source, List`1 errors)
bei Oberon0.TestSupport.TestHelper.CompileString(String source, String[] expectedErrors)
bei Oberon0.Compiler.Tests.SimpleStatementTests.TestAssignFailVarNotFound()
The following code generates wrong MSIL:
VAR
s: RECORD a : INTEGER END;
BEGIN
ReadInt(s.a);
s.a := s.a + 1;
WriteInt(s.a);
WriteLn
END ReadToRecord.
No type for the record is generated in MSIL
MODULE Test;
VAR i: INTEGER;
BEGIN
i := -2147483648;
END Test.
The value -2147483648
should be of type INTEGER
, not REAL
.
Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Oberon0.Msil.Program.StartCompile(ParseResult result, FileSystemInfo input, Boolean verbose, IConsole console) in D:\Users\StephenReindl\Source\Repos\steven-r\Oberon0Compiler\Oberon0.Msil\Program.cs:line 55
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__21_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__22_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__20_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__11_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()
D:\Users\StephenReindl\Source\Repos\steven-r\Oberon0Compiler\Oberon0.Msil\bin\Debug\netcoreapp3.1\Oberon0.Msil.exe (process 29484) exited with code 1.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
Dependabot was set up to create pull requests against the branch develop
, but couldn't find it.
If the branch has been permanently deleted you can update Dependabot's target branch from your dashboard.
There're only simple tests for real arithmetic. More tests are required to check for correct code generation
Prepare to use .net 7 to allow LLVM (and compile on macos)
Combine compiler and command line towards a zip file
The following code failes (and should succeed):
VAR a: ARRAY 5 OF INTEGER;
BEGIN
a[5] := 1;
END test.
In addition a NRE is thrown:
System.NullReferenceException : Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei Oberon0.Compiler.Oberon0CompilerListener.ExitAssign_statement(Assign_statementContext context)
bei Oberon0.Compiler.OberonGrammarParser.Assign_statementContext.ExitRule(IParseTreeListener listener)
bei Antlr4.Runtime.Parser.TriggerExitRuleEvent()
bei Antlr4.Runtime.Parser.ExitRule()
bei Oberon0.Compiler.OberonGrammarParser.module()
bei Oberon0.Compiler.Oberon0Compiler.CompileString(String source, Oberon0CompilerOptions options)
bei Oberon0.TestSupport.TestHelper.CompileString(String source, List`1 errors)
bei Oberon0.TestSupport.TestHelper.CompileString(String source, String[] expectedErrors)
bei Oberon0.Compiler.Tests.Types.ArrayTests.ArrayFail1TestIndex5()
Currently this is not working and is creating wrong code
See https://github.com/robvanderleek/create-issue-branch for details
The follwing will create a DLL instead of an executable...
MODULE export;
PROCEDURE x*;
BEGIN
END x;
BEGIN
(* init code *)
END export;
The code will emit one external static function ('x'). The init code will be executed as part of system initialization.
if an if/while/repeat statement contains a simple variable reference (e.g. IF (x) THEN
), wrong code is generated.
Compile is supported, MSIL is not correct (call by value, call by reference)
This might cause compatibility issues while moving to different platforms.
Use double.Epsilon
for code generation
Having a RECORD containing an ARRAY or other complex scenarios are compiling but do not create correct code
Describe the bug
Module end name is not compared against module name
To Reproduce
MODULE test;
END failed.
**Expected behavior**
A error message is dispayed that name and end-name do not match
The following code throws an NRE:
BEGIN
a[0] = 1;
END test.
Output:
System.NullReferenceException : Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei Oberon0.Compiler.Oberon0CompilerListener.ExitAssign_statement(Assign_statementContext context)
bei Oberon0.Compiler.OberonGrammarParser.Assign_statementContext.ExitRule(IParseTreeListener listener)
bei Antlr4.Runtime.Parser.TriggerExitRuleEvent()
bei Antlr4.Runtime.Parser.ExitRule()
bei Oberon0.Compiler.OberonGrammarParser.module()
bei Oberon0.Compiler.Oberon0Compiler.CompileString(String source, Oberon0CompilerOptions options)
bei Oberon0.TestSupport.TestHelper.CompileString(String source, List`1 errors)
bei Oberon0.TestSupport.TestHelper.CompileString(String source, String[] expectedErrors)
bei Oberon0.Compiler.Tests.Types.ArrayTests.ArrayFail1Test()
[9/9] - mismatched input '=' expecting ':='
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.