Mara /

Filename Size Date modified Message
compiler
samples
stdlib
utils
52 B
34.3 KB
544 B
2.9 KB

Mara Programming Language

What is Mara ?

Mara is a programming language dedicated to 8bit ATMEL AVR microcontrollers with a focus on simplicity and productivity.

The goal of this project is to simplify the programming of these microcontrollers for all those who do not wish to use (or learn) the C or assembly language.

Mara is also compatible with Arduino boards based on AVR.

The core language is still under development. Although stable version is not available, Mara can be used experimentally.

Examples

Factorial

# fact.mr

static

func fact(n)
        return n = 0 ? 1 :          \
               (n * fact(n - 1))
end

# main.mr

using fact

begin setup
        PORTD.set_mode(0xFF)
        PORTD.write(fact(3)) # print 6
end

begin loop
end

USART

begin setup
        PORTB.set_pin_in(0)
        var uart <- new uart(23)
end

begin loop
        waitfor not PORTB.read_pin(0)
        uart.write("Hello World !\n\r")
        waitfor PORTB.read_pin(0)
end

List

begin setup
        PORTD.set_mode(0xFF)

        var l <- [1; 1337; 21; 4]
        l.insert(1, 42)
        l.push(0)

        PORTD.write(l[2]) # print 42

        del l
end

begin loop
end

Classes

# point.mr

integer x
integer y

func init(nx, ny)
        self.x <- nx
        self.y <- ny
        return self
end

func squared_dist()
        return (self.x * self.x) + \
               (self.y * self.y)
end

# main.mr

begin setup
        PORTD.set_mode(0xFF)

        var p <- new point(2, 3)

        PORTD.write(p.squared_dist()) # print 13

        del p
end

begin loop
end

Dependencies

  • avrdude (driver program for AVR programmer)

Edit Mara code with Emacs

First, copy the file utils/mara-mode.el in your ~/.emacs.d/ directory.

Then, add the following lines to your ~/.emacs file :

(autoload 'mara-mode "~/.emacs.d/mara-mode.el" "" t)
(setq auto-mode-alist (cons '("\\.mr\\w?" . mara-mode) auto-mode-alist))

Installation

$ make
# make install

Usage

marac FILE [OPTIONS]...

The compiler support the following flags :

  • -mmcu MCU name
  • -I Include folder
  • -v Verbose
  • -clean Remove build directory and .hex files
  • -help Display this list of options
  • --help Display this list of options

Contact

  • Pierre Surply (pierre.surply@gmail.com)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.