GithubHelp home page GithubHelp logo

rvanbaarle / metaborg-chocopy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from molenzwiebel/metaborg-chocopy

0.0 0.0 0.0 46 KB

An implementation of ChocoPy with exceptions within the Spoofax Language Workbench

License: Apache License 2.0

Kotlin 100.00%

metaborg-chocopy's Introduction

metaborg-chocopy

This repository contains an implementation of the ChocoPy programming language, with additional support for Python 3.6+-style exceptions. The implementation is written using version 3 of the Spoofax language workbench. Part of this project was written as part as a case-study for Dynamix: A Domain-Specific Language for Dynamic Semantics.

You can import this repository in your Spoofax 3 eclipse instance by following the steps here.

Exception Extensions

This version of ChocoPy has additional support for exceptions. In particular, the following constructs have been added:

raise exp

try:
    body
except ClassName as ident:
    body
finally:
    body

The behavior of exceptions largely mimics that of exceptions in Python, with a few key differences:

  • Raised exceptions can be any object of any class, and do not need to inherit Exception (there's no Exception in ChocoPy).
  • Caught exceptions bound in except blocks must be declared beforehand, similar to the loop variable for for blocks.
  • Classes declared in an except block must match exactly. If Bar is a subclass of Foo, an except Foo as ex: block will ONLY catch Foo instances, not Bar instances.

Contents

This language project contains the following parts:

  • chocopy/src/syntax: The SDF3 grammar definition for ChocoPy, with extensions for exceptions.
  • chocopy/src/statics: The Statix specification for ChocoPy, with extensions for exceptions and tagging for boxing operations.
  • chocopy/src/dynamics: The Dynamix specification for ChocoPy, with extensions for exceptions and support for automatic boxing.

Acknowledgements

The original SDF3 grammar and Statix specification for ChocoPy was written by Alexander Sterk and Tim Nederveen. Adjustments to add support for exceptions, as well as the Dynamix specification, are courtesy of Thijs Molendijk.

License

The files in this repository are licensed under the Apache License, Version 2.0. You may use the files in this repository in compliance with the license.

metaborg-chocopy's People

Contributors

molenzwiebel avatar rvanbaarle avatar

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.