calebh / juniper Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://www.juniper-lang.org/
License: MIT License
Home Page: https://www.juniper-lang.org/
License: MIT License
Hello!
The language looks awesome! I just started using it but I didn't find editor support except for syntax highlighting, so I started to create a Language Server Protocol implementation and a VS Code extension which you can check out in my fork of this repo. I think it already gives a pretty nice basic programming experience :)
So far I've tried to make as little modification to the original compiler as possible but I think I've more or less exhausted the LSP features that can be implemented this way. If you like these changes I made to the compiler, I can create a PR.
In order to support more LSP features for the language (completion suggestions in lots of places, semantic highlighting, types on hover, go to definition, etc...) there's a need for a more error tolerant parser and a type checker that can report multiple errors at once or give incomplete (but useful) information on a file that has syntax or type errors. Stretch goal could be some kind of incremental parsing/type checking.
I'm happy to already start working on extending the parser and the type checker this way. I'm planning to make changes including but probably not limited to:
type ModuleName = ModuleName of string
Any change/progress I make I would be happy to push back to this repo, but I'm not confident that it's useful for you to accept the changes. Ideally, nothing I do will change e.g. the typing rules (*for well typed programs anyway) but the details of the actual implementation could differ greatly. Maybe it's important that you're closely familiar with the codebase in case you need to work on a new version or a new paper, so a big change would cause difficulties in these areas. On the other hand, if you accept the changes and implement any future modifications on top of them, then the improvements would be instantly available to the Language Server implementation and any editor extensions. I'd ask you to share your viewpoint on this.
So in summary, I'd like to extend the parser and the type checker in order to implement more Language Server Protocol features for an enhanced editing experience of Juniper source code. Or that's my plan anyway, which I'm not sure exactly how far will get in reality.
I'd like to hear your thoughts on the topic generally, and on the possible joint future of the original compiler and the LSP version.
Thanks in advance!
I currently try to build and upload the blink example with VsCode using the Arduino IDE.
But I get the following error message when I try to compile the generated file
Alternatives for new: []
ResolveLibrary(new)
-> candidates: []fatal error: new: No such file or directory
#include <new>
^~~~~
compilation terminated.
The board is a Arduino Nano Every and I have not included any other libraries.
I'm having a hard time writing a program that fades in and out a led, this is what i'm trying:
module Blink
open(Prelude, Io, Time)
let boardLed = 11
let tState = Time:state()
let ledState = ref (0u16, high())
fun loop() = (
fadeLed(boardLed, tState, ledState)
)
fun folder(_ : uint32, lastState: (uint16 * pinState)) = (
case (lastState) of
| (0, low()) => (1, high())
| (x, low()) => (x - 1, low())
| (100, high()) => (99, low())
| (x, high()) => (x + 1, high())
end
)
fun fadeLed(boardLed, tState, ledState) = (
let timeSignal = Time:every(10, tState);
let fader = Signal:foldP(folder, ledState, timeSignal);
let pinSignal = Signal:map(fst, fader);
Io:anaOut(boardLed, pinSignal)
)
fun setup() =
Io:setPinMode(boardLed, Io:output())
However, i'm getting this message when i try to uptade the cpp to a arduino uno using platformIO:
> Executing task in folder Juniper: pio run --target upload <
Processing uno (platform: atmelavr; board: uno; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (3.0.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr 5.1.0
- tool-avrdude 1.60300.200527 (6.3.0)
- toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/uno/src/main.cpp.o
src/main.cpp: In instantiation of 'Result juniper::concrete_function<Func, Result, Args>::operator()(Args ...) [with Func = Prelude::tuple2<long int, Io::pinState> (*)(long unsigned int, Prelude::tuple2<unsigned int, Io::pinState>); Result = Prelude::tuple2<unsigned int, Io::pinState>; Args = {long unsigned int, Prelude::tuple2<unsigned int, Io::pinState>}]':
src/main.cpp:4504:1: required from here
src/main.cpp:130:29: error: could not convert '((juniper::concrete_function<Prelude::tuple2<long int, Io::pinState> (*)(long unsigned int, Prelude::tuple2<unsigned int, Io::pinState>), Prelude::tuple2<unsigned int, Io::pinState>, long unsigned int, Prelude::tuple2<unsigned int, Io::pinState> >*)this)->juniper::concrete_function<Prelude::tuple2<long int, Io::pinState> (*)(long unsigned int, Prelude::tuple2<unsigned int, Io::pinState>), Prelude::tuple2<unsigned int, Io::pinState>, long unsigned int, Prelude::tuple2<unsigned int, Io::pinState> >::f(args#0, args#1)' from 'Prelude::tuple2<long int, Io::pinState>' to 'Prelude::tuple2<unsigned int, Io::pinState>'
return f(args...);
^
*** [.pio/build/uno/src/main.cpp.o] Error 1
================================================================================================= [FAILED] Took 0.56 seconds =================================================================================================
The terminal process "pio 'run', '--target', 'upload'" terminated with exit code: 1.
It there something i'm doing wrong?
@calebh
I tested blink example on arduino and surprisingly it's blinking only 33 times and led stays off. After reset again: led blinks 33 times and off.
Smart pointers cannot be members of unions due to smart pointers having non-trivial copy constructors. Obviously there is no reason for this restriction to exist since all of the algebraic data types are tagged. Consider moving from unions to something more like std::variant or boost::variant to allow this use case.
We currently cannot track what variables a C++ block uses, leading to potential ordering problems when generating output C++. For example, a inline C++ in a function may refer to a global variable stored in a module, but the Juniper compiler may place that global variable declaration after the function declaration. This is only an issue for global variables, which cannot be forward declared. Alternatively, try to use smarter heuristics like maintaining the order of global variable declarations based on position in the source code. At the very least, we can move all global variable declarations to come before function declarations.
First time Juniper developer here. I'm having problems getting the simple blink.jun program uploaded to my board. Here's the problems I'm running into.
I've installed Juniper (version 3.0) and am running the following code:
module Blink
open(Prelude, Io, Time)
//It wouldn't compile without me specifying the `uint16` type
let boardLed: uint16 = 13
let tState = Time:state()
let ledState = ref low()
fun loop() = (
let timerSig = Time:every(1000, tState);
let ledSig =
Signal:foldP(
fn (currentTime, lastState) ->
Io:toggle(lastState)
end,
ledState, timerSig);
Io:digOut(boardLed, ledSig)
)
fun setup() =
Io:setPinMode(boardLed, Io:output())
I am able to successfully compile using the Juniper CLI:
(Independently I've installed PlatformIO, and can copy their simple blink to my board and run it.)
I'm writing the output of the Juniper build into the main.cpp of my PlatformIO project. But when I build the PlatformIO project, I get a lot of warnings and the following errors.
src\main.cpp:333:13: error: no matching function for call to 'operator new(sizetype, void*&)'
src\main.cpp:266:17: error: no matching function for call to 'operator new(sizetype, void*&)'
//lots more of this error
Do you have any guidance on how to resolve these errors?
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.