Giter Site home page Giter Site logo

juniper's People

Contributors

calebh avatar kiliankilmister avatar ljades avatar pre63 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

juniper's Issues

Error tolerant Parsing and Type Checking to improve editor support

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:

  • Parser that records all text and positions in the AST (even keywords, comments, etc, useful for semantic highlighting)
  • Parser that recovers from syntax errors that happen typically when you type new code.
  • Type checker that can work with an AST that contains parse errors.
  • Type checker that never or rarely throws an exception (therefore records type errors in some other way)
  • Type checker that can output multiple constraint errors instead of throwing on the first one.
  • Type checker that keeps track of type variables' and capacity variables' original names (for more readable type strings)
  • (?) Type checker that can use the results of the last type check, and only recheck the AST that has changed
  • General refactoring, e.g. to reduce warnings in the code, or adding strong aliases e.g. type ModuleName = ModuleName of string
  • ... I know I must be already forgetting something

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!

No such file or directory: #include <new>

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.

Problem compiling program

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?

blink example

@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.

Algebraic data type with pointer member causes C++ compilation error

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.

Add dependency tracking information to inline C++ blocks

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.

Problems Getting Blink.jun Uploaded to Arduino

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:

image

Ouput main.cpp

(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.

image

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

Full Build Output

Do you have any guidance on how to resolve these errors?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.