A small sneak peek of what the error highlighting looks like in the IDE I am making:
Yet another update:
So far I am happy with how the project is progressing. I think it will take a little bit more time until the first release, as now I am not only building the compiler but also the IDE which comes with it.
Compiler progress:I have built an evaluator (code analyzer), which can check whether the types are correct, if all variables have been declared, etc. It can also put additional info into the parse tree (e.g. types for inferred declarations)
It still needs a few tweaks, but overall its initial version is complete.
Right now the compiler consists of three main parts:
-
The Parser - Checks the code syntax and generates the first parse tree
-
The Evaluator - Analyzes code semantics and generates the second parse tree
-
Code Generator -
(I am yet to write this one) - it will produce C++ code for Arduino; As I said before I may need help from the community in the future in order to optimize it properly.
IDE progress:The IDE is going well, especially since I added the analyzer - it can now point out errors like undefined variables, incorrect types, etc. Its really nice to have a compiler 'built-in' because we can check not only the syntax, but also the semantics of the code, and all that can be done 'live'
Besides that it allows for some other great functionality in the future, for example, we could develop an Arduino emulator which can be used for testing code before uploading to the actual device.
I also checked out some other similar projects like
https://codebender.cc/, but I think my approach has some benefits over what they are doing.
Other stuff:Putting aside the compiler implementation details, here is a somewhat interesting 'quirk' that I stumbled upon while developing the languge.
As I mentioned before I wanted to add 'optional' types to the language, meaning that the type of the variable can be inferred from its value during assignment. E.g.
( b = 4 ) - here
b is obviously an
intI also made semicolons optional as I think it can make the code look more 'approachable' to beginners
But take a look at this situation:
a = // accidentally forgot to assign value
// (real life example, I did this while testing the IDE)
b = 3
in a system with no declaration types and no semicolons this converts into:
int a = b = 3
Which can lead to some
weird errors, and the compiler also would not be able to catch such an error.
I decided to fix this by not allowing multi-line assignments, so both left and right parts of the assignment must be on the same line. I think that this is a good enough fix, but this made me think whether optional types will bring more benefits then problems. I will leave them in for now, but this is something that we can discuss in the future.
Ideas:I also have a couple ideas that I want to add to the language.
For example,
'short-hand functions' (or
'dynamic variables') which could be declared with
-> operator, and are really just a shorter way to express a function with no arguments
So you can write something like this:
a = 1
b = 2
c -> a + b
serial_println( "Sum is " + c ) // Sum is 3
a = 3
serial_println( "Sum is " + c ) // Sum is 5
Also sub-string expressions, which are kind of like string 'templates' and act as an alias for
sprinf() :
foo = "Hello"
serial_println( "{foo} World!" ) // Hello World!
Anyways, its important to focus on getting the basics right for now

I will post a new update soon.
PS I updated the topic title since it has become more of a 'developer notes' kind of post.