Skip to content
This repository has been archived by the owner on Jun 23, 2018. It is now read-only.

Adding a language

amasad edited this page Oct 3, 2011 · 3 revisions

Adding a language

jsREPL

jsREPL is the REPL engine, language loader and sandboxer for repl.it.
Most of the work done in order to add a new language falls into jsREPL.
The following guide assumes that a language engine has been already added to
jsREPL, refer to jsREPL's wiki for more information.

repl.it

###Config

languages.coffee holds all the featuerd language definitions and config.
e.g. CoffeeScript config:

CoffeeScript:
	name: 'CoffeeScript'
	tagline: 'Unfancy JavaScript.'
	shortcut: 'C'
	about_link: 'http://jashkenas.github.com/coffee-script/'
	engine_link: 'https://github.com/jashkenas/coffee-script/'
	examples:
  		editor: '/langs/coffee-script/examples-editor.html'
  		console: '/langs/coffee-script/examples-console.html'
	ace_mode:
  		script: '/lib/ace/mode-coffee.js'
  		module: 'ace/mode/coffee'
	header: '''
  	  CoffeeScript v1.0.1
  	  Copyright (c) 2011, Jeremy Ashkenas
	'''
  • name: Is the display name of the language.
  • tagline: A one line description of the language (max 50 chars).
  • shortcut: A character that represents the unique keyboard shortcut for
    each language in repl.it.
  • about_link: A link to the official page of the language.
  • engine_link: A link to the implementation of the language used.
  • examples: An object that defines an example file that has a set of examples
    suitable for either the editor or the console.
  • ace_mode: An object that defines the Ace editor mode script path and module name.
  • header: The header that is displayed in the console when the language is first loaded.

###Examples Examples are a very important part of repl.it and each language must define a set of editor
and console examples. See http://repl.it/#:examples
The example file structure:

Example Title
********************************************************************************
Example content
********************************************************************************
(newline)

For the asterisk seperator to be identified as one it should be at least 60 chars long.

e.g. CoffeeScript console examples:

Hello World
********************************************************************************
console.log 'Hello World!'
********************************************************************************

Comprehension
********************************************************************************
square = (x) -> x * x
console.dir (square num for num in [10..1])
********************************************************************************

Factorial
********************************************************************************
factorial = (x) ->
	if x then x * factorial x - 1 else 1
factorial 6
********************************************************************************
Clone this wiki locally