To run this you need node and the PEG.js module installed.
To create the parser.js file, run:
pegjs grammar.peg parser.js
Now to compile the xmaslang source, run:
node parser.js program.xmas > programm.js
| REBOL [ | |
| Title: "Euler1 dialecting example" | |
| Author: "Torbjørn Marø" | |
| Home: http://blog.kjempekjekt.com | |
| Date: 19-Dec-2011 | |
| Purpose: { | |
| This script demonstrates how to use the built in parse | |
| functionality of Rebol to create an internal DSL. | |
| This particular DSL lets you create sums that are the |
| =begin | |
| TO INSTALL DEPENDENCIES | |
| ----------------------- | |
| gem install ffi <-- For Windows users | |
| gem install clipboard | |
| =end | |
| HTML_CODES = { | |
| "&" => "&", | |
| ">" => ">", |
| require './parser' | |
| require './nodes_eval' | |
| class Runtime | |
| def initialize | |
| @file = "test.log" | |
| end | |
| def loglines | |
| @lines = File.readlines(@file) | |
| @lines.each_with_index do |line, index| |
| # Encoding: UTF-8 | |
| Encoding.default_external = "UTF-8" | |
| require 'benchmark' | |
| BLACKLIST = %w(på og er om fra med i to det å | |
| ditt til ved fra for av en din | |
| du at vi har vil nå det som dere | |
| kan vår så) |
| var encryption = function() { | |
| // Works with ASCII chars from 32 (space) | |
| // to 248 (å). | |
| var shiftCharCode = function(code, shift) { | |
| if (shift < 0) shift += (248 - 32 + 1) | |
| return 32 + (((code - 32) + shift) % (248 - 32 + 1)); | |
| }; |
To run this you need node and the PEG.js module installed.
To create the parser.js file, run:
pegjs grammar.peg parser.js
Now to compile the xmaslang source, run:
node parser.js program.xmas > programm.js
| (use srfi-13 extras) | |
| (define header #<<EOF | |
| -------------------------------------------------------------------- | |
| WORD | |
| Adaption of original game in BASIC by Charles Reid of Lexington High | |
| School, Massachusetts. Scheme version by Torbjørn Marø, 2014. | |
| -------------------------------------------------------------------- | |
| I am thinking of a word -- you guess it. I will give you clues to |
| (use srfi-13 extras) | |
| (printf #<<EOF | |
| KINEMA | |
| Adaption of BASIC computer game from 1978 | |
| EOF | |
| ) |
| #lang racket | |
| ;; Author: Torbjørn Marø | |
| ;; Inspired by Peter Sessions REVERSE game | |
| ;; as published in 'BASIC Computer Games' (1978) | |
| ;; http://www.atariarchives.org/basicgames/showpage.php?page=135 | |
| (displayln "Welcome to REVERSE -- A Game of Skill! ") | |
| (newline) | |
| (displayln "To win, all you have to do is arrange a list ") |
| (in-package :cl-user) | |
| (defpackage :sms | |
| (:documentation | |
| "A simple package to send SMS using LINK Mobility") | |
| (:use :cl) | |
| (:import-from :drakma :http-request) | |
| (:import-from :cl-who :with-html-output-to-string :str :esc) | |
| (:export :<gateway> | |
| :send-sms)) | |
| (in-package :sms) |