mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Compare commits
35 Commits
puppet-fix
...
v5.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e60384b018 | ||
|
|
470a82d9f5 | ||
|
|
37979b26b0 | ||
|
|
1a6df12902 | ||
|
|
24e196df4e | ||
|
|
8d178bfaed | ||
|
|
e9ec699931 | ||
|
|
9a6c3f2c4d | ||
|
|
648720301d | ||
|
|
c552e25bd7 | ||
|
|
d5c8db3fb9 | ||
|
|
632bcdc1ad | ||
|
|
6b221172c0 | ||
|
|
6f0d801375 | ||
|
|
128abe3533 | ||
|
|
9312353d20 | ||
|
|
b6460f8ed6 | ||
|
|
60f864a138 | ||
|
|
ca6121e3ea | ||
|
|
7c17b1f10c | ||
|
|
d490fc303f | ||
|
|
20fdac95f6 | ||
|
|
234ee8b6d2 | ||
|
|
58ab593a64 | ||
|
|
ec1f6a4cd6 | ||
|
|
3eea8212f4 | ||
|
|
a1e09ae3e6 | ||
|
|
c1f76c26e5 | ||
|
|
0983f62e02 | ||
|
|
190e54c020 | ||
|
|
ded651159d | ||
|
|
acbab53198 | ||
|
|
fba4babdcd | ||
|
|
eb6a213921 | ||
|
|
5e2c79e950 |
36
.gitmodules
vendored
36
.gitmodules
vendored
@@ -112,9 +112,6 @@
|
||||
[submodule "vendor/grammars/fancy-tmbundle"]
|
||||
path = vendor/grammars/fancy-tmbundle
|
||||
url = https://github.com/fancy-lang/fancy-tmbundle
|
||||
[submodule "vendor/grammars/dart-sublime-bundle"]
|
||||
path = vendor/grammars/dart-sublime-bundle
|
||||
url = https://github.com/guillermooo/dart-sublime-bundle
|
||||
[submodule "vendor/grammars/sublimetext-cuda-cpp"]
|
||||
path = vendor/grammars/sublimetext-cuda-cpp
|
||||
url = https://github.com/harrism/sublimetext-cuda-cpp
|
||||
@@ -330,7 +327,7 @@
|
||||
url = https://github.com/textmate/php-smarty.tmbundle
|
||||
[submodule "vendor/grammars/php.tmbundle"]
|
||||
path = vendor/grammars/php.tmbundle
|
||||
url = https://github.com/brandonblack/php.tmbundle
|
||||
url = https://github.com/textmate/php.tmbundle
|
||||
[submodule "vendor/grammars/postscript.tmbundle"]
|
||||
path = vendor/grammars/postscript.tmbundle
|
||||
url = https://github.com/textmate/postscript.tmbundle
|
||||
@@ -387,7 +384,7 @@
|
||||
url = https://github.com/textmate/c.tmbundle
|
||||
[submodule "vendor/grammars/zephir-sublime"]
|
||||
path = vendor/grammars/zephir-sublime
|
||||
url = https://github.com/vmg/zephir-sublime
|
||||
url = https://github.com/phalcon/zephir-sublime
|
||||
[submodule "vendor/grammars/llvm.tmbundle"]
|
||||
path = vendor/grammars/llvm.tmbundle
|
||||
url = https://github.com/whitequark/llvm.tmbundle
|
||||
@@ -799,7 +796,7 @@
|
||||
url = https://github.com/perl6/atom-language-perl6
|
||||
[submodule "vendor/grammars/reason"]
|
||||
path = vendor/grammars/reason
|
||||
url = https://github.com/facebook/reason
|
||||
url = https://github.com/chenglou/sublime-reason
|
||||
[submodule "vendor/grammars/language-xcompose"]
|
||||
path = vendor/grammars/language-xcompose
|
||||
url = https://github.com/samcv/language-xcompose
|
||||
@@ -839,3 +836,30 @@
|
||||
[submodule "vendor/grammars/language-jolie"]
|
||||
path = vendor/grammars/language-jolie
|
||||
url = https://github.com/fmontesi/language-jolie
|
||||
[submodule "vendor/grammars/language-typelanguage"]
|
||||
path = vendor/grammars/language-typelanguage
|
||||
url = https://github.com/goodmind/language-typelanguage
|
||||
[submodule "vendor/grammars/sublime-shen"]
|
||||
path = vendor/grammars/sublime-shen
|
||||
url = https://github.com/rkoeninger/sublime-shen
|
||||
[submodule "vendor/grammars/Sublime-Pep8"]
|
||||
path = vendor/grammars/Sublime-Pep8
|
||||
url = https://github.com/R4PaSs/Sublime-Pep8
|
||||
[submodule "vendor/grammars/dartlang"]
|
||||
path = vendor/grammars/dartlang
|
||||
url = https://github.com/dart-atom/dartlang
|
||||
[submodule "vendor/grammars/language-closure-templates"]
|
||||
path = vendor/grammars/language-closure-templates
|
||||
url = https://github.com/mthadley/language-closure-templates
|
||||
[submodule "vendor/grammars/language-webassembly"]
|
||||
path = vendor/grammars/language-webassembly
|
||||
url = https://github.com/Alhadis/language-webassembly
|
||||
[submodule "vendor/grammars/language-ring"]
|
||||
path = vendor/grammars/language-ring
|
||||
url = https://github.com/MahmoudFayed/atom-language-ring
|
||||
[submodule "vendor/grammars/sublime-fantom"]
|
||||
path = vendor/grammars/sublime-fantom
|
||||
url = https://github.com/rkoeninger/sublime-fantom
|
||||
[submodule "vendor/grammars/language-pan"]
|
||||
path = vendor/grammars/language-pan
|
||||
url = https://github.com/quattor/language-pan
|
||||
|
||||
@@ -67,6 +67,16 @@ For development you are going to want to checkout out the source. To get it, clo
|
||||
cd linguist/
|
||||
script/bootstrap
|
||||
|
||||
To run Linguist from the cloned repository, you will need to generate the code samples first:
|
||||
|
||||
bundle exec rake samples
|
||||
|
||||
Run this command each time a [sample][samples] has been modified.
|
||||
|
||||
To run Linguist from the cloned repository:
|
||||
|
||||
bundle exec bin/linguist --breakdown
|
||||
|
||||
To run the tests:
|
||||
|
||||
bundle exec rake test
|
||||
|
||||
22
grammars.yml
22
grammars.yml
@@ -100,6 +100,8 @@ vendor/grammars/Sublime-Modula-2:
|
||||
- source.modula2
|
||||
vendor/grammars/Sublime-Nit:
|
||||
- source.nit
|
||||
vendor/grammars/Sublime-Pep8/:
|
||||
- source.pep8
|
||||
vendor/grammars/Sublime-QML:
|
||||
- source.qml
|
||||
vendor/grammars/Sublime-REBOL:
|
||||
@@ -247,11 +249,9 @@ vendor/grammars/cython:
|
||||
- source.cython
|
||||
vendor/grammars/d.tmbundle:
|
||||
- source.d
|
||||
vendor/grammars/dart-sublime-bundle:
|
||||
vendor/grammars/dartlang:
|
||||
- source.dart
|
||||
- source.pubspec
|
||||
- text.dart-analysis-output
|
||||
- text.dart-doccomments
|
||||
- source.yaml-ext
|
||||
vendor/grammars/desktop.tmbundle:
|
||||
- source.desktop
|
||||
vendor/grammars/diff.tmbundle:
|
||||
@@ -358,6 +358,8 @@ vendor/grammars/language-click:
|
||||
- source.click
|
||||
vendor/grammars/language-clojure:
|
||||
- source.clojure
|
||||
vendor/grammars/language-closure-templates:
|
||||
- text.html.soy
|
||||
vendor/grammars/language-coffee-script:
|
||||
- source.coffee
|
||||
- source.litcoffee
|
||||
@@ -425,6 +427,8 @@ vendor/grammars/language-ncl:
|
||||
- source.ncl
|
||||
vendor/grammars/language-ninja:
|
||||
- source.ninja
|
||||
vendor/grammars/language-pan:
|
||||
- source.pan
|
||||
vendor/grammars/language-povray:
|
||||
- source.pov-ray sdl
|
||||
vendor/grammars/language-regexp:
|
||||
@@ -434,6 +438,8 @@ vendor/grammars/language-renpy:
|
||||
- source.renpy
|
||||
vendor/grammars/language-restructuredtext:
|
||||
- text.restructuredtext
|
||||
vendor/grammars/language-ring:
|
||||
- source.ring
|
||||
vendor/grammars/language-roff:
|
||||
- source.ditroff
|
||||
- source.ditroff.desc
|
||||
@@ -453,11 +459,15 @@ vendor/grammars/language-toc-wow:
|
||||
- source.toc
|
||||
vendor/grammars/language-turing:
|
||||
- source.turing
|
||||
vendor/grammars/language-typelanguage:
|
||||
- source.tl
|
||||
vendor/grammars/language-viml:
|
||||
- source.viml
|
||||
vendor/grammars/language-wavefront:
|
||||
- source.wavefront.mtl
|
||||
- source.wavefront.obj
|
||||
vendor/grammars/language-webassembly:
|
||||
- source.webassembly
|
||||
vendor/grammars/language-xbase:
|
||||
- source.harbour
|
||||
vendor/grammars/language-xcompose:
|
||||
@@ -618,6 +628,8 @@ vendor/grammars/sublime-cirru:
|
||||
- source.cirru
|
||||
vendor/grammars/sublime-clips:
|
||||
- source.clips
|
||||
vendor/grammars/sublime-fantom:
|
||||
- source.fan
|
||||
vendor/grammars/sublime-glsl:
|
||||
- source.essl
|
||||
- source.glsl
|
||||
@@ -639,6 +651,8 @@ vendor/grammars/sublime-rexx:
|
||||
- source.rexx
|
||||
vendor/grammars/sublime-robot-plugin:
|
||||
- text.robot
|
||||
vendor/grammars/sublime-shen:
|
||||
- source.shen
|
||||
vendor/grammars/sublime-spintools:
|
||||
- source.regexp.spin
|
||||
- source.spin
|
||||
|
||||
@@ -57,7 +57,7 @@ module Linguist
|
||||
composer_lock? ||
|
||||
node_modules? ||
|
||||
go_vendor? ||
|
||||
npm_shrinkwrap? ||
|
||||
npm_shrinkwrap_or_package_lock? ||
|
||||
godeps? ||
|
||||
generated_by_zephir? ||
|
||||
minified_files? ||
|
||||
@@ -326,11 +326,11 @@ module Linguist
|
||||
!!name.match(/vendor\/((?!-)[-0-9A-Za-z]+(?<!-)\.)+(com|edu|gov|in|me|net|org|fm|io)/)
|
||||
end
|
||||
|
||||
# Internal: Is the blob a generated npm shrinkwrap file?
|
||||
# Internal: Is the blob a generated npm shrinkwrap or package lock file?
|
||||
#
|
||||
# Returns true or false.
|
||||
def npm_shrinkwrap?
|
||||
!!name.match(/npm-shrinkwrap\.json/)
|
||||
def npm_shrinkwrap_or_package_lock?
|
||||
name.match(/npm-shrinkwrap\.json/) || name.match(/package-lock\.json/)
|
||||
end
|
||||
|
||||
# Internal: Is the blob part of Godeps/,
|
||||
|
||||
@@ -297,7 +297,7 @@ module Linguist
|
||||
disambiguate ".ms" do |data|
|
||||
if /^[.'][a-z][a-z](\s|$)/i.match(data)
|
||||
Language["Roff"]
|
||||
elsif /(?<!\S)\.(include|globa?l)\s/.match(data) || /(?<!\/\*)(\A|\n)\s*\.[A-Za-z]/.match(data.gsub(/"([^\\"]|\\.)*"|'([^\\']|\\.)*'|\\\s*(?:--.*)?\n/, ""))
|
||||
elsif /(?<!\S)\.(include|globa?l)\s/.match(data) || /(?<!\/\*)(\A|\n)\s*\.[A-Za-z][_A-Za-z0-9]*:/.match(data.gsub(/"([^\\"]|\\.)*"|'([^\\']|\\.)*'|\\\s*(?:--.*)?\n/, ""))
|
||||
Language["Unix Assembly"]
|
||||
else
|
||||
Language["MAXScript"]
|
||||
@@ -340,13 +340,13 @@ module Linguist
|
||||
elsif /use strict|use\s+v?5\./.match(data)
|
||||
Language["Perl"]
|
||||
elsif /^(use v6|(my )?class|module)/.match(data)
|
||||
Language["Perl6"]
|
||||
Language["Perl 6"]
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate ".pm" do |data|
|
||||
if /^\s*(?:use\s+v6\s*;|(?:\bmy\s+)?class|module)\b/.match(data)
|
||||
Language["Perl6"]
|
||||
Language["Perl 6"]
|
||||
elsif /\buse\s+(?:strict\b|v?5\.)/.match(data)
|
||||
Language["Perl"]
|
||||
end
|
||||
@@ -446,7 +446,7 @@ module Linguist
|
||||
if /^\s*%[ \t]+|^\s*var\s+\w+\s*:=\s*\w+/.match(data)
|
||||
Language["Turing"]
|
||||
elsif /^\s*(?:use\s+v6\s*;|\bmodule\b|\b(?:my\s+)?class\b)/.match(data)
|
||||
Language["Perl6"]
|
||||
Language["Perl 6"]
|
||||
elsif /\buse\s+(?:strict\b|v?5\.)/.match(data)
|
||||
Language["Perl"]
|
||||
end
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
#
|
||||
# type - Either data, programming, markup, prose, or nil
|
||||
# aliases - An Array of additional aliases (implicitly
|
||||
# includes the lowercase name with spaces replaced
|
||||
# by dashes)
|
||||
# includes name.downcase)
|
||||
# ace_mode - A String name of the Ace Mode used for highlighting whenever
|
||||
# a file is edited. This must match one of the filenames in http://git.io/3XO_Cg.
|
||||
# Use "text" if a mode does not exist.
|
||||
@@ -456,7 +455,6 @@ C:
|
||||
- ".cats"
|
||||
- ".h"
|
||||
- ".idc"
|
||||
- ".w"
|
||||
interpreters:
|
||||
- tcc
|
||||
ace_mode: c_cpp
|
||||
@@ -590,6 +588,13 @@ CSV:
|
||||
extensions:
|
||||
- ".csv"
|
||||
language_id: 51
|
||||
CWeb:
|
||||
type: programming
|
||||
extensions:
|
||||
- ".w"
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
language_id: 657332628
|
||||
Cap'n Proto:
|
||||
type: programming
|
||||
tm_scope: source.capnp
|
||||
@@ -688,6 +693,18 @@ Clojure:
|
||||
filenames:
|
||||
- riemann.config
|
||||
language_id: 62
|
||||
Closure Templates:
|
||||
type: markup
|
||||
group: HTML
|
||||
ace_mode: soy_template
|
||||
codemirror_mode: soy
|
||||
codemirror_mime_type: text/x-soy
|
||||
alias:
|
||||
- soy
|
||||
extensions:
|
||||
- ".soy"
|
||||
tm_scope: text.html.soy
|
||||
language_id: 357046146
|
||||
CoffeeScript:
|
||||
type: programming
|
||||
tm_scope: source.coffee
|
||||
@@ -1067,6 +1084,16 @@ Eagle:
|
||||
codemirror_mode: xml
|
||||
codemirror_mime_type: text/xml
|
||||
language_id: 97
|
||||
Easybuild:
|
||||
type: data
|
||||
group: Python
|
||||
ace_mode: python
|
||||
codemirror_mode: python
|
||||
codemirror_mime_type: text/x-python
|
||||
tm_scope: source.python
|
||||
extensions:
|
||||
- ".eb"
|
||||
language_id: 342840477
|
||||
Ecere Projects:
|
||||
type: data
|
||||
group: JavaScript
|
||||
@@ -1214,10 +1241,10 @@ Fancy:
|
||||
language_id: 109
|
||||
Fantom:
|
||||
type: programming
|
||||
color: "#dbded5"
|
||||
color: "#14253c"
|
||||
extensions:
|
||||
- ".fan"
|
||||
tm_scope: none
|
||||
tm_scope: source.fan
|
||||
ace_mode: text
|
||||
language_id: 110
|
||||
Filebench WML:
|
||||
@@ -1360,6 +1387,8 @@ GLSL:
|
||||
- ".glslv"
|
||||
- ".gshader"
|
||||
- ".shader"
|
||||
- ".tesc"
|
||||
- ".tese"
|
||||
- ".vert"
|
||||
- ".vrx"
|
||||
- ".vsh"
|
||||
@@ -2450,6 +2479,7 @@ Makefile:
|
||||
- Makefile.frag
|
||||
- Makefile.in
|
||||
- Makefile.inc
|
||||
- Makefile.wat
|
||||
- makefile
|
||||
- makefile.sco
|
||||
- mkfile
|
||||
@@ -3100,7 +3130,7 @@ Pan:
|
||||
color: "#cc0000"
|
||||
extensions:
|
||||
- ".pan"
|
||||
tm_scope: none
|
||||
tm_scope: source.pan
|
||||
ace_mode: text
|
||||
language_id: 276
|
||||
Papyrus:
|
||||
@@ -3160,6 +3190,14 @@ Pascal:
|
||||
codemirror_mode: pascal
|
||||
codemirror_mime_type: text/x-pascal
|
||||
language_id: 281
|
||||
Pep8:
|
||||
type: programming
|
||||
color: "#C76F5B"
|
||||
extensions:
|
||||
- ".pep"
|
||||
ace_mode: text
|
||||
tm_scope: source.pep8
|
||||
language_id: 840372442
|
||||
Perl:
|
||||
type: programming
|
||||
tm_scope: source.perl
|
||||
@@ -3179,10 +3217,12 @@ Perl:
|
||||
- ".pod"
|
||||
- ".psgi"
|
||||
- ".t"
|
||||
filenames:
|
||||
- cpanfile
|
||||
interpreters:
|
||||
- perl
|
||||
language_id: 282
|
||||
Perl6:
|
||||
Perl 6:
|
||||
type: programming
|
||||
color: "#0000fb"
|
||||
extensions:
|
||||
@@ -3708,6 +3748,14 @@ RenderScript:
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
language_id: 323
|
||||
Ring:
|
||||
type: programming
|
||||
color: "#0e60e3"
|
||||
extensions:
|
||||
- .ring
|
||||
tm_scope: source.ring
|
||||
ace_mode: text
|
||||
language_id: 431
|
||||
RobotFramework:
|
||||
type: programming
|
||||
extensions:
|
||||
@@ -3740,6 +3788,7 @@ Roff:
|
||||
- ".me"
|
||||
- ".ms"
|
||||
- ".n"
|
||||
- ".nr"
|
||||
- ".rno"
|
||||
- ".roff"
|
||||
- ".tmac"
|
||||
@@ -4073,7 +4122,12 @@ Shell:
|
||||
- PKGBUILD
|
||||
- gradlew
|
||||
interpreters:
|
||||
- ash
|
||||
- bash
|
||||
- dash
|
||||
- ksh
|
||||
- mksh
|
||||
- pdksh
|
||||
- rc
|
||||
- sh
|
||||
- zsh
|
||||
@@ -4098,7 +4152,7 @@ Shen:
|
||||
color: "#120F14"
|
||||
extensions:
|
||||
- ".shen"
|
||||
tm_scope: none
|
||||
tm_scope: source.shen
|
||||
ace_mode: text
|
||||
language_id: 348
|
||||
Slash:
|
||||
@@ -4459,6 +4513,15 @@ Twig:
|
||||
codemirror_mode: twig
|
||||
codemirror_mime_type: text/x-twig
|
||||
language_id: 377
|
||||
Type Language:
|
||||
type: data
|
||||
aliases:
|
||||
- tl
|
||||
extensions:
|
||||
- ".tl"
|
||||
tm_scope: source.tl
|
||||
ace_mode: text
|
||||
language_id: 632765617
|
||||
TypeScript:
|
||||
type: programming
|
||||
color: "#2b7489"
|
||||
@@ -4656,6 +4719,20 @@ Web Ontology Language:
|
||||
tm_scope: text.xml
|
||||
ace_mode: xml
|
||||
language_id: 394
|
||||
WebAssembly:
|
||||
type: programming
|
||||
color: "#04133b"
|
||||
extensions:
|
||||
- ".wast"
|
||||
- ".wat"
|
||||
aliases:
|
||||
- wast
|
||||
- wasm
|
||||
tm_scope: source.webassembly
|
||||
ace_mode: lisp
|
||||
codemirror_mode: commonlisp
|
||||
codemirror_mime_type: text/x-common-lisp
|
||||
language_id: 956556503
|
||||
WebIDL:
|
||||
type: programming
|
||||
extensions:
|
||||
@@ -4800,6 +4877,7 @@ XML:
|
||||
- ".xml.dist"
|
||||
- ".xproj"
|
||||
- ".xsd"
|
||||
- ".xspec"
|
||||
- ".xul"
|
||||
- ".zcml"
|
||||
filenames:
|
||||
|
||||
@@ -72,6 +72,9 @@
|
||||
# Normalize.css
|
||||
- (^|/)normalize\.(css|less|scss|styl)$
|
||||
|
||||
# Skeleton.css
|
||||
- (^|/)skeleton\.(css|less|scss|styl)$
|
||||
|
||||
# Bourbon css
|
||||
- (^|/)[Bb]ourbon/.*\.(css|less|scss|styl)$
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Linguist
|
||||
VERSION = "5.0.9"
|
||||
VERSION = "5.1.0"
|
||||
end
|
||||
|
||||
27
samples/C/asm.h
Normal file
27
samples/C/asm.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* CarbonOS System/Kernel
|
||||
* Copyright 2015-2017 David Aylaian
|
||||
* Licensed under Apache 2.0: https://github.com/DavidAylaian/CarbonOS/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
#ifndef ASM_H
|
||||
#define ASM_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// macros for enabling and disabling interrupts
|
||||
#define enable() asm("sti");
|
||||
#define disable() asm("cli");
|
||||
|
||||
// inb instruction
|
||||
uint8_t inb (uint16_t port) {
|
||||
uint8_t val;
|
||||
asm volatile ("inb %0, %1" : "=a"(val): "Nd"(port));
|
||||
return val;
|
||||
}
|
||||
|
||||
// outb instruction
|
||||
void outb (uint16_t port, uint8_t val) {
|
||||
asm volatile ("outb %1, %0" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
#endif
|
||||
25
samples/C/cpuid.h
Normal file
25
samples/C/cpuid.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef CPUID_H
|
||||
#define CPUID_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
static inline void do_cpuid(dword_t *eax, dword_t *ebx, dword_t *ecx, dword_t *edx) {
|
||||
dword_t leaf = *eax;
|
||||
switch (leaf) {
|
||||
case 0:
|
||||
*eax = 0x01; // we support barely anything
|
||||
*ebx = 0x756e6547; // Genu
|
||||
*edx = 0x49656e69; // ineI
|
||||
*ecx = 0x6c65746e; // ntel
|
||||
break;
|
||||
default: // if leaf is too high, use highest supported leaf
|
||||
case 1:
|
||||
*eax = 0x0; // say nothing about cpu model number
|
||||
*ebx = 0x0; // processor number 0, flushes 0 bytes on clflush
|
||||
*ecx = 0b00000000000000000000000000000000; // we support none of the features in ecx
|
||||
*edx = 0b00000000000000000000000000000000; // we also support none of the features in edx
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
404
samples/CWeb/sat-life.w
Normal file
404
samples/CWeb/sat-life.w
Normal file
@@ -0,0 +1,404 @@
|
||||
\datethis
|
||||
@*Intro. This program generates clauses for the transition relation
|
||||
from time $t$ to time $t+1$ in Conway's Game of Life, assuming that
|
||||
all of the potentially live cells at time $t$ belong to a pattern
|
||||
that's specified in |stdin|. The pattern is defined by one or more
|
||||
lines representing rows of cells, where each line has `\..' in a
|
||||
cell that's guaranteed to be dead at time~$t$, otherwise it has `\.*'.
|
||||
The time is specified separately as a command-line parameter.
|
||||
|
||||
The Boolean variable for cell $(x,y)$ at time $t$ is named by its
|
||||
so-called ``xty code,'' namely by the decimal value of~$x$, followed
|
||||
by a code letter for~$t$, followed by the decimal value of~$y$. For
|
||||
example, if $x=10$ and $y=11$ and $t=0$, the variable that indicates
|
||||
liveness of the cell is \.{10a11}; and the corresponding variable
|
||||
for $t=1$ is \.{10b11}.
|
||||
|
||||
Up to 19 auxiliary variables are used together with each xty code,
|
||||
in order to construct clauses that define the successor state.
|
||||
The names of these variables are obtained by appending one of
|
||||
the following two-character combinations to the xty code:
|
||||
\.{A2}, \.{A3}, \.{A4},
|
||||
\.{B1}, \.{B2}, \.{B3}, \.{B4},
|
||||
\.{C1}, \.{C2}, \.{C3}, \.{C4},
|
||||
\.{D1}, \.{D2},
|
||||
\.{E1}, \.{E2},
|
||||
\.{F1}, \.{F2},
|
||||
\.{G1}, \.{G2}.
|
||||
These variables are derived from the Bailleux--Boufkhad method
|
||||
of encoding cardinality constraints:
|
||||
The auxiliary variable \.{A$k$} stands for the condition
|
||||
``at least $k$ of the eight neighbors are alive.'' Similarly,
|
||||
\.{B$k$} stands for ``at least $k$ of the first four neighbors
|
||||
are alive,'' and \.{C$k$} accounts for the other four neighbors.
|
||||
Codes \.D, \.E, \.F, and~\.G refer to pairs of neighbors.
|
||||
Thus, for instance, \.{10a11C2} means that at least two of the
|
||||
last four neighbors of cell $(10,11)$ are alive.
|
||||
|
||||
Those auxiliary variables receive values by means of up to 77 clauses per cell.
|
||||
For example, if $u$ and~$v$ are the neighbors of cell~$z$ that correspond
|
||||
to a pairing of type~\.D, there are six clauses
|
||||
$$\bar u d_1,\quad
|
||||
\bar v d_1,\quad
|
||||
\bar u\bar v d_2,\quad
|
||||
u v\bar d_1,\quad
|
||||
u\bar d_2,\quad
|
||||
v\bar d_2.$$
|
||||
The sixteen clauses
|
||||
$$\displaylines{\hfill
|
||||
\bar d_1b_1,\quad
|
||||
\bar e_1b_1,\quad
|
||||
\bar d_2b_2,\quad
|
||||
\bar d_1\bar e_1b_2,\quad
|
||||
\bar e_2b_2,\quad
|
||||
\bar d_2\bar e_1b_3,\quad
|
||||
\bar d_1\bar e_2b_3,\quad
|
||||
\bar d_2\bar e_2b_4,
|
||||
\hfill\cr\hfill
|
||||
d_1e_1\bar b_1,\quad
|
||||
d_1e_2\bar b_2,\quad
|
||||
d_2e_1\bar b_2,\quad
|
||||
d_1\bar b_3,\quad
|
||||
d_2e_2\bar b_3,\quad
|
||||
e_1\bar b_3,\quad
|
||||
d_2\bar b_4,\quad
|
||||
e_2\bar b_4
|
||||
\hfill}$$
|
||||
define $b$ variables from $d$'s and $e$'s; and another sixteen
|
||||
define $c$'s from $f$'s and $g$'s in the same fashion.
|
||||
A similar set of 21 clauses will define the $a$'s from the $b$'s and $c$'s.
|
||||
|
||||
Once the $a$'s are defined, thus essentially counting the
|
||||
live neighbors of cell $z$, the next
|
||||
state~$z'$ is defined by five further clauses
|
||||
$$\bar a_4\bar z',\quad
|
||||
a_2\bar z',\quad
|
||||
a_3z\bar z',\quad
|
||||
\bar a_3a_4z',\quad
|
||||
\bar a_2a_4\bar zz'.$$
|
||||
For example, the last of these states that $z'$ will be true
|
||||
(i.e., that cell $z$ will be alive at time $t+1$) if
|
||||
$z$ is alive at time~$t$ and has $\ge2$ live neighbors
|
||||
but not $\ge4$.
|
||||
|
||||
Nearby cells can share auxiliary variables, according to a tricky scheme that
|
||||
is worked out below. In consequence, the actual number of auxiliary variables
|
||||
and clauses per cell is reduced from 19 and $77+5$ to 13 and $57+5$,
|
||||
respectively, except at the boundaries.
|
||||
|
||||
@ So here's the overall outline of the program.
|
||||
|
||||
@d maxx 50 /* maximum number of lines in the pattern supplied by |stdin| */
|
||||
@d maxy 50 /* maximum number of columns per line in |stdin| */
|
||||
|
||||
@c
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
char p[maxx+2][maxy+2]; /* is cell $(x,y)$ potentially alive? */
|
||||
char have_b[maxx+2][maxy+2]; /* did we already generate $b(x,y)$? */
|
||||
char have_d[maxx+2][maxy+2]; /* did we already generate $d(x,y)$? */
|
||||
char have_e[maxx+2][maxy+4]; /* did we already generate $e(x,y)$? */
|
||||
char have_f[maxx+4][maxy+2]; /* did we already generate $f(x-2,y)$? */
|
||||
int tt; /* time as given on the command line */
|
||||
int xmax,ymax; /* the number of rows and columns in the input pattern */
|
||||
int xmin=maxx,ymin=maxy; /* limits in the other direction */
|
||||
char timecode[]="abcdefghijklmnopqrstuvwxyz"@|
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"@|
|
||||
"!\"#$%&'()*+,-./:;<=>?@@[\\]^_`{|}~"; /* codes for $0\le t\le83$ */
|
||||
@q$@>
|
||||
char buf[maxy+2]; /* input buffer */
|
||||
unsigned int clause[4]; /* clauses are assembled here */
|
||||
int clauseptr; /* this many literals are in the current clause */
|
||||
@<Subroutines@>@;
|
||||
main(int argc,char*argv[]) {
|
||||
register int j,k,x,y;
|
||||
@<Process the command line@>;
|
||||
@<Input the pattern@>;
|
||||
for (x=xmin-1;x<=xmax+1;x++) for (y=ymin-1;y<=ymax+1;y++) {
|
||||
@<If cell $(x,y)$ is obviously dead at time $t+1$, |continue|@>;
|
||||
a(x,y);
|
||||
zprime(x,y);
|
||||
}
|
||||
}
|
||||
|
||||
@ @<Process the command line@>=
|
||||
if (argc!=2 || sscanf(argv[1],"%d",&tt)!=1) {
|
||||
fprintf(stderr,"Usage: %s t\n",argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
if (tt<0 || tt>82) {
|
||||
fprintf(stderr,"The time should be between 0 and 82 (not %d)!\n",tt);
|
||||
exit(-2);
|
||||
}
|
||||
|
||||
@ @<Input the pattern@>=
|
||||
for (x=1;;x++) {
|
||||
if (!fgets(buf,maxy+2,stdin)) break;
|
||||
if (x>maxx) {
|
||||
fprintf(stderr,"Sorry, the pattern should have at most %d rows!\n",maxx);
|
||||
exit(-3);
|
||||
}
|
||||
for (y=1;buf[y-1]!='\n';y++) {
|
||||
if (y>maxy) {
|
||||
fprintf(stderr,"Sorry, the pattern should have at most %d columns!\n",
|
||||
maxy);
|
||||
exit(-4);
|
||||
}
|
||||
if (buf[y-1]=='*') {
|
||||
p[x][y]=1;
|
||||
if (y>ymax) ymax=y;
|
||||
if (y<ymin) ymin=y;
|
||||
if (x>xmax) xmax=x;
|
||||
if (x<xmin) xmin=x;
|
||||
}@+else if (buf[y-1]!='.') {
|
||||
fprintf(stderr,"Unexpected character `%c' found in the pattern!\n",
|
||||
buf[y-1]);
|
||||
exit(-5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ @d pp(xx,yy) ((xx)>=0 && (yy)>=0? p[xx][yy]: 0)
|
||||
|
||||
@<If cell $(x,y)$ is obviously dead at time $t+1$, |continue|@>=
|
||||
if (pp(x-1,y-1)+pp(x-1,y)+pp(x-1,y+1)+
|
||||
pp(x,y-1)+p[x][y]+p[x][y+1]+
|
||||
pp(x+1,y-1)+p[x+1][y]+p[x+1][y+1]<3) continue;
|
||||
|
||||
@ Clauses are assembled in the |clause| array (surprise), where we
|
||||
put encoded literals.
|
||||
|
||||
The code for a literal is an unsigned 32-bit quantity, where the leading
|
||||
bit is 1 if the literal should be complemented. The next three bits
|
||||
specify the type of the literal (0 thru 7 for plain and \.A--\.G);
|
||||
the next three bits specify an integer~$k$; and the next bit is zero.
|
||||
That leaves room for two 12-bit fields, which specify $x$ and $y$.
|
||||
|
||||
Type 0 literals have $k=0$ for the ordinary xty code. However, the
|
||||
value $k=1$ indicates that the time code should be for $t+1$ instead of~$t$.
|
||||
And $k=2$ denotes a special ``tautology'' literal, which is always true.
|
||||
If the tautology literal is complemented, we omit it from the clause;
|
||||
otherwise we omit the entire clause.
|
||||
Finally, $k=7$ denotes an auxiliary literal, used to avoid
|
||||
clauses of length~4.
|
||||
|
||||
Here's a subroutine that outputs the current clause and resets
|
||||
the |clause| array.
|
||||
|
||||
@d taut (2<<25)
|
||||
@d sign (1U<<31)
|
||||
|
||||
@<Sub...@>=
|
||||
void outclause(void) {
|
||||
register int c,k,x,y,p;
|
||||
for (p=0;p<clauseptr;p++)
|
||||
if (clause[p]==taut) goto done;
|
||||
for (p=0;p<clauseptr;p++) if (clause[p]!=taut+sign) {
|
||||
if (clause[p]>>31) printf(" ~");@+else printf(" ");
|
||||
c=(clause[p]>>28)&0x7;
|
||||
k=(clause[p]>>25)&0x7;
|
||||
x=(clause[p]>>12)&0xfff;
|
||||
y=clause[p]&0xfff;
|
||||
if (c) printf("%d%c%d%c%d",
|
||||
x,timecode[tt],y,c+'@@',k);
|
||||
else if (k==7) printf("%d%c%dx",
|
||||
x,timecode[tt],y);
|
||||
else printf("%d%c%d",
|
||||
x,timecode[tt+k],y);
|
||||
}
|
||||
printf("\n");
|
||||
done: clauseptr=0;
|
||||
}
|
||||
|
||||
@ And here's another, which puts a type-0 literal into |clause|.
|
||||
|
||||
@<Sub...@>=
|
||||
void applit(int x,int y,int bar,int k) {
|
||||
if (k==0 && (x<xmin || x>xmax || y<ymin || y>ymax || p[x][y]==0))
|
||||
clause[clauseptr++]=(bar? 0: sign)+taut;
|
||||
else clause[clauseptr++]=(bar? sign:0)+(k<<25)+(x<<12)+y;
|
||||
}
|
||||
|
||||
@ The |d| and |e| subroutines are called for only one-fourth
|
||||
of all cell addresses $(x,y)$. Indeed, one can show that
|
||||
$x$ is always odd, and that $y\bmod4<2$.
|
||||
|
||||
Therefore we remember if we've seen $(x,y)$ before.
|
||||
|
||||
Slight trick: If |yy| is not in range, we avoid generating the
|
||||
clause $\bar d_k$ twice.
|
||||
|
||||
@d newlit(x,y,c,k) clause[clauseptr++]=((c)<<28)+((k)<<25)+((x)<<12)+(y)
|
||||
@d newcomplit(x,y,c,k)
|
||||
clause[clauseptr++]=sign+((c)<<28)+((k)<<25)+((x)<<12)+(y)
|
||||
|
||||
@<Sub...@>=
|
||||
void d(int x,int y) {
|
||||
register x1=x-1,x2=x,yy=y+1;
|
||||
if (have_d[x][y]!=tt+1) {
|
||||
applit(x1,yy,1,0),newlit(x,y,4,1),outclause();
|
||||
applit(x2,yy,1,0),newlit(x,y,4,1),outclause();
|
||||
applit(x1,yy,1,0),applit(x2,yy,1,0),newlit(x,y,4,2),outclause();
|
||||
applit(x1,yy,0,0),applit(x2,yy,0,0),newcomplit(x,y,4,1),outclause();
|
||||
applit(x1,yy,0,0),newcomplit(x,y,4,2),outclause();
|
||||
if (yy>=ymin && yy<=ymax)
|
||||
applit(x2,yy,0,0),newcomplit(x,y,4,2),outclause();
|
||||
have_d[x][y]=tt+1;
|
||||
}
|
||||
}
|
||||
@#
|
||||
void e(int x,int y) {
|
||||
register x1=x-1,x2=x,yy=y-1;
|
||||
if (have_e[x][y]!=tt+1) {
|
||||
applit(x1,yy,1,0),newlit(x,y,5,1),outclause();
|
||||
applit(x2,yy,1,0),newlit(x,y,5,1),outclause();
|
||||
applit(x1,yy,1,0),applit(x2,yy,1,0),newlit(x,y,5,2),outclause();
|
||||
applit(x1,yy,0,0),applit(x2,yy,0,0),newcomplit(x,y,5,1),outclause();
|
||||
applit(x1,yy,0,0),newcomplit(x,y,5,2),outclause();
|
||||
if (yy>=ymin && yy<=ymax)
|
||||
applit(x2,yy,0,0),newcomplit(x,y,5,2),outclause();
|
||||
have_e[x][y]=tt+1;
|
||||
}
|
||||
}
|
||||
|
||||
@ The |f| subroutine can't be shared quite so often. But we
|
||||
do save a factor of~2, because $x+y$ is always even.
|
||||
|
||||
@<Sub...@>=
|
||||
void f(int x,int y) {
|
||||
register xx=x-1,y1=y,y2=y+1;
|
||||
if (have_f[x][y]!=tt+1) {
|
||||
applit(xx,y1,1,0),newlit(x,y,6,1),outclause();
|
||||
applit(xx,y2,1,0),newlit(x,y,6,1),outclause();
|
||||
applit(xx,y1,1,0),applit(xx,y2,1,0),newlit(x,y,6,2),outclause();
|
||||
applit(xx,y1,0,0),applit(xx,y2,0,0),newcomplit(x,y,6,1),outclause();
|
||||
applit(xx,y1,0,0),newcomplit(x,y,6,2),outclause();
|
||||
if (xx>=xmin && xx<=xmax)
|
||||
applit(xx,y2,0,0),newcomplit(x,y,6,2),outclause();
|
||||
have_f[x][y]=tt+1;
|
||||
}
|
||||
}
|
||||
|
||||
@ The |g| subroutine cleans up the dregs, by somewhat tediously
|
||||
locating the two neighbors that weren't handled by |d|, |e|, or~|f|.
|
||||
No sharing is possible here.
|
||||
|
||||
@<Sub...@>=
|
||||
void g(int x,int y) {
|
||||
register x1,x2,y1,y2;
|
||||
if (x&1) x1=x-1,y1=y,x2=x+1,y2=y^1;
|
||||
else x1=x+1,y1=y,x2=x-1,y2=y-1+((y&1)<<1);
|
||||
applit(x1,y1,1,0),newlit(x,y,7,1),outclause();
|
||||
applit(x2,y2,1,0),newlit(x,y,7,1),outclause();
|
||||
applit(x1,y1,1,0),applit(x2,y2,1,0),newlit(x,y,7,2),outclause();
|
||||
applit(x1,y1,0,0),applit(x2,y2,0,0),newcomplit(x,y,7,1),outclause();
|
||||
applit(x1,y1,0,0),newcomplit(x,y,7,2),outclause();
|
||||
applit(x2,y2,0,0),newcomplit(x,y,7,2),outclause();
|
||||
}
|
||||
|
||||
@ Fortunately the |b| subroutine {\it can\/} be shared (since |x| is always
|
||||
odd), thus saving half of the sixteen clauses generated.
|
||||
|
||||
@<Sub...@>=
|
||||
void b(int x,int y) {
|
||||
register j,k,xx=x,y1=y-(y&2),y2=y+(y&2);
|
||||
if (have_b[x][y]!=tt+1) {
|
||||
d(xx,y1);
|
||||
e(xx,y2);
|
||||
for (j=0;j<3;j++) for (k=0;k<3;k++) if (j+k) {
|
||||
if (j) newcomplit(xx,y1,4,j); /* $\bar d_j$ */
|
||||
if (k) newcomplit(xx,y2,5,k); /* $\bar e_k$ */
|
||||
newlit(x,y,2,j+k); /* $b_{j+k}$ */
|
||||
outclause();
|
||||
if (j) newlit(xx,y1,4,3-j); /* $d_{3-j}$ */
|
||||
if (k) newlit(xx,y2,5,3-k); /* $e_{3-k}$ */
|
||||
newcomplit(x,y,2,5-j-k); /* $\bar b_{5-j-k}$ */
|
||||
outclause();
|
||||
}
|
||||
have_b[x][y]=tt+1;
|
||||
}
|
||||
}
|
||||
|
||||
@ The (unshared) |c| subroutine handles the other four neighbors,
|
||||
by working with |f| and |g| instead of |d| and~|e|.
|
||||
|
||||
If |y=0|, the overlap rules set |y1=-1|, which can be problematic.
|
||||
I've decided to avoid this case by omitting |f| when it is
|
||||
guaranteed to be zero.
|
||||
|
||||
@<Sub...@>=
|
||||
void c(int x,int y) {
|
||||
register j,k,x1,y1;
|
||||
if (x&1) x1=x+2,y1=(y-1)|1;
|
||||
else x1=x,y1=y&-2;
|
||||
g(x,y);
|
||||
if (x1-1<xmin || x1-1>xmax || y1+1<ymin || y1>ymax)
|
||||
@<Set |c| equal to |g|@>@;
|
||||
else {
|
||||
f(x1,y1);
|
||||
for (j=0;j<3;j++) for (k=0;k<3;k++) if (j+k) {
|
||||
if (j) newcomplit(x1,y1,6,j); /* $\bar f_j$ */
|
||||
if (k) newcomplit(x,y,7,k); /* $\bar g_k$ */
|
||||
newlit(x,y,3,j+k); /* $c_{j+k}$ */
|
||||
outclause();
|
||||
if (j) newlit(x1,y1,6,3-j); /* $f_{3-j}$ */
|
||||
if (k) newlit(x,y,7,3-k); /* $g_{3-k}$ */
|
||||
newcomplit(x,y,3,5-j-k); /* $\bar c_{5-j-k}$ */
|
||||
outclause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ @<Set |c| equal to |g|@>=
|
||||
{
|
||||
for (k=1;k<3;k++) {
|
||||
newcomplit(x,y,7,k),newlit(x,y,3,k),outclause(); /* $\bar g_k\lor c_k$ */
|
||||
newlit(x,y,7,k),newcomplit(x,y,3,k),outclause(); /* $g_k\lor\bar c_k$ */
|
||||
}
|
||||
newcomplit(x,y,3,3),outclause(); /* $\bar c_3$ */
|
||||
newcomplit(x,y,3,4),outclause(); /* $\bar c_4$ */
|
||||
}
|
||||
|
||||
@ Totals over all eight neighbors are then deduced by the |a|
|
||||
subroutine.
|
||||
|
||||
@<Sub...@>=
|
||||
void a(int x,int y) {
|
||||
register j,k,xx=x|1;
|
||||
b(xx,y);
|
||||
c(x,y);
|
||||
for (j=0;j<5;j++) for (k=0;k<5;k++) if (j+k>1 && j+k<5) {
|
||||
if (j) newcomplit(xx,y,2,j); /* $\bar b_j$ */
|
||||
if (k) newcomplit(x,y,3,k); /* $\bar c_k$ */
|
||||
newlit(x,y,1,j+k); /* $a_{j+k}$ */
|
||||
outclause();
|
||||
}
|
||||
for (j=0;j<5;j++) for (k=0;k<5;k++) if (j+k>2 && j+k<6 && j*k) {
|
||||
if (j) newlit(xx,y,2,j); /* $b_j$ */
|
||||
if (k) newlit(x,y,3,k); /* $c_k$ */
|
||||
newcomplit(x,y,1,j+k-1); /* $\bar a_{j+k-1}$ */
|
||||
outclause();
|
||||
}
|
||||
}
|
||||
|
||||
@ Finally, as mentioned at the beginning, $z'$ is determined
|
||||
from $z$, $a_2$, $a_3$, and $a_4$.
|
||||
|
||||
I actually generate six clauses, not five, in order to stick to
|
||||
{\mc 3SAT}.
|
||||
|
||||
@<Sub...@>=
|
||||
void zprime(int x,int y) {
|
||||
newcomplit(x,y,1,4),applit(x,y,1,1),outclause(); /* $\bar a_4\bar z'$ */
|
||||
newlit(x,y,1,2),applit(x,y,1,1),outclause(); /* $a_2\bar z'$ */
|
||||
newlit(x,y,1,3),applit(x,y,0,0),applit(x,y,1,1),outclause();
|
||||
/* $a_3z\bar z'$ */
|
||||
newcomplit(x,y,1,3),newlit(x,y,1,4),applit(x,y,0,1),outclause();
|
||||
/* $\bar a_3a_4z'$ */
|
||||
applit(x,y,0,7),newcomplit(x,y,1,2),newlit(x,y,1,4),outclause();
|
||||
/* $x\bar a_2a_4$ */
|
||||
applit(x,y,1,7),applit(x,y,1,0),applit(x,y,0,1),outclause();
|
||||
/* $\bar x\bar zz'$ */
|
||||
}
|
||||
|
||||
@*Index.
|
||||
24
samples/Closure Templates/example.soy
Normal file
24
samples/Closure Templates/example.soy
Normal file
@@ -0,0 +1,24 @@
|
||||
{namespace Exmaple}
|
||||
|
||||
/**
|
||||
* Example
|
||||
*/
|
||||
{template .foo}
|
||||
{@param count: string}
|
||||
{@param? name: int}
|
||||
|
||||
{if isNonnull($name)}
|
||||
<h1>{$name}</h1>
|
||||
{/if}
|
||||
|
||||
<div class="content">
|
||||
{switch count}
|
||||
{case 0}
|
||||
{call Empty.view}
|
||||
{param count: $count /}
|
||||
{/call}
|
||||
{default}
|
||||
<h2>Wow, so many!</h2>
|
||||
{/switch}
|
||||
</div>
|
||||
{/template}
|
||||
File diff suppressed because it is too large
Load Diff
20
samples/Easybuild/bzip2-1.0.6-GCC-4.9.2.eb
Normal file
20
samples/Easybuild/bzip2-1.0.6-GCC-4.9.2.eb
Normal file
@@ -0,0 +1,20 @@
|
||||
# not really (there's an EB_bzip2 easyblock), but fine for use in unit tests
|
||||
easyblock = 'ConfigureMake'
|
||||
|
||||
name = 'bzip2'
|
||||
version = '1.0.6'
|
||||
|
||||
homepage = 'http://www.bzip.org/'
|
||||
description = """bzip2 is a freely available, patent free, high-quality data compressor. It typically
|
||||
compresses files to within 10% to 15% of the best available techniques (the PPM family of statistical
|
||||
compressors), whilst being around twice as fast at compression and six times faster at decompression."""
|
||||
|
||||
toolchain = {'name': 'GCC', 'version': '4.9.2'}
|
||||
toolchainopts = {'pic': True}
|
||||
|
||||
sources = [SOURCE_TAR_GZ]
|
||||
source_urls = ['http://www.bzip.org/%(version)s']
|
||||
|
||||
builddependencies = [('gzip', '1.6')]
|
||||
|
||||
moduleclass = 'tools'
|
||||
97
samples/Fantom/sample1.fan
Normal file
97
samples/Fantom/sample1.fan
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Author: Robert Koeninger
|
||||
* License: WTFPL (http://www.wtfpl.net/)
|
||||
*/
|
||||
|
||||
class Spelling {
|
||||
|
||||
** Load sample text and offer corrections for input
|
||||
static Void main(Str[] args) {
|
||||
text := File.os("big.txt").readAllStr
|
||||
counts := Str:Int[:] { def = 0 }
|
||||
text.split.each |word| { counts[word] += 1 }
|
||||
args.each |arg| { echo(correction(counts, arg)) }
|
||||
}
|
||||
|
||||
static const Range letters := Range.makeInclusive(97, 122)
|
||||
|
||||
** Most probable spelling correction for `word`.
|
||||
static Str correction(Str:Int counts, Str word) {
|
||||
candidates(counts, word).max |x, y| { counts[x] <=> counts[y] }
|
||||
}
|
||||
|
||||
** Generate possible spelling corrections for `word`.
|
||||
static Str[] candidates(Str:Int counts, Str word) {
|
||||
result := known(counts, Str[word])
|
||||
if (result.size > 0) return result
|
||||
|
||||
result = known(counts, edits1(word))
|
||||
if (result.size > 0) return result
|
||||
|
||||
result = known(counts, edits2(word))
|
||||
if (result.size > 0) return result
|
||||
|
||||
return Str[word]
|
||||
}
|
||||
|
||||
** The subset of `words` that appear in the map of `counts`.
|
||||
static Str[] known(Str:Int counts, Str[] words) {
|
||||
words.findAll |word, i| { counts[word] > 0 }.unique
|
||||
}
|
||||
|
||||
** All edits that are one edit away from `word`.
|
||||
static Str[] edits1(Str word) {
|
||||
edits := Str[,]
|
||||
|
||||
for (i := 0; i < word.size; ++i) {
|
||||
edits.add(delete(word, i))
|
||||
|
||||
if (i < word.size - 2) {
|
||||
edits.add(transpose(word, i))
|
||||
}
|
||||
|
||||
edits.addAll(replace(word, i))
|
||||
edits.addAll(insert(word, i))
|
||||
}
|
||||
|
||||
edits = edits.unique
|
||||
edits.remove(word)
|
||||
return edits
|
||||
}
|
||||
|
||||
** Word with `i`th letter removed.
|
||||
static Str delete(Str word, Int i) {
|
||||
left := word.getRange(Range.makeExclusive(0, i))
|
||||
right := word.getRange(Range.makeExclusive(i + 1, word.size))
|
||||
return left + right
|
||||
}
|
||||
|
||||
** Word with `i`th and `i+1`st letter swapped.
|
||||
static Str transpose(Str word, Int i) {
|
||||
left := word.getRange(Range.makeExclusive(0, i))
|
||||
right := word.getRange(Range.makeExclusive(i, word.size))
|
||||
first := right.get(0).toChar
|
||||
second := right.get(1).toChar
|
||||
rest := right.getRange(Range.makeExclusive(2, right.size))
|
||||
return left + second + first + rest
|
||||
}
|
||||
|
||||
** Word with `i`th letter replaced with every other letter.
|
||||
static Str[] replace(Str word, Int i) {
|
||||
left := word.getRange(Range.makeExclusive(0, i))
|
||||
right := word.getRange(Range.makeExclusive(i + 1, word.size))
|
||||
return letters.map |ch| { left + ch.toChar + right }
|
||||
}
|
||||
|
||||
** Word with each letter inserted at `i`.
|
||||
static Str[] insert(Str word, Int i) {
|
||||
left := word.getRange(Range.makeExclusive(0, i))
|
||||
right := word.getRange(Range.makeExclusive(i, word.size))
|
||||
return letters.map |ch| { left + ch.toChar + right }
|
||||
}
|
||||
|
||||
** All edits that are two edits away from `word`.
|
||||
static Str[] edits2(Str word) {
|
||||
(Str[])(edits1(word).map |w| { edits1(w) }.flatten)
|
||||
}
|
||||
}
|
||||
50
samples/Fantom/sample2.fan
Normal file
50
samples/Fantom/sample2.fan
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Author: Robert Koeninger
|
||||
* License: WTFPL (http://www.wtfpl.net/)
|
||||
*/
|
||||
|
||||
mixin Expr
|
||||
{
|
||||
abstract Obj? eval()
|
||||
}
|
||||
|
||||
class Constant : Expr
|
||||
{
|
||||
Obj? value
|
||||
|
||||
new make(Obj? value) { this.value = value }
|
||||
override Obj? eval() { value }
|
||||
}
|
||||
|
||||
enum class Op
|
||||
{
|
||||
plus,
|
||||
minus
|
||||
}
|
||||
|
||||
class Infix : Expr
|
||||
{
|
||||
Op op
|
||||
Expr left
|
||||
Expr right
|
||||
|
||||
new make(Op op, Expr left, Expr right)
|
||||
{
|
||||
this.op = op
|
||||
this.left = left
|
||||
this.right = right
|
||||
}
|
||||
|
||||
override Obj? eval()
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case Op.plus:
|
||||
return (Int)left.eval() + (Int)right.eval()
|
||||
case Op.minus:
|
||||
return (Int)left.eval() - (Int)right.eval()
|
||||
default:
|
||||
throw Err("undefined Op")
|
||||
}
|
||||
}
|
||||
}
|
||||
98
samples/GLSL/pntriangles.tesc
Normal file
98
samples/GLSL/pntriangles.tesc
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Sascha Willems
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
// PN patch data
|
||||
struct PnPatch
|
||||
{
|
||||
float b210;
|
||||
float b120;
|
||||
float b021;
|
||||
float b012;
|
||||
float b102;
|
||||
float b201;
|
||||
float b111;
|
||||
float n110;
|
||||
float n011;
|
||||
float n101;
|
||||
};
|
||||
|
||||
// tessellation levels
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
float tessLevel;
|
||||
} ubo;
|
||||
|
||||
layout(vertices=3) out;
|
||||
|
||||
layout(location = 0) in vec3 inNormal[];
|
||||
layout(location = 1) in vec2 inUV[];
|
||||
|
||||
layout(location = 0) out vec3 outNormal[3];
|
||||
layout(location = 3) out vec2 outUV[3];
|
||||
layout(location = 6) out PnPatch outPatch[3];
|
||||
|
||||
float wij(int i, int j)
|
||||
{
|
||||
return dot(gl_in[j].gl_Position.xyz - gl_in[i].gl_Position.xyz, inNormal[i]);
|
||||
}
|
||||
|
||||
float vij(int i, int j)
|
||||
{
|
||||
vec3 Pj_minus_Pi = gl_in[j].gl_Position.xyz
|
||||
- gl_in[i].gl_Position.xyz;
|
||||
vec3 Ni_plus_Nj = inNormal[i]+inNormal[j];
|
||||
return 2.0*dot(Pj_minus_Pi, Ni_plus_Nj)/dot(Pj_minus_Pi, Pj_minus_Pi);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// get data
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
outNormal[gl_InvocationID] = inNormal[gl_InvocationID];
|
||||
outUV[gl_InvocationID] = inUV[gl_InvocationID];
|
||||
|
||||
// set base
|
||||
float P0 = gl_in[0].gl_Position[gl_InvocationID];
|
||||
float P1 = gl_in[1].gl_Position[gl_InvocationID];
|
||||
float P2 = gl_in[2].gl_Position[gl_InvocationID];
|
||||
float N0 = inNormal[0][gl_InvocationID];
|
||||
float N1 = inNormal[1][gl_InvocationID];
|
||||
float N2 = inNormal[2][gl_InvocationID];
|
||||
|
||||
// compute control points
|
||||
outPatch[gl_InvocationID].b210 = (2.0*P0 + P1 - wij(0,1)*N0)/3.0;
|
||||
outPatch[gl_InvocationID].b120 = (2.0*P1 + P0 - wij(1,0)*N1)/3.0;
|
||||
outPatch[gl_InvocationID].b021 = (2.0*P1 + P2 - wij(1,2)*N1)/3.0;
|
||||
outPatch[gl_InvocationID].b012 = (2.0*P2 + P1 - wij(2,1)*N2)/3.0;
|
||||
outPatch[gl_InvocationID].b102 = (2.0*P2 + P0 - wij(2,0)*N2)/3.0;
|
||||
outPatch[gl_InvocationID].b201 = (2.0*P0 + P2 - wij(0,2)*N0)/3.0;
|
||||
float E = ( outPatch[gl_InvocationID].b210
|
||||
+ outPatch[gl_InvocationID].b120
|
||||
+ outPatch[gl_InvocationID].b021
|
||||
+ outPatch[gl_InvocationID].b012
|
||||
+ outPatch[gl_InvocationID].b102
|
||||
+ outPatch[gl_InvocationID].b201 ) / 6.0;
|
||||
float V = (P0 + P1 + P2)/3.0;
|
||||
outPatch[gl_InvocationID].b111 = E + (E - V)*0.5;
|
||||
outPatch[gl_InvocationID].n110 = N0+N1-vij(0,1)*(P1-P0);
|
||||
outPatch[gl_InvocationID].n011 = N1+N2-vij(1,2)*(P2-P1);
|
||||
outPatch[gl_InvocationID].n101 = N2+N0-vij(2,0)*(P0-P2);
|
||||
|
||||
// set tess levels
|
||||
gl_TessLevelOuter[gl_InvocationID] = ubo.tessLevel;
|
||||
gl_TessLevelInner[0] = ubo.tessLevel;
|
||||
}
|
||||
103
samples/GLSL/pntriangles.tese
Normal file
103
samples/GLSL/pntriangles.tese
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Sascha Willems
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
// PN patch data
|
||||
struct PnPatch
|
||||
{
|
||||
float b210;
|
||||
float b120;
|
||||
float b021;
|
||||
float b012;
|
||||
float b102;
|
||||
float b201;
|
||||
float b111;
|
||||
float n110;
|
||||
float n011;
|
||||
float n101;
|
||||
};
|
||||
|
||||
layout (binding = 1) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
float tessAlpha;
|
||||
} ubo;
|
||||
|
||||
layout(triangles, fractional_odd_spacing, ccw) in;
|
||||
|
||||
layout(location = 0) in vec3 iNormal[];
|
||||
layout(location = 3) in vec2 iTexCoord[];
|
||||
layout(location = 6) in PnPatch iPnPatch[];
|
||||
|
||||
layout(location = 0) out vec3 oNormal;
|
||||
layout(location = 1) out vec2 oTexCoord;
|
||||
|
||||
#define uvw gl_TessCoord
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 uvwSquared = uvw * uvw;
|
||||
vec3 uvwCubed = uvwSquared * uvw;
|
||||
|
||||
// extract control points
|
||||
vec3 b210 = vec3(iPnPatch[0].b210, iPnPatch[1].b210, iPnPatch[2].b210);
|
||||
vec3 b120 = vec3(iPnPatch[0].b120, iPnPatch[1].b120, iPnPatch[2].b120);
|
||||
vec3 b021 = vec3(iPnPatch[0].b021, iPnPatch[1].b021, iPnPatch[2].b021);
|
||||
vec3 b012 = vec3(iPnPatch[0].b012, iPnPatch[1].b012, iPnPatch[2].b012);
|
||||
vec3 b102 = vec3(iPnPatch[0].b102, iPnPatch[1].b102, iPnPatch[2].b102);
|
||||
vec3 b201 = vec3(iPnPatch[0].b201, iPnPatch[1].b201, iPnPatch[2].b201);
|
||||
vec3 b111 = vec3(iPnPatch[0].b111, iPnPatch[1].b111, iPnPatch[2].b111);
|
||||
|
||||
// extract control normals
|
||||
vec3 n110 = normalize(vec3(iPnPatch[0].n110, iPnPatch[1].n110, iPnPatch[2].n110));
|
||||
vec3 n011 = normalize(vec3(iPnPatch[0].n011, iPnPatch[1].n011, iPnPatch[2].n011));
|
||||
vec3 n101 = normalize(vec3(iPnPatch[0].n101, iPnPatch[1].n101, iPnPatch[2].n101));
|
||||
|
||||
// compute texcoords
|
||||
oTexCoord = gl_TessCoord[2]*iTexCoord[0] + gl_TessCoord[0]*iTexCoord[1] + gl_TessCoord[1]*iTexCoord[2];
|
||||
|
||||
// normal
|
||||
// Barycentric normal
|
||||
vec3 barNormal = gl_TessCoord[2]*iNormal[0] + gl_TessCoord[0]*iNormal[1] + gl_TessCoord[1]*iNormal[2];
|
||||
vec3 pnNormal = iNormal[0]*uvwSquared[2] + iNormal[1]*uvwSquared[0] + iNormal[2]*uvwSquared[1]
|
||||
+ n110*uvw[2]*uvw[0] + n011*uvw[0]*uvw[1]+ n101*uvw[2]*uvw[1];
|
||||
oNormal = ubo.tessAlpha*pnNormal + (1.0-ubo.tessAlpha) * barNormal;
|
||||
|
||||
// compute interpolated pos
|
||||
vec3 barPos = gl_TessCoord[2]*gl_in[0].gl_Position.xyz
|
||||
+ gl_TessCoord[0]*gl_in[1].gl_Position.xyz
|
||||
+ gl_TessCoord[1]*gl_in[2].gl_Position.xyz;
|
||||
|
||||
// save some computations
|
||||
uvwSquared *= 3.0;
|
||||
|
||||
// compute PN position
|
||||
vec3 pnPos = gl_in[0].gl_Position.xyz*uvwCubed[2]
|
||||
+ gl_in[1].gl_Position.xyz*uvwCubed[0]
|
||||
+ gl_in[2].gl_Position.xyz*uvwCubed[1]
|
||||
+ b210*uvwSquared[2]*uvw[0]
|
||||
+ b120*uvwSquared[0]*uvw[2]
|
||||
+ b201*uvwSquared[2]*uvw[1]
|
||||
+ b021*uvwSquared[0]*uvw[1]
|
||||
+ b102*uvwSquared[1]*uvw[2]
|
||||
+ b012*uvwSquared[1]*uvw[0]
|
||||
+ b111*6.0*uvw[0]*uvw[1]*uvw[2];
|
||||
|
||||
// final position and normal
|
||||
vec3 finalPos = (1.0-ubo.tessAlpha)*barPos + ubo.tessAlpha*pnPos;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(finalPos,1.0);
|
||||
}
|
||||
176
samples/MAXScript/rolloutCreator.ms
Normal file
176
samples/MAXScript/rolloutCreator.ms
Normal file
@@ -0,0 +1,176 @@
|
||||
-------------------------------------------------------------------------------
|
||||
--
|
||||
-- File: rolloutCreator.ms
|
||||
-- Description: Localization friendly helper struct for dynamically creating rollouts
|
||||
-- By: Ravi Karra [Discreet] ravi.karra@discreet.com
|
||||
--
|
||||
-- Version: 1.01
|
||||
-- Version: 1.02 - Larry Minton [Discreet]
|
||||
-- changed <string1> += <string2> to append string1 string2
|
||||
-- added addText method
|
||||
-- Declarations:
|
||||
/*
|
||||
rolloutCreator <rollout_name> <rollout_caption> [width:] [height:]
|
||||
creates an instance of rolloutCreator, assign it to a variable
|
||||
width - width of the rollout/dialog to be created
|
||||
height - of the rollout/dialog to be created
|
||||
|
||||
eg:
|
||||
rci = rolloutCreator "myRollout" "My Rollout"
|
||||
|
||||
|
||||
.begin()
|
||||
this function needs to be called immediately after the instance is created, this does the initialization
|
||||
|
||||
.addLocal <local_name> [init:]
|
||||
<local_name>
|
||||
name of the local
|
||||
|
||||
[init:]
|
||||
what the local should be initialized to
|
||||
|
||||
.addControl <control_type> <control_name> <control_caption> [paramStr:<string>] =
|
||||
adds a control to the rollout
|
||||
|
||||
<control_type>
|
||||
can be any of named rolloutControls eg: #button, #spinner, #activeXControl etc
|
||||
|
||||
<control_name>
|
||||
variable name of the control by which it is referred eg: #btnButton
|
||||
|
||||
<control_caption>
|
||||
caption of the control "My Button"
|
||||
|
||||
[paramStr:]
|
||||
an optional string representation of all the keyword parameters that needs to be passed to the control
|
||||
eg: "width:100 height:20 align:#right"
|
||||
|
||||
eg:
|
||||
rci.addControl #button #myButton "My Button"
|
||||
|
||||
.addHandler <control_name> <event_type> [paramStr:<string>] [codeStr:<string>] [filter:<boolean>]
|
||||
adds an event handler for the controls previously added
|
||||
|
||||
<control_name>
|
||||
the variable passed during the control creation
|
||||
|
||||
<event_type>
|
||||
any of the events supported by the control, eg: #changed, #pressed, #selected
|
||||
|
||||
[paramStr:<string>]
|
||||
an optional string representation of all the positional and keyword parameters that are passed to the event
|
||||
|
||||
[codeStr:<string>]
|
||||
a string representation of the event handler code, if the string contains sub-strings, enclose them in two character '@'
|
||||
and pass on\true for the filter: parameter
|
||||
|
||||
[filter:<boolean>]
|
||||
if true, converts '@' to quote in codeStr
|
||||
|
||||
eg:
|
||||
rci.addHandler #myButton #pressed codeStr:"MessageBox @Hey@" filter:on
|
||||
will add an event handler for button named "myButton". When the button is clicked, messagebox pops up with text "hey" in it.
|
||||
|
||||
.addText <string> [filter:<boolean>]
|
||||
adds string to rollout definition. Typically used for function definitions.
|
||||
|
||||
[filter:<boolean>]
|
||||
if true, converts '@' to quote in string
|
||||
|
||||
.end()
|
||||
this function has to be called whenever all the required control and their event handler's are called. This function forms
|
||||
the rollout string, evaluates it and returns the definition which can passed to createDialog and addRollout functions.
|
||||
|
||||
Complete Example:
|
||||
rci = rolloutCreator "myRollout" "My Rollout"
|
||||
rci.begin()
|
||||
rci.addControl #button #myButton "My Button"
|
||||
rci.addHandler #myButton #pressed filter:on codeStr:"MessageBox @Isn't this cool@ title:@Wow@"
|
||||
createDialog (rci.end())
|
||||
*/
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __rcCounter == undefined then global __rcCounter = 0
|
||||
struct rolloutCreator
|
||||
(
|
||||
-- variables
|
||||
name, caption, str, def, width, height, quote="\"",
|
||||
|
||||
-- functions
|
||||
fn begin =
|
||||
(
|
||||
if name == undefined then
|
||||
(
|
||||
__rcCounter += 1
|
||||
name = "rolloutCreator" + __rcCounter as string
|
||||
)
|
||||
if caption == undefined then caption = ""
|
||||
str = ""
|
||||
),
|
||||
|
||||
fn addLocal name init: =
|
||||
(
|
||||
local dStr = "\tlocal " + name as string
|
||||
if init != unsupplied then append dStr (" = " + init as string)
|
||||
append dStr "\n"
|
||||
append str dStr
|
||||
),
|
||||
|
||||
fn addControl type name caption paramStr:"" =
|
||||
(
|
||||
append str ("\t" + type as string + " " + name as string + " " + quote + caption + quote + paramStr + "\n")
|
||||
),
|
||||
|
||||
fn strFilter codeStr =
|
||||
(
|
||||
local last_is_at = codeStr[codeStr.count] == "@"
|
||||
local fltStr = filterString codeStr "@"
|
||||
local rep = "\""
|
||||
codeStr = (if (codeStr[1] == "@") then rep else "") + fltStr[1]
|
||||
for i=2 to fltStr.count do
|
||||
(
|
||||
append codeStr (rep + fltStr[i])
|
||||
)
|
||||
if last_is_at then append codeStr rep
|
||||
codeStr
|
||||
),
|
||||
|
||||
fn addHandler ctrl event paramStr:"" filter:on codeStr:"" =
|
||||
(
|
||||
if filter do codeStr = (strFilter codeStr)
|
||||
append str ("\non " + ctrl as string + " " + event as string + " " + paramStr as string + " do \n(\n" + codeStr + ";ok\n)\n")
|
||||
),
|
||||
|
||||
fn addText txt filter:on =
|
||||
(
|
||||
if filter do txt = (strFilter txt )
|
||||
append str ("\t " + txt + "\n")
|
||||
),
|
||||
|
||||
fn end =
|
||||
(
|
||||
local dStr = "rollout " + name + " " + quote + caption + quote
|
||||
if width != undefined then
|
||||
append dStr (" width:" + width as string)
|
||||
if height != undefined then
|
||||
append dStr (" height:" + height as string)
|
||||
append dStr "\n(\n"
|
||||
append dStr str
|
||||
append dStr "\n)\n"
|
||||
str = dStr
|
||||
def = execute str
|
||||
)
|
||||
)
|
||||
|
||||
/*-- Usage
|
||||
-- Create an instance of the rolloutCreator passing the name and the caption
|
||||
rfTest = rolloutCreator "rfTestN" "rfTestC" --width:300 height:100
|
||||
-- Start creating the rollout
|
||||
rfTest.begin()
|
||||
rfTest.addControl #button #myButton "My Button" -- add a button
|
||||
-- rfTest.addHandler #myButton #pressed filter:on codeStr:"MessageBox @Hey@"
|
||||
rfTest.addHandler #myButton #pressed filter:on codeStr:"MessageBox @Look to the \@Light\@ thing@"
|
||||
rfTest.end()
|
||||
createDialog rfTest.def
|
||||
*/
|
||||
248
samples/Makefile/filenames/Makefile.wat
Normal file
248
samples/Makefile/filenames/Makefile.wat
Normal file
@@ -0,0 +1,248 @@
|
||||
#
|
||||
# The FreeType Project LICENSE
|
||||
# ----------------------------
|
||||
#
|
||||
# Copyright 1996-1999 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg
|
||||
#
|
||||
#
|
||||
#
|
||||
# Introduction
|
||||
# ============
|
||||
#
|
||||
# The FreeType Project is distributed in several archive packages;
|
||||
# some of them may contain, in addition to the FreeType font engine,
|
||||
# various tools and contributions which rely on, or relate to, the
|
||||
# FreeType Project.
|
||||
#
|
||||
# This license applies to all files found in such packages, and
|
||||
# which do not fall under their own explicit license. The license
|
||||
# affects thus the FreeType font engine, the test programs,
|
||||
# documentation and makefiles, at the very least.
|
||||
#
|
||||
# This license was inspired by the BSD, Artistic, and IJG
|
||||
# (Independent JPEG Group) licenses, which all encourage inclusion
|
||||
# and use of free software in commercial and freeware products
|
||||
# alike. As a consequence, its main points are that:
|
||||
#
|
||||
# o We don't promise that this software works. However, we are be
|
||||
# interested in any kind of bug reports. (`as is' distribution)
|
||||
#
|
||||
# o You can use this software for whatever you want, in parts or
|
||||
# full form, without having to pay us. (`royalty-free' usage)
|
||||
#
|
||||
# o You may not pretend that you wrote this software. If you use
|
||||
# it, or only parts of it, in a program, you must acknowledge
|
||||
# somewhere in your documentation that you've used the FreeType
|
||||
# code. (`credits')
|
||||
#
|
||||
# We specifically permit and encourage the inclusion of this
|
||||
# software, with or without modifications, in commercial products,
|
||||
# provided that all warranty or liability claims are assumed by the
|
||||
# product vendor.
|
||||
#
|
||||
#
|
||||
# Legal Terms
|
||||
# ===========
|
||||
#
|
||||
# 0. Definitions
|
||||
# --------------
|
||||
#
|
||||
# Throughout this license, the terms `package', `FreeType Project',
|
||||
# and `FreeType archive' refer to the set of files originally
|
||||
# distributed by the authors (David Turner, Robert Wilhelm, and
|
||||
# Werner Lemberg) as the `FreeType project', be they named as alpha,
|
||||
# beta or final release.
|
||||
#
|
||||
# `You' refers to the licensee, or person using the project, where
|
||||
# `using' is a generic term including compiling the project's source
|
||||
# code as well as linking it to form a `program' or `executable'.
|
||||
# This program is referred to as `a program using the FreeType
|
||||
# engine'.
|
||||
#
|
||||
# This license applies to all files distributed in the original
|
||||
# FreeType archive, including all source code, binaries and
|
||||
# documentation, unless otherwise stated in the file in its
|
||||
# original, unmodified form as distributed in the original archive.
|
||||
# If you are unsure whether or not a particular file is covered by
|
||||
# this license, you must contact us to verify this.
|
||||
#
|
||||
# The FreeType project is copyright (C) 1996-1999 by David Turner,
|
||||
# Robert Wilhelm, and Werner Lemberg. All rights reserved except as
|
||||
# specified below.
|
||||
#
|
||||
# 1. No Warranty
|
||||
# --------------
|
||||
#
|
||||
# THE FREETYPE ARCHIVE IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
|
||||
# KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
|
||||
# USE, OF THE FREETYPE PROJECT.
|
||||
#
|
||||
# As you have not signed this license, you are not required to
|
||||
# accept it. However, as the FreeType project is copyrighted
|
||||
# material, only this license, or another one contracted with the
|
||||
# authors, grants you the right to use, distribute, and modify it.
|
||||
# Therefore, by using, distributing, or modifying the FreeType
|
||||
# project, you indicate that you understand and accept all the terms
|
||||
# of this license.
|
||||
#
|
||||
# 2. Redistribution
|
||||
# -----------------
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# o Redistribution of source code must retain this license file
|
||||
# (`licence.txt') unaltered; any additions, deletions or changes
|
||||
# to the original files must be clearly indicated in
|
||||
# accompanying documentation. The copyright notices of the
|
||||
# unaltered, original files must be preserved in all copies of
|
||||
# source files.
|
||||
#
|
||||
# o Redistribution in binary form must provide a disclaimer that
|
||||
# states that the software is based in part of the work of the
|
||||
# FreeType Team, in the distribution documentation. We also
|
||||
# encourage you to put an URL to the FreeType web page in your
|
||||
# documentation, though this isn't mandatory.
|
||||
#
|
||||
# These conditions apply to any software derived from or based on
|
||||
# the FreeType code, not just the unmodified files. If you use our
|
||||
# work, you must acknowledge us. However, no fee need be paid to
|
||||
# us.
|
||||
#
|
||||
# 3. Advertising
|
||||
# --------------
|
||||
#
|
||||
# The names of FreeType's authors and contributors may not be used
|
||||
# to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# We suggest, but do not require, that you use one or more of the
|
||||
# following phrases to refer to this software in your documentation
|
||||
# or advertising materials: `FreeType Project', `FreeType Engine',
|
||||
# `FreeType library', or `FreeType Distribution'.
|
||||
#
|
||||
# 4. Contacts
|
||||
# -----------
|
||||
#
|
||||
# There are two mailing lists related to FreeType:
|
||||
#
|
||||
# o freetype@freetype.org
|
||||
#
|
||||
# Discusses general use and applications of FreeType, as well as
|
||||
# future and wanted additions to the library and distribution.
|
||||
# If you are looking for support, start in this list if you
|
||||
# haven't found anything to help you in the documentation.
|
||||
#
|
||||
# o devel@freetype.org
|
||||
#
|
||||
# Discusses bugs, as well as engine internals, design issues,
|
||||
# specific licenses, porting, etc.
|
||||
#
|
||||
# o http://www.freetype.org
|
||||
#
|
||||
# Holds the current FreeType web page, which will allow you to
|
||||
# download our latest development version and read online
|
||||
# documentation.
|
||||
#
|
||||
# You can also contact us individually at:
|
||||
#
|
||||
# David Turner <david.turner@freetype.org>
|
||||
# Robert Wilhelm <robert.wilhelm@freetype.org>
|
||||
# Werner Lemberg <werner.lemberg@freetype.org>
|
||||
#
|
||||
#
|
||||
# --- end of license ---
|
||||
#
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# This builds the Watcom library with Watcom's wcc386 under OS/2.
|
||||
#
|
||||
# You'll need Watcom's wmake.
|
||||
#
|
||||
#
|
||||
# Invoke by "wmake -f arch\os2\Makefile.wat" when in the "lib" directory
|
||||
#
|
||||
# This will build "freetype\lib\libttf.lib"
|
||||
|
||||
ARCH = arch\os2
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.wat
|
||||
FT_MAKE = wmake -h
|
||||
|
||||
|
||||
.EXTENSIONS:
|
||||
.EXTENSIONS: .lib .obj .c .h
|
||||
.obj:.;.\extend;.\$(ARCH)
|
||||
.c:.;.\extend;.\$(ARCH)
|
||||
.h:.;.\extend;.\$(ARCH)
|
||||
|
||||
CC = wcc386
|
||||
|
||||
CCFLAGS = /otexanl+ /s /w5 /zq -Iarch\os2 -I. -Iextend
|
||||
|
||||
TTFILE = .\ttfile.c
|
||||
TTMEMORY = .\ttmemory.c
|
||||
TTMUTEX = .\ttmutex.c
|
||||
|
||||
TTFILE_OBJ = ttfile.obj
|
||||
TTMEMORY_OBJ = ttmemory.obj
|
||||
TTMUTEX_OBJ = ttmutex.obj
|
||||
|
||||
PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX)
|
||||
PORT_OBJS = $(TTFILE_OBJ) $(TTMEMORY_OBJ) $(TTMUTEX_OBJ)
|
||||
|
||||
SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c &
|
||||
extend\ftxcmap.c extend\ftxwidth.c extend\ftxsbit.c &
|
||||
extend\ftxgsub.c extend\ftxgpos.c extend\ftxopen.c &
|
||||
extend\ftxgdef.c
|
||||
|
||||
OBJS_X = extend\ftxgasp.obj extend\ftxkern.obj extend\ftxpost.obj &
|
||||
extend\ftxcmap.obj extend\ftxwidth.obj extend\ftxsbit.obj &
|
||||
extend\ftxgsub.obj extend\ftxgpos.obj extend\ftxopen.obj &
|
||||
extend\ftxgdef.obj
|
||||
|
||||
SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c &
|
||||
ttgload.c ttinterp.c ttload.c ttobjs.c &
|
||||
ttraster.c ttextend.c $(PORT)
|
||||
|
||||
OBJS_M = ttapi.obj ttcache.obj ttcalc.obj ttcmap.obj &
|
||||
ttgload.obj ttinterp.obj ttload.obj ttobjs.obj &
|
||||
ttraster.obj ttextend.obj $(PORT_OBJS) $(OBJS_X)
|
||||
|
||||
SRC_S = freetype.c
|
||||
OBJ_S = freetype.obj
|
||||
OBJS_S = $(OBJ_S) $(OBJS_X)
|
||||
|
||||
|
||||
.c.obj:
|
||||
$(CC) $(CCFLAGS) $[* /fo=$[*.obj
|
||||
|
||||
all: .symbolic
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) libttf.lib
|
||||
|
||||
debug: .symbolic
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJS_M)" libttf.lib
|
||||
|
||||
|
||||
libttf.lib: $(OBJS_M)
|
||||
wlib -q -n libttf.lib $(OBJS_M)
|
||||
|
||||
# is this correct? Know nothing about wmake and the Watcom compiler...
|
||||
$(OBJ_S): $(SRC_S) $(SRC_M)
|
||||
$(CC) $(CCFLAGS) $(SRC_S) /fo=$(OBJ_S)
|
||||
|
||||
clean: .symbolic
|
||||
@-erase $(OBJS_M)
|
||||
@-erase *.err
|
||||
|
||||
distclean: .symbolic clean
|
||||
@-erase libttf.lib
|
||||
|
||||
new: .symbolic
|
||||
@-wtouch *.c
|
||||
|
||||
# end of Makefile.wat
|
||||
59
samples/Pan/ceph-raid.pan
Normal file
59
samples/Pan/ceph-raid.pan
Normal file
@@ -0,0 +1,59 @@
|
||||
unique template site/filesystems/ceph-raid;
|
||||
|
||||
prefix '/system/blockdevices';
|
||||
|
||||
variable CEPH_OSD_DISKS = {
|
||||
# SAS disks partitions
|
||||
disks = list();
|
||||
foreach (disk; data; value('/hardware/harddisks')) {
|
||||
if (data['capacity'] > 1000 * GB) {
|
||||
append(disks, disk);
|
||||
};
|
||||
};
|
||||
disks;
|
||||
};
|
||||
|
||||
'partitions' = {
|
||||
foreach (idx; disk; CEPH_OSD_DISKS) {
|
||||
partitions_add(
|
||||
disk, dict(
|
||||
format('%s1', disk), 10 * GB,
|
||||
format('%s2', disk), 5 * GB,
|
||||
format('%s3', disk), -1));
|
||||
SELF[format('%s1', disk)]['offset'] = 1;
|
||||
};
|
||||
SELF;
|
||||
};
|
||||
|
||||
#raid for data
|
||||
'md' = {
|
||||
for (i = 0; i < length(CEPH_OSD_DISKS); i = i + 2) {
|
||||
for (j = 2; j <= 3; j = j + 1) {
|
||||
SELF[escape(format('md/%s0%s%d', CEPH_OSD_DISKS[i], CEPH_OSD_DISKS[i+1], j ))] = dict(
|
||||
"device_list", list(format('partitions/%s%d', CEPH_OSD_DISKS[i], j), format('partitions/%s%d', CEPH_OSD_DISKS[i+1], j)),
|
||||
"raid_level", 'RAID0',
|
||||
"metadata", '1.2',
|
||||
);
|
||||
};
|
||||
};
|
||||
SELF;
|
||||
};
|
||||
|
||||
# ceph OSD and journal fs
|
||||
'/system/filesystems' = {
|
||||
# ga over software raids..
|
||||
foreach (disk; data; value('/system/blockdevices/md')) { #check for data part/disk
|
||||
if (match(unescape(disk), '^md/.+0.+3$')) {
|
||||
append(merge(CEPH_FSOPTS_BASE, CEPH_DISK_OPTIONS[CEPH_FS], dict(
|
||||
'mountpoint', format('/var/lib/ceph/osd/%s', replace('md/([a-z0A-Z]+)[0-9]*$', '$1', unescape(disk))),
|
||||
'block_device', format('md/%s', disk),
|
||||
)));
|
||||
} else if (match(unescape(disk), '^md/.+0.+2$')) {
|
||||
append(merge(CEPH_FSOPTS_DUMMY, dict(
|
||||
'mountpoint', format('/dummy/%s', unescape(disk)),
|
||||
'block_device', format('md/%s', disk)
|
||||
)));
|
||||
};
|
||||
};
|
||||
SELF;
|
||||
};
|
||||
11
samples/Pan/cluster-A.pan
Normal file
11
samples/Pan/cluster-A.pan
Normal file
@@ -0,0 +1,11 @@
|
||||
structure template site/nagios/hosts/cluster-A;
|
||||
|
||||
# let Nagios server A monitor B
|
||||
# just an example to make the templates compile
|
||||
"nagios-slave-B.example.org" = create (NAGIOS_QUATTOR_HOST);
|
||||
"nagios-slave-B.example.org/alias" = "slave B";
|
||||
"nagios-slave-B.example.org/hostgroups" = list( "quattor-nodes" );
|
||||
|
||||
|
||||
# "another-host-in-A.example.org" = create (NAGIOS_QUATTOR_HOST);
|
||||
# "another-host-in-A.example.org/alias" = "another monitored host in cluster A";
|
||||
18
samples/Pan/databases.pan
Normal file
18
samples/Pan/databases.pan
Normal file
@@ -0,0 +1,18 @@
|
||||
template site/databases;
|
||||
|
||||
# Defines the mapping between the full hostname and the IP
|
||||
# address.
|
||||
final variable DB_IP = dict(
|
||||
escape("one"), "192.168.0.24",
|
||||
escape("hyp01"), "192.168.0.25",
|
||||
escape("vm"), "192.168.0.26",
|
||||
);
|
||||
|
||||
# Defines the mapping between the full hostname and the
|
||||
# physical machine.
|
||||
# A different hardware template must be used for each machine
|
||||
final variable DB_MACHINE = dict(
|
||||
escape("one"), "hardware/machine/ibm/x3550/x_KDXXXX",
|
||||
escape("hyp01"), "hardware/machine/ibm/hs21xm/blade_99HXXXX",
|
||||
escape("vm"), "hardware/machine/one/example",
|
||||
);
|
||||
56
samples/Pan/functions.pan
Normal file
56
samples/Pan/functions.pan
Normal file
@@ -0,0 +1,56 @@
|
||||
################################################################################
|
||||
# This is 'namespaces/standard/pan/functions.tpl', a pan-templates's file
|
||||
################################################################################
|
||||
#
|
||||
# VERSION: 3.2.7, 21/08/09 22:22
|
||||
# AUTHOR: Martin Bock
|
||||
# MAINTAINER: Example Maintainer <support@example.org>
|
||||
# LICENSE: http://cern.ch/eu-datagrid/license.html
|
||||
#
|
||||
################################################################################
|
||||
# Coding style: emulate <TAB> characters with 4 spaces, thanks!
|
||||
################################################################################
|
||||
#
|
||||
# Function definitions
|
||||
#
|
||||
################################################################################
|
||||
|
||||
declaration template pan/functions;
|
||||
|
||||
include 'pan/types';
|
||||
|
||||
############################################################
|
||||
##=
|
||||
## @function push
|
||||
## @# push zero or more values onto the end of a list.
|
||||
##+If the list does not exist or is not defined a new list is
|
||||
##+created.
|
||||
## @syntax value:element
|
||||
## @param:value... the values to push onto list
|
||||
## @example
|
||||
##+# "/data" will contain list (1,2,3,4)
|
||||
##+"/data" = list(1,2);
|
||||
##+"/data" = push(3,4);
|
||||
##=
|
||||
############################################################
|
||||
function push = {
|
||||
# Get the reference to SELF or create an empty list
|
||||
# as necessary.
|
||||
if (exists(SELF) && is_list(SELF)) {
|
||||
v = SELF;
|
||||
} else if (!exists(SELF) || !is_defined(SELF)) {
|
||||
v = list();
|
||||
} else {
|
||||
error("push can only be applied to a list");
|
||||
};
|
||||
|
||||
# Merge the arguments into the given array. Neither the
|
||||
# first/next or merge functions can be used because the
|
||||
# ARGV array cannot be directly referenced.
|
||||
i = 0;
|
||||
while (i < ARGC) {
|
||||
v[length(v)] = ARGV[i];
|
||||
i = i + 1;
|
||||
};
|
||||
v;
|
||||
};
|
||||
22
samples/Pan/infernalis.pan
Normal file
22
samples/Pan/infernalis.pan
Normal file
@@ -0,0 +1,22 @@
|
||||
unique template site/ceph/server/infernalis;
|
||||
|
||||
include 'components/dirperm/config';
|
||||
|
||||
"/software/components/dirperm/paths" = {
|
||||
foreach (idx; mp; value('/system/filesystems')) {
|
||||
if (match(mp['mountpoint'], format('^%s', CEPH_OSD_MP_BASE))) {
|
||||
append(SELF, dict(
|
||||
"path", mp['mountpoint'],
|
||||
"owner", "ceph:ceph",
|
||||
"perm", "0755",
|
||||
"type", "d",
|
||||
));
|
||||
};
|
||||
};
|
||||
SELF;
|
||||
};
|
||||
|
||||
include 'common/sysctl/service';
|
||||
prefix "/software/components/metaconfig/services/{/etc/sysctl.conf}/contents";
|
||||
|
||||
'kernel.pid_max' = 4194303;
|
||||
20
samples/Pan/libvirt.pan
Normal file
20
samples/Pan/libvirt.pan
Normal file
@@ -0,0 +1,20 @@
|
||||
unique template site/ceph/client/libvirt;
|
||||
|
||||
include 'site/ceph/client/config';
|
||||
|
||||
variable CEPH_LIBVIRT_USER ?= 'oneadmin';
|
||||
variable CEPH_LIBVIRT_GROUP ?= CEPH_LIBVIRT_USER;
|
||||
prefix '/software/components/metaconfig/services/{/etc/ceph/ceph.client.libvirt.keyring}';
|
||||
|
||||
"contents" = if (is_defined(CEPH_LIBVIRT_SECRET)) {
|
||||
dict("client.libvirt", dict(
|
||||
"key", CEPH_LIBVIRT_SECRET,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
dict();
|
||||
};
|
||||
'module' = 'tiny';
|
||||
'mode' = 0600;
|
||||
'owner' = CEPH_LIBVIRT_USER;
|
||||
'group' = CEPH_LIBVIRT_GROUP;
|
||||
19
samples/Pan/link.pan
Normal file
19
samples/Pan/link.pan
Normal file
@@ -0,0 +1,19 @@
|
||||
unique template site/dcache/link;
|
||||
|
||||
include 'components/dcache/config';
|
||||
|
||||
## links
|
||||
## default preference value
|
||||
"/software/components/dcache/link/def_pref" = "10";
|
||||
## list of links that will be ignored during configuration
|
||||
"/software/components/dcache/link/ignore_link" = list();
|
||||
##
|
||||
"/software/components/dcache/link/links" = dict(
|
||||
## out_buf_write: all outside to write to the storage through this buffer
|
||||
"out", dict("ugroup", list("all_net", "any_store"), "pgroup", list("out_buf"), "read", "10", "write", "10", "cache", "10"),
|
||||
"in", dict("ugroup", list("in_net", "any_store"), "pgroup", list("priv"), "read", "20", "write", "20", "cache", "20"),
|
||||
"dteam", dict("ugroup", list("dteam_store"), "pgroup", list("out_buf"), "read", "10", "write", "10", "cache", "10"),
|
||||
"ops", dict("ugroup", list("ops_store"), "pgroup", list("out_buf"), "read", "10", "write", "10", "cache", "10"),
|
||||
"cms", dict("ugroup", list("cms_store"), "pgroup", list("out_buf"), "read", "10", "write", "10", "cache", "10"),
|
||||
"test", dict("ugroup", list("test_store"), "pgroup", list("behar_test"), "read", "10", "write", "10", "cache", "10"),
|
||||
);
|
||||
29
samples/Pan/mysql.pan
Normal file
29
samples/Pan/mysql.pan
Normal file
@@ -0,0 +1,29 @@
|
||||
unique template common/opennebula/mysql;
|
||||
|
||||
prefix "/software/packages";
|
||||
"{mysql-server}" = dict();
|
||||
|
||||
include 'components/mysql/config';
|
||||
|
||||
prefix "/software/components/mysql";
|
||||
"serviceName" = {
|
||||
if (RPM_BASE_FLAVOUR_VERSIONID == 7) {
|
||||
"mariadb";
|
||||
} else {
|
||||
"mysqld";
|
||||
};
|
||||
};
|
||||
prefix "/software/components/mysql/servers/one";
|
||||
"host" = FULL_HOSTNAME; # localhost is added by component
|
||||
"adminpwd" = OPENNEBULA_MYSQL_ADMIN;
|
||||
"adminuser" = "root";
|
||||
|
||||
prefix "/software/components/mysql/databases/opennebula";
|
||||
"server" = "one";
|
||||
"users/oneadmin/password" = OPENNEBULA_MYSQL_ONEADMIN;
|
||||
"users/oneadmin/rights" = list("ALL PRIVILEGES");
|
||||
"createDb" = false; # if false, run script
|
||||
"initScript/file" = "/dev/null";
|
||||
|
||||
prefix "/software/components/chkconfig/service";
|
||||
"mysqld" = dict("on", "", "startstop", true);
|
||||
18
samples/Pan/nodes_properties.pan
Normal file
18
samples/Pan/nodes_properties.pan
Normal file
@@ -0,0 +1,18 @@
|
||||
template config/nodes_properties;
|
||||
|
||||
variable SITES ?= list('example');
|
||||
|
||||
#variable NEW_NODES_PROPS ?= {
|
||||
|
||||
variable NODES_PROPS = {
|
||||
nodes_add = dict();
|
||||
nodes_props = dict();
|
||||
allsites = SITES;
|
||||
ok = first(allsites, k, v);
|
||||
while (ok) {
|
||||
nodes_add = merge(create(format("config/%s_nodes_properties", v)), nodes_props);
|
||||
nodes_props = merge(nodes_add[v], nodes_props);
|
||||
ok = next(allsites, k, v);
|
||||
};
|
||||
nodes_props;
|
||||
};
|
||||
14
samples/Pan/onevm.pan
Normal file
14
samples/Pan/onevm.pan
Normal file
@@ -0,0 +1,14 @@
|
||||
unique template site/one/onevm;
|
||||
|
||||
include 'components/chkconfig/config';
|
||||
|
||||
# set opennebula map
|
||||
include 'quattor/aii/opennebula/schema';
|
||||
bind "/system/opennebula" = opennebula_vmtemplate;
|
||||
|
||||
include 'site/config-vm';
|
||||
|
||||
include 'quattor/aii/opennebula/default';
|
||||
|
||||
"/software/packages/{acpid}" = dict();
|
||||
"/software/components/chkconfig/service/acpid" = dict('on', '', 'startstop', true);
|
||||
26
samples/Pan/osd-fetch.pan
Normal file
26
samples/Pan/osd-fetch.pan
Normal file
@@ -0,0 +1,26 @@
|
||||
unique template site/ceph/osdschemas/osd-fetch;
|
||||
|
||||
prefix '/software/components/ceph/clusters/ceph';
|
||||
|
||||
variable FETCHED_OSDS = {
|
||||
t = dict();
|
||||
rep = 2;
|
||||
foreach(idx; host; CEPH_NODES) {
|
||||
prof = replace('.data$', '.os', host);
|
||||
d = value(format('%s:/software/components/ceph/localdaemons/osds', prof));
|
||||
t[shorten_fqdn(host)] = dict(
|
||||
'fqdn', host,
|
||||
'osds', d
|
||||
);
|
||||
|
||||
numosd = length(d);
|
||||
if (numosd > rep){
|
||||
rep = numosd;
|
||||
};
|
||||
};
|
||||
all = dict('osdhosts', t, 'maxosd', rep);
|
||||
};
|
||||
|
||||
'osdhosts' = FETCHED_OSDS['osdhosts'];
|
||||
variable CEPH_OSD_DOWN_REPORTERS ?= FETCHED_OSDS['maxosd'] + 2;
|
||||
variable CEPH_OSD_DOWN_REPORTS ?= CEPH_OSD_DOWN_REPORTERS + CEPH_OSD_DOWN_REPORTERS / 4 + 1;
|
||||
45
samples/Pan/pakiti.pan
Normal file
45
samples/Pan/pakiti.pan
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# Generated by RepositoryTask on 12/09/13 15:41
|
||||
#
|
||||
# name = pakiti
|
||||
# owner = support@example.org
|
||||
# url = http://quattor.web.lal.in2p3.fr/packages/pakiti
|
||||
#
|
||||
|
||||
structure template repository/pakiti;
|
||||
|
||||
"name" = "pakiti";
|
||||
"owner" = "support@example.org";
|
||||
"protocols" = list(
|
||||
dict("name", "http",
|
||||
"url", "http://quattor.web.lal.in2p3.fr/packages/pakiti")
|
||||
);
|
||||
|
||||
"contents" = dict(
|
||||
# pkg = pakiti-client-2.1.4-1-noarch
|
||||
escape("pakiti-client-2.1.4-1-noarch"), dict("name", "pakiti-client", "version", "2.1.4-1", "arch", "noarch"),
|
||||
# pkg = pakiti-client-2.1.4-2-noarch
|
||||
escape("pakiti-client-2.1.4-2-noarch"), dict("name", "pakiti-client", "version", "2.1.4-2", "arch", "noarch"),
|
||||
# pkg = pakiti-client-2.1.4-3-noarch
|
||||
escape("pakiti-client-2.1.4-3-noarch"), dict("name", "pakiti-client", "version", "2.1.4-3", "arch", "noarch"),
|
||||
# pkg = pakiti-client-2.1.4-4-noarch
|
||||
escape("pakiti-client-2.1.4-4-noarch"), dict("name", "pakiti-client", "version", "2.1.4-4", "arch", "noarch"),
|
||||
# pkg = pakiti-client-2.1.5-0-noarch
|
||||
escape("pakiti-client-2.1.5-0-noarch"), dict("name", "pakiti-client", "version", "2.1.5-0", "arch", "noarch"),
|
||||
# pkg = pakiti-client-manual-2.1.4-2-noarch
|
||||
escape("pakiti-client-manual-2.1.4-2-noarch"), dict("name", "pakiti-client-manual", "version", "2.1.4-2", "arch", "noarch"),
|
||||
# pkg = pakiti-client-manual-2.1.4-3-noarch
|
||||
escape("pakiti-client-manual-2.1.4-3-noarch"), dict("name", "pakiti-client-manual", "version", "2.1.4-3", "arch", "noarch"),
|
||||
# pkg = pakiti-client-manual-2.1.4-4-noarch
|
||||
escape("pakiti-client-manual-2.1.4-4-noarch"), dict("name", "pakiti-client-manual", "version", "2.1.4-4", "arch", "noarch"),
|
||||
# pkg = pakiti-server-2.1.4-1-noarch
|
||||
escape("pakiti-server-2.1.4-1-noarch"), dict("name", "pakiti-server", "version", "2.1.4-1", "arch", "noarch"),
|
||||
# pkg = pakiti-server-2.1.4-2-noarch
|
||||
escape("pakiti-server-2.1.4-2-noarch"), dict("name", "pakiti-server", "version", "2.1.4-2", "arch", "noarch"),
|
||||
# pkg = pakiti-server-2.1.4-3-noarch
|
||||
escape("pakiti-server-2.1.4-3-noarch"), dict("name", "pakiti-server", "version", "2.1.4-3", "arch", "noarch"),
|
||||
# pkg = pakiti-server-2.1.4-4-noarch
|
||||
escape("pakiti-server-2.1.4-4-noarch"), dict("name", "pakiti-server", "version", "2.1.4-4", "arch", "noarch"),
|
||||
# pkg = pakiti-server-2.1.5-0-noarch
|
||||
escape("pakiti-server-2.1.5-0-noarch"), dict("name", "pakiti-server", "version", "2.1.5-0", "arch", "noarch"),
|
||||
);
|
||||
30
samples/Pan/purge_fqan_accounts.pan
Normal file
30
samples/Pan/purge_fqan_accounts.pan
Normal file
@@ -0,0 +1,30 @@
|
||||
# Template installing a script to remove all accounts with 'fqan' in
|
||||
# their name. Used after fixing VOConfigTask in SCDB 2.3.2 to remove
|
||||
# obsolete accounts not removed by ncm-accounts.
|
||||
#
|
||||
# The script is added and executed only on nodes where NODE_VO_ACCOUNTS
|
||||
# is true. It is intended to be run as GLITE_BASE_CONFIG_SITE (define
|
||||
# this variable to the script namespace).
|
||||
#
|
||||
# Michel Jouvin - 13/9/09
|
||||
|
||||
unique template site/misc/purge_fqan_accounts;
|
||||
|
||||
variable LAL_PURGE_ACCOUNTS_SCRIPT = '/tmp/purge_fqan_accounts';
|
||||
|
||||
include 'components/filecopy/config';
|
||||
|
||||
'/software/components/filecopy/services' = {
|
||||
if ( is_defined(NODE_VO_ACCOUNTS) && NODE_VO_ACCOUNTS ) {
|
||||
debug('Adding purge_fqan_accounts');
|
||||
SELF[escape(LAL_PURGE_ACCOUNTS_SCRIPT)] = dict(
|
||||
'config', file_contents('site/misc/purge_fqan_accounts.sh'),
|
||||
'owner', 'root:root',
|
||||
'perms', '0755',
|
||||
'restart', LAL_PURGE_ACCOUNTS_SCRIPT,
|
||||
);
|
||||
} else {
|
||||
debug(format('VO accounts disabled (NODE_VO_ACCOUNTS=%s', NODE_VO_ACCOUNTS));
|
||||
};
|
||||
SELF;
|
||||
};
|
||||
30
samples/Pan/resources.pan
Normal file
30
samples/Pan/resources.pan
Normal file
@@ -0,0 +1,30 @@
|
||||
unique template site/one/resources;
|
||||
|
||||
# datastores templates
|
||||
prefix "/software/components/opennebula/datastores/0";
|
||||
"name" = "ceph.example";
|
||||
"bridge_list" = list(FULL_HOSTNAME); # for now, do this from the headnode
|
||||
"ceph_host" = CEPH_MON_HOSTS;
|
||||
"ceph_secret" = CEPH_LIBVIRT_UUID;
|
||||
"ceph_user" = "libvirt";
|
||||
"ceph_user_key" = CEPH_LIBVIRT_SECRET;
|
||||
"datastore_capacity_check" = true;
|
||||
"pool_name" = "one";
|
||||
"type" = "IMAGE_DS";
|
||||
"rbd_format" = 2;
|
||||
|
||||
prefix "/software/components/opennebula/datastores/1";
|
||||
"name" = "nfs.example";
|
||||
"datastore_capacity_check" = true;
|
||||
"ds_mad" = "fs";
|
||||
"tm_mad" = "shared";
|
||||
"type" = "IMAGE_DS";
|
||||
|
||||
# untouchables resources
|
||||
prefix "/software/components/opennebula/untouchables";
|
||||
"datastores" = list('system');
|
||||
|
||||
# extra conf
|
||||
prefix "/software/components/opennebula";
|
||||
"ssh_multiplex" = true;
|
||||
"tm_system_ds" = "ssh";
|
||||
20
samples/Pan/simple.pan
Normal file
20
samples/Pan/simple.pan
Normal file
@@ -0,0 +1,20 @@
|
||||
unique template site/ceph/osdlocal/simple;
|
||||
|
||||
variable CEPH_JOURNAL_PART ?= dict();
|
||||
|
||||
prefix '/software/components/ceph';
|
||||
|
||||
'localdaemons/osds' = {
|
||||
d = dict();
|
||||
foreach(idx; osdmnt; value('/system/filesystems')) {
|
||||
part = osdmnt['block_device'];
|
||||
disk = replace('\S+/([a-zA-Z]+)[0-9]*$', '$1', part);
|
||||
if (match(osdmnt['mountpoint'], '/var/lib/ceph/osd/\w+')){
|
||||
d[escape(osdmnt['mountpoint'])] = dict(
|
||||
'journal_path', format('/dev/%s%d', disk, CEPH_JOURNAL_PART['data']),
|
||||
'crush_weight', weight_of(part),
|
||||
);
|
||||
};
|
||||
};
|
||||
d;
|
||||
};
|
||||
151
samples/Pan/types.pan
Normal file
151
samples/Pan/types.pan
Normal file
@@ -0,0 +1,151 @@
|
||||
@contributor{
|
||||
name = First Contributor
|
||||
email = first@example.org
|
||||
}
|
||||
@contributor{
|
||||
name = Second Contributor
|
||||
email = second@example.org
|
||||
}
|
||||
@documentation{
|
||||
Data type and function definitions for basic types
|
||||
}
|
||||
|
||||
declaration template pan/types;
|
||||
|
||||
include 'pan/legacy';
|
||||
|
||||
@documentation{
|
||||
This type implements a date/time format consistent with
|
||||
ASN.1 typically used by LDAP. The actual specification is the
|
||||
"GeneralizedTime" format as specified on page 38 of the X.208
|
||||
ITU-T recommendation and references within.
|
||||
|
||||
Ex: 20040825120123Z
|
||||
20040825120123+0100
|
||||
20040825120123,5
|
||||
20040825120123.5
|
||||
20040825120123.5-0123
|
||||
}
|
||||
function is_asndate = {
|
||||
# Check cardinality and type of argument.
|
||||
if (ARGC != 1 || !is_string(ARGV[0]))
|
||||
error("usage: is_asndate(string)");
|
||||
|
||||
# Match the datetime pattern, extracting interesting fields.
|
||||
result = matches(ARGV[0],
|
||||
'^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:[,\.](\d+))?([Zz]|(?:[-+]\d{2}\d{2}))?$');
|
||||
|
||||
if (length(result) >= 7) {
|
||||
# Do further tests on various components of the date.
|
||||
# NOTE: the to_long(to_double(x)) construct below is to avoid having
|
||||
# the to_long function treat strings with leading zeros as octal
|
||||
# numbers. E.g. to_long("09") will throw an exception because '9' is
|
||||
# not a valid octal digit.
|
||||
year = to_long(result[1]);
|
||||
month = to_long(to_double(result[2]));
|
||||
day = to_long(to_double(result[3]));
|
||||
hour = to_long(to_double(result[4]));
|
||||
minute = to_long(to_double(result[5]));
|
||||
second = to_long(to_double(result[6]));
|
||||
|
||||
frac = 0;
|
||||
if (length(result) > 7) {
|
||||
frac = to_long(to_double(result[7]));
|
||||
};
|
||||
|
||||
zone = '+0000';
|
||||
if (length(result) > 8) {
|
||||
zone = result[8];
|
||||
};
|
||||
|
||||
# Check the range of months.
|
||||
if (month < 1 || month > 12) {
|
||||
error("is_asndate: invalid month");
|
||||
return(false);
|
||||
};
|
||||
|
||||
# Check the range of days.
|
||||
if (day < 1 || day > 31) {
|
||||
error("is_asndate: invalid day");
|
||||
return(false);
|
||||
};
|
||||
|
||||
# Be more specific on the days in each month.
|
||||
if (month == 4 || month == 6 || month == 9 || month == 11) {
|
||||
if (day > 30) {
|
||||
error("is_asndate: invalid day");
|
||||
};
|
||||
};
|
||||
|
||||
# February is always a bother. Too lazy to check that the leap
|
||||
# years have been specified correctly.
|
||||
if (month == 2 && day > 29) {
|
||||
error("is_asndate: invalid day");
|
||||
};
|
||||
|
||||
# Check the time.
|
||||
if (hour > 23) {
|
||||
error("is_asndate: invalid hour");
|
||||
return(false);
|
||||
};
|
||||
if (minute > 59) {
|
||||
error("is_asndate: invalid minute");
|
||||
return(false);
|
||||
};
|
||||
|
||||
# Allow for leap seconds here (since it is easy).
|
||||
if (second > 60) {
|
||||
error("is_asndate: invalid minute");
|
||||
return(false);
|
||||
};
|
||||
|
||||
# Check the time zone format.
|
||||
if (zone != "Z" && zone != "z") {
|
||||
tz = matches(zone, '^[-+](\d{2})(\d{2})$');
|
||||
|
||||
hoffset = to_long(to_double(tz[1]));
|
||||
moffset = to_long(to_double(tz[2]));
|
||||
|
||||
if (hoffset >= 12) {
|
||||
error("is_asndate: invalid hour offset in time zone");
|
||||
return(false);
|
||||
};
|
||||
if (moffset > 59) {
|
||||
error("is_asndate: invalid minute offset in time zone");
|
||||
return(false);
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
error("is_asndate: invalid format for time");
|
||||
return(false);
|
||||
};
|
||||
|
||||
# If it gets to this point, then the date must be OK.
|
||||
true;
|
||||
};
|
||||
|
||||
|
||||
type type_asndate = string with {
|
||||
is_asndate(SELF);
|
||||
};
|
||||
|
||||
@documentation{
|
||||
desc = Type that enforces the existence of a named interface.
|
||||
}
|
||||
type valid_interface = string with {
|
||||
if (exists(format('/system/network/interfaces/%s', SELF))) {
|
||||
return(true);
|
||||
};
|
||||
foreach(ifc; attr; value('/system/network/interfaces')) {
|
||||
if (attr['device'] == SELF){
|
||||
return(true);
|
||||
};
|
||||
};
|
||||
false;
|
||||
};
|
||||
|
||||
@documentation{
|
||||
desc = CPU architectures understood by Quattor
|
||||
}
|
||||
type cpu_architecture = string with match (SELF, '^(i386|ia64|x86_64|sparc|aarch64|ppc64(le)?)$');
|
||||
32
samples/Pan/unit.pan
Normal file
32
samples/Pan/unit.pan
Normal file
@@ -0,0 +1,32 @@
|
||||
unique template site/dcache/unit;
|
||||
|
||||
include 'components/dcache/config';
|
||||
|
||||
## unit/ugroups
|
||||
## list of ugroups that will be ignored during configuration
|
||||
"/software/components/dcache/unit/ignore_ugroup" = list();
|
||||
"/software/components/dcache/unit/units" = dict(
|
||||
"protocol", list(
|
||||
dict("cond", "*/*", "ugroup", list("default_protocol"))
|
||||
),
|
||||
"net", list(
|
||||
dict("cond", "192.168.0.0/255.255.0.0", "ugroup", list("in_net", "all_net")),
|
||||
dict("cond", "192.168.10.0/255.255.255.0", "ugroup", list("in_server", "in_net", "all_net")),
|
||||
dict("cond", "192.168.11.0/255.255.255.0", "ugroup", list("in_wn", "in_net", "all_net")),
|
||||
dict("cond", "192.168.12.0/255.255.255.0", "ugroup", list("in_wn", "in_net", "all_net")),
|
||||
dict("cond", "192.168.13.0/255.255.255.0", "ugroup", list("in_wn", "in_net", "all_net")),
|
||||
dict("cond", "192.168.14.0/255.255.255.0", "ugroup", list("in_wn", "in_net", "all_net")),
|
||||
dict("cond", "192.168.15.0/255.255.255.0", "ugroup", list("in_wn", "in_net", "all_net")),
|
||||
dict("cond", "192.168.16.0/255.255.255.0", "ugroup", list("in_wn", "in_net", "all_net")),
|
||||
dict("cond", "192.168.17.0/255.255.255.0", "ugroup", list("in_wn", "in_net", "all_net")),
|
||||
dict("cond", "0.0.0.0/0.0.0.0", "ugroup", list("all_net")),
|
||||
),
|
||||
"store", list(
|
||||
dict("cond", "*@*", "ugroup", list("any_store")),
|
||||
dict("cond", "myStore:STRING@osm", "ugroup", list("default_store", "any_store")),
|
||||
dict("cond", "dteam:dteam-base@osm", "ugroup", list("dteam_store", "any_store")),
|
||||
dict("cond", "ops:ops-base@osm", "ugroup", list("ops_store", "any_store")),
|
||||
dict("cond", "cms:cms-base@osm", "ugroup", list("cms_store", "any_store")),
|
||||
dict("cond", "test:cms-test@osm", "ugroup", list("test_store")),
|
||||
),
|
||||
);
|
||||
34
samples/Pep8/div.pep
Normal file
34
samples/Pep8/div.pep
Normal file
@@ -0,0 +1,34 @@
|
||||
main: SUBSP 8, i
|
||||
DECI 0, s
|
||||
DECI 2, s
|
||||
CALL div
|
||||
DECO 4, s
|
||||
CHARO '\n', i
|
||||
DECO 6, s
|
||||
CHARO '\n', i
|
||||
STOP
|
||||
|
||||
; Divides two numbers following the euclidian method
|
||||
;
|
||||
; Parameters:
|
||||
; SP + 2: Dividend
|
||||
; SP + 4: Divider
|
||||
; Returns:
|
||||
; SP + 6: Quotient
|
||||
; SP + 8: Remain
|
||||
div: LDX 0, i
|
||||
LDA dividend, s
|
||||
divlp: CPA divider, s
|
||||
BRLT divout
|
||||
ADDX 1, i
|
||||
SUBA divider, s
|
||||
BR divlp
|
||||
divout: STX quot, s
|
||||
STA rem, s
|
||||
RET0
|
||||
dividend: .EQUATE 2
|
||||
divider: .EQUATE 4
|
||||
quot: .EQUATE 6
|
||||
rem: .EQUATE 8
|
||||
|
||||
.END
|
||||
23
samples/Pep8/flag.pep
Normal file
23
samples/Pep8/flag.pep
Normal file
@@ -0,0 +1,23 @@
|
||||
_start: LDA 0,i
|
||||
LDX 0,i
|
||||
LDA 20, i
|
||||
ADDA 51, i
|
||||
CPA 0,i
|
||||
BRLT s3
|
||||
BR s4
|
||||
s1: LDBYTEA s3, x
|
||||
NOTA
|
||||
STBYTEA s3, x
|
||||
ADDX 1,i
|
||||
CPX 12, i
|
||||
BRNE s1
|
||||
s2: STOP
|
||||
s4: LDA 31, d
|
||||
LDX 50, d
|
||||
RET0
|
||||
STOP
|
||||
s3: CPX -27746, d
|
||||
ANDX -8241, i
|
||||
SUBA -12337, sxf
|
||||
LDX -12289, sx
|
||||
.END
|
||||
675
samples/Pep8/linked.pep
Normal file
675
samples/Pep8/linked.pep
Normal file
@@ -0,0 +1,675 @@
|
||||
; Linked list of integers API
|
||||
;
|
||||
; Contains the basis of the structure and a
|
||||
; variety of available functions to call on it.
|
||||
;
|
||||
; Calling conventions:
|
||||
;
|
||||
; - When the number of arguments is <= 2, the fastcall convention will be used:
|
||||
; Arguments will be passed by registers, no assumption is made concerning the
|
||||
; state of the registers during execution, they will need to be saved.
|
||||
;
|
||||
; - When the number of arguments exceeds 2, the cdecl convention will be used:
|
||||
; Arguments will be passed on the stack, no assumption is made concerning the
|
||||
; state of the registers during execution, they will need to be saved.
|
||||
|
||||
; Simple test program, do no include when using the library
|
||||
main: SUBSP 4, i
|
||||
DECI mnelmt, s
|
||||
CALL newlst
|
||||
LDX mnlst, s
|
||||
CALL lstgetst
|
||||
LDX mnlst, s
|
||||
CALL lstsetst
|
||||
LDX mnlst, s
|
||||
CALL lstgetst
|
||||
LDX mnlst, s
|
||||
CALL shftest
|
||||
LDX mnlst, s
|
||||
CALL ushftest
|
||||
LDX mnlst, s
|
||||
CALL shftest
|
||||
ADDSP 4, i
|
||||
STOP
|
||||
; Pointer to the list
|
||||
mnlst: .EQUATE 0
|
||||
; Element read
|
||||
mnelmt: .EQUATE 2
|
||||
|
||||
; TESTS
|
||||
|
||||
; Simple test for the get operation
|
||||
; Gets the first element of the list and prints it
|
||||
;
|
||||
; REQUIRES: Non-empty list
|
||||
;
|
||||
; Parameters:
|
||||
; - X: Pointer to the list
|
||||
;
|
||||
; Returns:
|
||||
; void
|
||||
lstgetst: SUBSP 2, i
|
||||
LDA 0, i
|
||||
CALL lstget
|
||||
STA 0, s
|
||||
DECO 0, s
|
||||
CHARO '\n', i
|
||||
ADDSP 2, i
|
||||
RET0
|
||||
|
||||
; Test for the set operation
|
||||
; Sets the first element of the list to a given value
|
||||
; The value is read from stdin
|
||||
;
|
||||
; REQUIRES: Non-empty list
|
||||
;
|
||||
; Parameters:
|
||||
; - X: Pointer to the list
|
||||
;
|
||||
; Returns:
|
||||
; void
|
||||
lstsetst: SUBSP 6, i
|
||||
STX 0, s
|
||||
DECI 4, s
|
||||
LDA 0, i
|
||||
STA 2, s
|
||||
CALL lstset
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
|
||||
; Tests shift operation on a list
|
||||
; Gets the last element of the list and prints it
|
||||
;
|
||||
; REQUIRES: Non-empty list
|
||||
;
|
||||
; Parameters:
|
||||
; - X: Pointer to the list
|
||||
;
|
||||
; Returns:
|
||||
; void
|
||||
shftest: SUBSP 2, i
|
||||
CALL lstshft
|
||||
STA 0, s
|
||||
DECO 0, s
|
||||
CHARO '\n', i
|
||||
ADDSP 2, i
|
||||
RET0
|
||||
|
||||
; Tests unshift operation on a list
|
||||
; Unshifts a new element read from keyboard
|
||||
;
|
||||
; Parameters:
|
||||
; - X: Pointer to the list
|
||||
;
|
||||
; Returns:
|
||||
; void
|
||||
ushftest: SUBSP 2, i
|
||||
DECI 0, s
|
||||
LDA 0, s
|
||||
CALL lstunshf
|
||||
ADDSP 2, i
|
||||
RET0
|
||||
|
||||
; LIBRARY
|
||||
|
||||
; Creates a new list with `element` as head
|
||||
;
|
||||
; Parameters:
|
||||
; SP + 4: Element
|
||||
;
|
||||
; Returns:
|
||||
; SP + 2: Pointer to the list
|
||||
newlst: LDA lstlen, i
|
||||
CALL new
|
||||
STX 2, s
|
||||
CALL newnode
|
||||
SUBSP 2, i
|
||||
STX 0, s
|
||||
LDX nodeelmt, i
|
||||
LDA 6, s
|
||||
STA 0, sxf
|
||||
LDA 0, s
|
||||
LDX lsthead, i
|
||||
STA 4, sxf
|
||||
ADDSP 2, i
|
||||
RET0
|
||||
|
||||
; Gets a node at specified index in a list
|
||||
;
|
||||
; Parameters:
|
||||
; - A: Index
|
||||
; - X: Pointer to the list
|
||||
;
|
||||
; Returns:
|
||||
; - A: Error code (0 if no error was produced)
|
||||
; - X: Pointer to the node
|
||||
;
|
||||
; Errors:
|
||||
; -1: Index < 0
|
||||
; -2: Index >= list.length
|
||||
nodeat: SUBSP 10, i
|
||||
STA ndaind, s
|
||||
STX ndalst, s
|
||||
LDX lsthead, i
|
||||
LDA ndalst, sxf
|
||||
STA ndanode, s
|
||||
LDA ndaind, s
|
||||
CPA 0, i
|
||||
LDA 0, i
|
||||
STA ndacurri, s
|
||||
BRGE ndagez
|
||||
LDA -1, i
|
||||
ADDSP 10, i
|
||||
RET0
|
||||
ndagez: LDX ndalst, s
|
||||
CALL listlen
|
||||
STA ndalstln, s
|
||||
LDA ndaind, s
|
||||
CPA ndalstln, s
|
||||
BRLT ndalp
|
||||
LDA -2, i
|
||||
ADDSP 10, i
|
||||
RET0
|
||||
ndalp: LDA ndacurri, s
|
||||
CPA ndaind, s
|
||||
BREQ ndaout
|
||||
LDX nodenxt, i
|
||||
LDA ndanode, sxf
|
||||
STA ndanode, s
|
||||
LDA ndacurri, s
|
||||
ADDA 1, i
|
||||
STA ndacurri, s
|
||||
BR ndalp
|
||||
ndaout: LDX ndanode, s
|
||||
LDA 0, i
|
||||
ADDSP 10, i
|
||||
RET0
|
||||
ndaind: .EQUATE 0
|
||||
ndanode: .EQUATE 2
|
||||
ndalst: .EQUATE 4
|
||||
ndalstln: .EQUATE 6
|
||||
ndacurri: .EQUATE 8
|
||||
|
||||
; Length of the list passed as a parameter
|
||||
;
|
||||
; Parameters:
|
||||
; - X: List
|
||||
;
|
||||
; Returns:
|
||||
; - A: Length
|
||||
listlen: SUBSP 4, i
|
||||
STX lenode, s
|
||||
LDX lenode, sf
|
||||
STX lenode, s
|
||||
LDA 0, i
|
||||
STA lencpt, s
|
||||
llenlp: LDA lenode, s
|
||||
CPA 0, i
|
||||
BREQ lenout
|
||||
LDA lencpt, s
|
||||
ADDA 1, i
|
||||
STA lencpt, s
|
||||
LDX nodenxt, i
|
||||
LDA lenode, sxf
|
||||
STA lenode, s
|
||||
BR llenlp
|
||||
lenout: LDA lencpt, s
|
||||
ADDSP 4, i
|
||||
RET0
|
||||
lenode: .EQUATE 0
|
||||
lencpt: .EQUATE 2
|
||||
|
||||
; Gets an element in a list at a specified index
|
||||
;
|
||||
; Parameters:
|
||||
; - A: Index
|
||||
; - X: Address of the list
|
||||
;
|
||||
; Returns:
|
||||
; - A: Element value
|
||||
;
|
||||
; Error:
|
||||
; If out of bounds, prints an error message and stops the program
|
||||
lstget: SUBSP 2, i
|
||||
STA 0, s
|
||||
CALL nodeat
|
||||
CPA 0, i
|
||||
BRNE getoob
|
||||
LDA 0, x
|
||||
ADDSP 2, i
|
||||
RET0
|
||||
; Out of bounds
|
||||
getoob: STRO getstrob, d
|
||||
DECO 0, s
|
||||
CHARO '\n', i
|
||||
STOP
|
||||
; String for out of bounds error
|
||||
getstrob: .ASCII "Invalid index on get, index = \x00"
|
||||
|
||||
; Sets an element in a list at a specified index to a new value
|
||||
;
|
||||
; Parameters:
|
||||
; - SP + 2: Pointer to the list
|
||||
; - SP + 4: Index
|
||||
; - SP + 6: Element
|
||||
;
|
||||
; Returns:
|
||||
; - A: 0 if all went well, an error code otherwise (analogous to the error codes in nodeat)
|
||||
lstset: CHARO '\n', i
|
||||
DECO lstsetlp, s
|
||||
CHARO ' ', i
|
||||
DECO lstsetin, s
|
||||
CHARO ' ', i
|
||||
DECO lstsetel, s
|
||||
CHARO '\n', i
|
||||
SUBSP 2, i
|
||||
LDX lstsetlp, s
|
||||
LDA lstsetin, s
|
||||
CALL nodeat
|
||||
CPA 0, i
|
||||
BRNE lstsetrt
|
||||
STX lstsetnp, s
|
||||
LDA lstsetel, s
|
||||
LDX nodeelmt, i
|
||||
STA lstsetnp, sxf
|
||||
LDA 0, i
|
||||
lstsetrt: ADDSP 2, i
|
||||
RET0
|
||||
; Pointer to the list
|
||||
lstsetlp: .EQUATE 4
|
||||
; Element to set the value at
|
||||
lstsetel: .EQUATE 8
|
||||
; Index of the node
|
||||
lstsetin: .EQUATE 6
|
||||
; Pointer to the node
|
||||
lstsetnp: .EQUATE 0
|
||||
|
||||
; Removes the first element of the list in parameter and returns its value
|
||||
;
|
||||
; REQUIRES: Non-empty list
|
||||
;
|
||||
; Parameters:
|
||||
; ⁻ X: Pointer to the list
|
||||
;
|
||||
; Returns :
|
||||
; - A: Element removed
|
||||
lstshft: SUBSP 8, i
|
||||
STX lshflp, s
|
||||
LDX lsthead, i
|
||||
LDA lshflp, sxf
|
||||
CPA 0, i
|
||||
BREQ shfterr
|
||||
STA lshfohd, s
|
||||
LDX nodenxt, i
|
||||
LDA lshfohd, sxf
|
||||
STA lshfnhd, s
|
||||
LDX lsthead, i
|
||||
STA lshflp, sxf
|
||||
LDX nodeelmt, i
|
||||
LDA lshfohd, sxf
|
||||
ADDSP 8, i
|
||||
RET0
|
||||
shfterr: STRO shfterrm, d
|
||||
STOP
|
||||
; Pointer to the list
|
||||
lshflp: .EQUATE 0
|
||||
; Pointer to the old head
|
||||
lshfohd: .EQUATE 2
|
||||
; Old head's element
|
||||
lshfhdel: .EQUATE 4
|
||||
; Pointer to the new head
|
||||
lshfnhd: .EQUATE 6
|
||||
; Error message on shift
|
||||
shfterrm: .ASCII "Cannot do shift on empty list.\n\x00"
|
||||
|
||||
; Inserts a new element at the beginning of a list
|
||||
;
|
||||
; Parameters:
|
||||
; - X: Pointer to the list
|
||||
; - A: Element to add to the list
|
||||
;
|
||||
; Returns:
|
||||
; - A: Error code, 0 if all right, a code otherwise
|
||||
lstunshf: SUBSP 8, i
|
||||
STA lunshelm, s
|
||||
STX lunslp, s
|
||||
CALL newnode
|
||||
STX lunsnhd, s
|
||||
LDX lsthead, i
|
||||
LDA lunslp, sxf
|
||||
STA lunsohd, s
|
||||
LDX nodenxt, i
|
||||
LDA lunsohd, s
|
||||
STA lunsnhd, sxf
|
||||
LDA lunshelm, s
|
||||
LDX nodeelmt, i
|
||||
STA lunsohd, sxf
|
||||
LDX lsthead, i
|
||||
LDA lunsnhd, s
|
||||
STA lunslp, sxf
|
||||
ADDSP 8, i
|
||||
RET0
|
||||
; Pointer to the list
|
||||
lunslp: .EQUATE 0
|
||||
; Pointer to the old head
|
||||
lunsohd: .EQUATE 2
|
||||
; Pointer to the new head
|
||||
lunsnhd: .EQUATE 4
|
||||
; Element to add
|
||||
lunshelm: .EQUATE 6
|
||||
|
||||
; Finds whether or not an element is present in a list
|
||||
;
|
||||
; Parameters:
|
||||
; - X: Pointer to the list
|
||||
; - A: Element to be found
|
||||
;
|
||||
; Returns:
|
||||
; - A: 0 if element was not found, 1 if it was
|
||||
lstfnd: SUBSP 6, i
|
||||
STX lstfndlp, s
|
||||
STA lstfndel, s
|
||||
LDX lsthead, i
|
||||
LDA lstfndlp, sxf
|
||||
STA lstfndnd, s
|
||||
fndloop: CPA 0, i
|
||||
BREQ notfnd
|
||||
LDX nodeelmt, i
|
||||
LDA lstfndnd, sxf
|
||||
CPA lstfndel, s
|
||||
BREQ found
|
||||
LDX nodenxt, i
|
||||
LDA lstfndnd, sxf
|
||||
STA lstfndnd, s
|
||||
BR fndloop
|
||||
notfnd: LDA 0, i
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
found: LDA 1, i
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
; Pointer to the list
|
||||
lstfndlp: .EQUATE 0
|
||||
; Element to search
|
||||
lstfndel: .EQUATE 2
|
||||
; Current node
|
||||
lstfndnd: .EQUATE 4
|
||||
|
||||
; Pushes a new element at the end of the list
|
||||
;
|
||||
; Parameters:
|
||||
; - X: Pointer to the list
|
||||
; - A: Element to push
|
||||
;
|
||||
; Returns:
|
||||
; - A: 0 if all went well, an error code otherwise
|
||||
lstpsh: SUBSP 8, i
|
||||
STX lpshlp, s
|
||||
STA lpshel, s
|
||||
CALL newnode
|
||||
STX lpshnd, s
|
||||
LDX lpshlp, s
|
||||
CALL listlen
|
||||
CPA 0, i
|
||||
BREQ lpshshft
|
||||
SUBA 1, i
|
||||
LDX lpshlp, s
|
||||
CALL nodeat
|
||||
STX lpshlnd, s
|
||||
LDX nodenxt, i
|
||||
LDA lpshnd, s
|
||||
STA lpshlnd, sxf
|
||||
LDA lpshel, s
|
||||
LDX nodeelmt, i
|
||||
STA lpshnd, sxf
|
||||
ADDSP 8, i
|
||||
RET0
|
||||
lpshshft: LDX lpshlp, s
|
||||
LDA lpshel, s
|
||||
CALL lstunshf
|
||||
ADDSP 8, i
|
||||
RET0
|
||||
; Pointer to the list
|
||||
lpshlp: .EQUATE 0
|
||||
; Element to add to the list
|
||||
lpshel: .EQUATE 2
|
||||
; Node to add to the list
|
||||
lpshnd: .EQUATE 4
|
||||
; Node to append
|
||||
lpshlnd: .EQUATE 6
|
||||
|
||||
; Pops the last element of a list
|
||||
;
|
||||
; Parameters:
|
||||
; - X: Pointer to the list
|
||||
;
|
||||
; Returns:
|
||||
; - A: Element removed from the list
|
||||
lstpop: SUBSP 6, i
|
||||
STX lpoplp, s
|
||||
CALL listlen
|
||||
CPA 0, i
|
||||
BRNE poperrem
|
||||
CPA 1, i
|
||||
BREQ popshft
|
||||
SUBA 2, i
|
||||
LDX lpoplp, s
|
||||
CALL nodeat
|
||||
STX lpopndpr, s
|
||||
LDX nodenxt, i
|
||||
LDA lpopndpr, sxf
|
||||
LDA 0, i
|
||||
LDX nodenxt, i
|
||||
STA lpopndpr, sxf
|
||||
STA lpoplnd, s
|
||||
LDX nodeelmt, i
|
||||
LDA lpoplnd, s
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
poperrem: STRO poperrsm, d
|
||||
STOP
|
||||
popshft: LDX lpoplp, s
|
||||
CALL lstshft
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
; Pointer to the list
|
||||
lpoplp: .EQUATE 0
|
||||
; Node to remove
|
||||
lpoplnd: .EQUATE 2
|
||||
;New last node
|
||||
lpopndpr: .EQUATE 4
|
||||
; Message to print when popping an empty list
|
||||
poperrsm: .ASCII "Error: cannot pop an empty list.\n\x00"
|
||||
|
||||
; Inserts an element in a list at a given position
|
||||
;
|
||||
; REQUIRES: Non-empty list
|
||||
;
|
||||
; Parameters:
|
||||
; - SP + 2: Pointer to the list
|
||||
; - SP + 4: Index to insert at
|
||||
; - SP + 6: Element to add
|
||||
;
|
||||
; Returns:
|
||||
; - A: Error code: 0 if all went well, -1 if index < 0, -2 if index > list.length
|
||||
lstinsat: SUBSP 6, i
|
||||
LDA lstinsid, s
|
||||
CPA 0, i
|
||||
BRLT lstinslz
|
||||
BREQ lstinush
|
||||
LDX lstinslp, s
|
||||
CALL listlen
|
||||
CPA lstinsel, s
|
||||
BRLT lstinsgl
|
||||
BREQ lstinpsh
|
||||
LDX lstinslp, s
|
||||
LDA lstinsel, s
|
||||
SUBA 1, i
|
||||
CALL nodeat
|
||||
STX lstinsnd, s
|
||||
LDX nodenxt, i
|
||||
LDA lstinsnd, sxf
|
||||
STA lstinscx, s
|
||||
CALL newnode
|
||||
STX lstinscn, s
|
||||
LDX nodeelmt, i
|
||||
LDA lstinsel, s
|
||||
STA lstinscn, sxf
|
||||
LDX nodenxt, i
|
||||
LDA lstinscx, s
|
||||
STA lstinscn, sxf
|
||||
LDA lstinscn, s
|
||||
LDX nodenxt, i
|
||||
STA lstinsnd, sxf
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
lstinush: LDX lstinslp, s
|
||||
LDA lstinsel, s
|
||||
CALL lstunshf
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
lstinpsh: LDX lstinslp, s
|
||||
LDA lstinsel, s
|
||||
CALL lstpsh
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
; Insert with index < 0
|
||||
lstinslz: LDA -1, i
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
; Insert with index > list.length
|
||||
lstinsgl: LDA -2, i
|
||||
ADDSP 6, i
|
||||
RET0
|
||||
; List pointer
|
||||
lstinslp: .EQUATE 8
|
||||
; Index of the newly created node
|
||||
lstinsid: .EQUATE 10
|
||||
; Element to add
|
||||
lstinsel: .EQUATE 12
|
||||
; Node to change the pointer to the next
|
||||
lstinsnd: .EQUATE 0
|
||||
; Node to insert
|
||||
lstinscn: .EQUATE 2
|
||||
; Pointer to the node after the created one (might be null)
|
||||
lstinscx: .EQUATE 4
|
||||
|
||||
; Removes a node at a given index in a list,
|
||||
; returns the element previously contained
|
||||
;
|
||||
; Parameters:
|
||||
; - X: Pointer to the list
|
||||
; - A: Index of the element
|
||||
;
|
||||
; Returns:
|
||||
; - A: Element removed
|
||||
;
|
||||
; Error:
|
||||
; In case of error, the program aborts with an error message
|
||||
lstremat: SUBSP 8, i
|
||||
STX lremlp, s
|
||||
STA lremid, s
|
||||
CPA 0, i
|
||||
BRLT lstremob
|
||||
BREQ lstremz
|
||||
CALL listlen
|
||||
CPA lremid, s
|
||||
BRGE lstremob
|
||||
SUBA 1, i
|
||||
CPA lremid, s
|
||||
BREQ lrempop
|
||||
LDA lremid, s
|
||||
LDX lremlp, s
|
||||
CALL nodeat
|
||||
STX lremnd, s
|
||||
LDA lremid, s
|
||||
SUBA 1, i
|
||||
LDX lremlp, s
|
||||
CALL nodeat
|
||||
STX lrempnd, s
|
||||
LDX nodenxt, i
|
||||
LDA lremnd, sxf
|
||||
STA lrempnd, sxf
|
||||
LDX nodeelmt, i
|
||||
LDA lremnd, sxf
|
||||
ADDSP 8, i
|
||||
RET0
|
||||
lstremz: LDX lremlp, s
|
||||
CALL lstshft
|
||||
ADDSP 8, i
|
||||
RET0
|
||||
lrempop: LDX lremlp, s
|
||||
CALL lstpop
|
||||
ADDSP 8, i
|
||||
RET0
|
||||
lstremob: STRO lremobst, d
|
||||
DECO lremid, s
|
||||
CHARO '\n', i
|
||||
STOP
|
||||
; Pointer to the list
|
||||
lremlp: .EQUATE 0
|
||||
; Index to remove an element at
|
||||
lremid: .EQUATE 2
|
||||
; Pointer to the node before the removed element
|
||||
lrempnd: .EQUATE 4
|
||||
; Pointer to the node to remove
|
||||
lremnd: .EQUATE 6
|
||||
; Error out of bounds string for remove_at
|
||||
lremobst: .ASCII "Error: Out of bounds in remove_at, index = \x00"
|
||||
|
||||
; Creates a new node from scratch
|
||||
; Sets its content to 0/NULL
|
||||
;
|
||||
; Parameters:
|
||||
; void
|
||||
;
|
||||
; Return:
|
||||
; - X: Address of the node
|
||||
newnode: LDA nodeln, i
|
||||
SUBSP 2, i
|
||||
CALL new
|
||||
STX 0, s
|
||||
LDA 0, i
|
||||
LDX nodenxt, i
|
||||
STA 0, sxf
|
||||
LDX nodeelmt, i
|
||||
STA 0, sxf
|
||||
LDX 0, s
|
||||
ADDSP 2, i
|
||||
RET0
|
||||
|
||||
; Allocates a new structure in the heap
|
||||
;
|
||||
; Parameters:
|
||||
; - A: Length of the structure to allocate (bytes)
|
||||
;
|
||||
; Returns:
|
||||
; - X: Address of the allocated structure
|
||||
new: ADDA hpptr, d
|
||||
LDX hpptr, d
|
||||
STA hpptr, d
|
||||
RET0
|
||||
|
||||
; Node in a linked list
|
||||
;
|
||||
; Contains two fields:
|
||||
; - Element: Offset 0
|
||||
; - Next: Offset 2
|
||||
;
|
||||
nodeln: .EQUATE 4
|
||||
nodeelmt: .EQUATE 0
|
||||
nodenxt: .EQUATE 2
|
||||
|
||||
; Linked list capsule
|
||||
;
|
||||
; Contains one field:
|
||||
; - Head: Offset 0
|
||||
;
|
||||
lstlen: .EQUATE 2
|
||||
lsthead: .EQUATE 0
|
||||
|
||||
; Pointer to the next available byte on the heap
|
||||
hpptr: .ADDRSS heap
|
||||
; Start of the heap
|
||||
heap: .BLOCK 1
|
||||
.END
|
||||
434
samples/Pep8/msq.pep
Normal file
434
samples/Pep8/msq.pep
Normal file
@@ -0,0 +1,434 @@
|
||||
; Reads a square from stdin, then computes whether it is a magic square or not.
|
||||
;
|
||||
; A Magic Square is a square following a specific set of rules, namely:
|
||||
; - The sum of each row must be the same as the sum of the diagonal
|
||||
; - The sum of the anti-diagonal must be the same as the sum of the diagonal
|
||||
; - The sum of each column must be the same as the sum of the diagonal
|
||||
;
|
||||
; If any column, row, or anti-diagonal does not follow the aformented rules,
|
||||
; the program will output its number to stdout.
|
||||
;
|
||||
; Columns are identified by a negative digit, ranging from -1 to -n
|
||||
; The anti-diagonal is identified by the number 0.
|
||||
; Finally, rows are identified by a positive integer, ranging from 1 to n.
|
||||
;
|
||||
; Formatting:
|
||||
; First a number `n` is read from Stdin, it will determine the size of the square
|
||||
; Then, enter the data for the square, `n` entries will be read
|
||||
; The data is sequentially added to the square in memory, from the upper-left corner
|
||||
; to the lower-right corner, in a zig-zag pattern
|
||||
;
|
||||
; Example:
|
||||
; 3
|
||||
; 4 9 3
|
||||
; 3 5 7
|
||||
; 8 1 6
|
||||
;
|
||||
; Limitation: Since there is no dynamic allocation, the size
|
||||
; of the square is capped at a maximum of 32*32.
|
||||
; Any size lower than 1 or higher than 32 will produce
|
||||
; an error and the termination of the program.
|
||||
|
||||
;_start
|
||||
DECI sidelen, d
|
||||
LDA sidelen, d
|
||||
CPA 1, i
|
||||
BRLT sderror
|
||||
CPA 32, i
|
||||
BRGT sderror
|
||||
LDX sidelen, d
|
||||
CALL mult
|
||||
STA sqlen, d
|
||||
CALL fillsq
|
||||
LDA sidelen, d
|
||||
LDX square, i
|
||||
CALL diagsum
|
||||
STA dgsm, d
|
||||
CALL colsums
|
||||
LDA sidelen, d
|
||||
LDX square, i
|
||||
CALL cdiagsum
|
||||
CPA dgsm, d
|
||||
BREQ cnt
|
||||
DECO 0, i
|
||||
CHARO '\n', i
|
||||
cnt: STA cdsm, d
|
||||
CALL rowsums
|
||||
STOP
|
||||
el: .BLOCK 2
|
||||
; Length of a side of the square
|
||||
sidelen: .WORD 0
|
||||
; Total length of the square
|
||||
sqlen: .BLOCK 2
|
||||
; 32 * 32 square of integers
|
||||
square: .BLOCK 255
|
||||
.BLOCK 255
|
||||
.BLOCK 255
|
||||
.BLOCK 255
|
||||
.BLOCK 255
|
||||
.BLOCK 255
|
||||
.BLOCK 255
|
||||
.BLOCK 255
|
||||
.BLOCK 8
|
||||
|
||||
; Prints an error and terminates the program
|
||||
sderror: STRO stderr, d
|
||||
STOP
|
||||
|
||||
; Parameters: A: Size of a side of the square
|
||||
; X: Base address of the square
|
||||
; cscolid: Identifier of the column (0-based)
|
||||
|
||||
; Computes the sum of each column
|
||||
; If the sum is not the same as dgsm, its index will be printed (in negative form)
|
||||
;
|
||||
; Parameters: A: Size of a side of the square
|
||||
; X: Address of the square
|
||||
;
|
||||
; Return: void
|
||||
colsums:STA clsmsqsz, d
|
||||
STX clsmsqad, d
|
||||
SUBA 1, i
|
||||
STA clsmyp, d
|
||||
clssmlp:CPA 0 ,i
|
||||
BRLT clsmout
|
||||
STA cscolid, d
|
||||
LDA clsmsqsz, d
|
||||
LDX clsmsqsz, d
|
||||
CALL colsum
|
||||
CPA dgsm, d
|
||||
BREQ clsdecpt
|
||||
LDX clsmyp, d
|
||||
NEGX
|
||||
STX clsmyp, d
|
||||
DECO clsmyp, d
|
||||
CHARO '\n', i
|
||||
LDX clsmyp, d
|
||||
NEGX
|
||||
STX clsmyp, d
|
||||
clsdecpt: LDA clsmyp, d
|
||||
SUBA 1, i
|
||||
STA clsmyp, d
|
||||
BR clssmlp
|
||||
clsmout: RET0
|
||||
clsmsqad: .BLOCK 2
|
||||
clsmsqsz: .BLOCK 2
|
||||
clsmyp_: .BLOCK 2
|
||||
|
||||
; Compute the sum of each row
|
||||
; Prints its index if the value does not match dgsum
|
||||
;
|
||||
; Parameters: A: Size of a side of the square
|
||||
; X: Address of the square
|
||||
;
|
||||
; Returns: void
|
||||
rowsums: STA maxrows, d
|
||||
STX rowssqad, d
|
||||
LDA 0, i
|
||||
STA tmprwsm, d
|
||||
STA rowid, d
|
||||
rwsmslp: CPA maxrows, d
|
||||
BRGE rwsmsout
|
||||
STA rwxpos, d
|
||||
LDA maxrows, d
|
||||
LDX rowssqad, d
|
||||
CALL rowsum
|
||||
CPA dgsm, d
|
||||
STA tmprwsm, d
|
||||
BREQ rwinccpt
|
||||
DECO rowid, d
|
||||
CHARO '\n', i
|
||||
rwinccpt: LDA rowid, d
|
||||
ADDA 1, i
|
||||
STA rowid, d
|
||||
BR rwsmslp
|
||||
rwsmsout: RET0
|
||||
; Number of rows to compute
|
||||
maxrows: .BLOCK 2
|
||||
; Square address
|
||||
rowssqad: .BLOCK 2
|
||||
; Current rowid
|
||||
rowid: .BLOCK 2
|
||||
; Current rowsum
|
||||
tmprwsm: .BLOCK 2
|
||||
|
||||
; Gets an element at the indexes given as parameter
|
||||
; The square is supposed to contain only integers
|
||||
; No check will be made on the correctness of the indexes
|
||||
;
|
||||
; Parameters: A: Size of a side of the square (in elements)
|
||||
; X: Base address of the square
|
||||
; xpos: Position in X for the element (0-indexed)
|
||||
; ypos: Position in Y for the element (0-indexed)
|
||||
;
|
||||
; Return: A will contain the element
|
||||
;
|
||||
; Side-effects: Registers A and X will neither be saved nor restored upon call
|
||||
; ypos will be altered
|
||||
elemat: STX elsqaddr, d
|
||||
ASLA
|
||||
LDX xpos, d
|
||||
CALL mult
|
||||
STA xpos, d
|
||||
LDX ypos, d
|
||||
ASLX
|
||||
STX ypos, d
|
||||
ADDA ypos, d
|
||||
ADDA elsqaddr, d
|
||||
STA elsqaddr, d
|
||||
LDX elsqaddr, d
|
||||
LDA 0, x
|
||||
RET0
|
||||
; X-index in square (in elements)
|
||||
xpos: .BLOCK 2
|
||||
; Y-index in square (in elements)
|
||||
ypos: .BLOCK 2
|
||||
; Address to fetch elements at
|
||||
elsqaddr: .BLOCK 2
|
||||
|
||||
; Fills the square with input from the user
|
||||
;
|
||||
; Pass via register A the number of inputs to be read
|
||||
fillsq: LDX 0, i
|
||||
filloop: SUBA 1, i
|
||||
CPA 0, i
|
||||
BRLT fillout
|
||||
DECI square, x
|
||||
ADDX 2, i
|
||||
BR filloop
|
||||
fillout: RET0
|
||||
|
||||
; Computes the sum of the digits of a column
|
||||
; The square is supposed to contain integers only
|
||||
;
|
||||
; Parameters: A: Size of a side of the square
|
||||
; X: Base address of the square
|
||||
; cscolid: Identifier of the column (0-based)
|
||||
;
|
||||
; Return: A: Sum of the digits of the column
|
||||
colsum: STA csclsqsz, d
|
||||
STX csclsqad, d
|
||||
LDA 0, i
|
||||
STA csclsum, d
|
||||
STA csclxpos, d
|
||||
clsmloop: CPA csclsqsz, d
|
||||
BRGE colout
|
||||
LDA cscolid, d
|
||||
STA ypos, d
|
||||
LDA csclxpos, d
|
||||
STA xpos, d
|
||||
LDA csclsqsz, d
|
||||
LDX csclsqad, d
|
||||
CALL elemat
|
||||
ADDA csclsum, d
|
||||
STA csclsum, d
|
||||
LDA csclxpos, d
|
||||
ADDA 1, i
|
||||
STA csclxpos, d
|
||||
BR clsmloop
|
||||
colout: LDA csclsum, d
|
||||
RET0
|
||||
; Identifier of the column which sum is to be computed
|
||||
cscolid: .BLOCK 2
|
||||
; Temporary for x position
|
||||
csclxpos: .BLOCK 2
|
||||
; Base address of the square
|
||||
csclsqad: .BLOCK 2
|
||||
; Size of a side of the square
|
||||
csclsqsz: .BLOCK 2
|
||||
; Sum of the column
|
||||
csclsum: .BLOCK 2
|
||||
|
||||
; Computes the sum of the digits of a row
|
||||
; The square is supposed to contain integers only
|
||||
;
|
||||
; Parameters: A: Size of a side of the square
|
||||
; X: Base address of the square
|
||||
; rwxpos: Row index (0-based)
|
||||
;
|
||||
; Returns: A: Sum of the digits of the row
|
||||
rowsum: STA rwsqsz, d
|
||||
STX rwbsqadr, d
|
||||
LDA 0,i
|
||||
STA rwsum, d
|
||||
STA rwypos, d
|
||||
rwsumlp: LDA rwypos, d
|
||||
CPA rwsqsz, d
|
||||
BRGE rwsumout
|
||||
STA ypos, d
|
||||
LDA rwxpos, d
|
||||
STA xpos, d
|
||||
LDA rwsqsz, d
|
||||
LDX rwbsqadr, d
|
||||
CALL elemat
|
||||
ADDA rwsum, d
|
||||
STA rwsum, d
|
||||
LDA rwypos, d
|
||||
ADDA 1, i
|
||||
STA rwypos, d
|
||||
BR rwsumlp
|
||||
rwsumout: LDA rwsum, d
|
||||
RET0
|
||||
; Square size (in elements)
|
||||
rwsqsz: .BLOCK 2
|
||||
; Square base address
|
||||
rwbsqadr: .BLOCK 2
|
||||
; Position of the row to compute
|
||||
rwxpos: .BLOCK 2
|
||||
; Current column visited
|
||||
rwypos: .BLOCK 2
|
||||
; Sum of the row
|
||||
rwsum: .BLOCK 2
|
||||
|
||||
; Computes the sum for the antidiagonal of a square
|
||||
; The square is supposed to contain integers only
|
||||
;
|
||||
; Parameters: A: Size of a side of the square (elements)
|
||||
; X: Base address of the square
|
||||
;
|
||||
; Returns: A: Sum of the antidiagonal
|
||||
cdiagsum: STA cdsqsz, d
|
||||
SUBA 1,i
|
||||
STA cdtmpy, d
|
||||
LDA 0, i
|
||||
STA cdtmpx, d
|
||||
STA cdsum, d
|
||||
STX cdsqaddr, d
|
||||
cdiaglp: LDA cdtmpx, d
|
||||
STA xpos, d
|
||||
LDA cdtmpy, d
|
||||
STA ypos, d
|
||||
CPA 0, i
|
||||
BRLT cdout
|
||||
LDA cdsqsz, d
|
||||
LDX cdsqaddr, d
|
||||
CALL elemat
|
||||
ADDA cdsum, d
|
||||
STA cdsum,d
|
||||
LDA cdtmpx, d
|
||||
ADDA 1, i
|
||||
STA cdtmpx, d
|
||||
LDA cdtmpy, d
|
||||
SUBA 1, i
|
||||
STA cdtmpy, d
|
||||
BR cdiaglp
|
||||
cdout: LDA cdsum, d
|
||||
RET0
|
||||
; Temporary handle for square size (elements)
|
||||
cdsqsz: .BLOCK 2
|
||||
; Square address
|
||||
cdsqaddr: .BLOCK 2
|
||||
; Keep x address
|
||||
cdtmpx: .BLOCK 2
|
||||
; Keep y address
|
||||
cdtmpy: .BLOCK 2
|
||||
; Sum of antidiagonal
|
||||
cdsum: .BLOCK 2
|
||||
|
||||
; Computes the sum for the diagonal of a square
|
||||
; The square is supposed to contain integers only
|
||||
;
|
||||
; Parameters: A: Size of a side of the square (elements)
|
||||
; X: Base address of the square
|
||||
;
|
||||
; Returns: A: Sum of the diagonal
|
||||
;
|
||||
diagsum: STA dsqsz, d
|
||||
STX dsqaddr, d
|
||||
LDA 0, i
|
||||
STA tmpsum, d
|
||||
STA curra, d
|
||||
dglp: CPA dsqsz, d
|
||||
BRGE dglpout
|
||||
STA xpos, d
|
||||
STA ypos, d
|
||||
LDA dsqsz, d
|
||||
LDX dsqaddr, d
|
||||
CALL elemat
|
||||
ADDA tmpsum, d
|
||||
STA tmpsum, d
|
||||
LDA curra, d
|
||||
ADDA 1, i
|
||||
STA curra, d
|
||||
BR dglp
|
||||
dglpout: LDA tmpsum, d
|
||||
RET0
|
||||
; Address of the square
|
||||
dsqaddr: .BLOCK 2
|
||||
; Size of a side of the square (elements)
|
||||
dsqsz: .BLOCK 2
|
||||
; Current value of the x and y indexes
|
||||
curra: .BLOCK 2
|
||||
; Sum of the values
|
||||
tmpsum: .BLOCK 2
|
||||
|
||||
; Muliplies two ints
|
||||
;
|
||||
; Parameters:
|
||||
; Register A : Left part of the multiplication
|
||||
; Register X : Right part of the multiplication
|
||||
;
|
||||
; Return:
|
||||
; Register A : Result of the multiplication
|
||||
;
|
||||
; Side-effects:
|
||||
; Uses multmp as a temporary value
|
||||
mult: STA multmp, d
|
||||
LDA 0, i
|
||||
muloop: CPX 0, i
|
||||
BRLE mulout
|
||||
ADDA multmp, d
|
||||
SUBX 1, i
|
||||
BR muloop
|
||||
mulout: RET0
|
||||
; Temporary variable for mult function
|
||||
; Holds the initial value of A
|
||||
multmp: .WORD 0
|
||||
|
||||
; For debugging purposes
|
||||
; Prints the content of the square to stdout
|
||||
;
|
||||
; Parameters: A: Size of a side
|
||||
; X: Base address of square
|
||||
;
|
||||
; Side-effects:
|
||||
; Consider variables sidesz, sqaddr, sqmaxa as local, they will be written
|
||||
; Registers A and X will not be saved nor restored upon call
|
||||
printsq: STA sidesz, d
|
||||
STX sqaddr, d
|
||||
LDX sidesz, d
|
||||
CALL mult
|
||||
ASLA
|
||||
ADDA sqaddr, d
|
||||
STA sqmaxa, d
|
||||
LDX sqaddr, d
|
||||
LDA 0, i
|
||||
priloop: DECO 0, x
|
||||
CHARO ' ', i
|
||||
ADDX 2, i
|
||||
CPX sqmaxa, d
|
||||
BREQ priout
|
||||
ADDA 1, i
|
||||
CPA sidesz, d
|
||||
BRLT priloop
|
||||
LDA 0, i
|
||||
CHARO '\n', i
|
||||
BR priloop
|
||||
priout: RET0
|
||||
; Size of a side of the square
|
||||
sidesz: .BLOCK 2
|
||||
; Address of the square
|
||||
sqaddr: .BLOCK 2
|
||||
; Maximum address to iterate upon
|
||||
sqmaxa: .BLOCK 2
|
||||
|
||||
; ------------------ GLOBALLY ACCESSIBLE SYMBOLS -------------------- ;
|
||||
;
|
||||
; Sum of the diagonal for the square
|
||||
; Reference value for magic-square
|
||||
dgsm: .WORD 0
|
||||
; Sum of the counter-diagonal
|
||||
cdsm: .WORD 0
|
||||
; Input error string
|
||||
stderr: .ASCII "A number between 1 and 32 (both inclusive) must be entered as value for the size of the square for the program to work.\n\x00"
|
||||
.END
|
||||
227
samples/Pep8/qsort.pep
Normal file
227
samples/Pep8/qsort.pep
Normal file
@@ -0,0 +1,227 @@
|
||||
; Sorts a statically defined array using the recursive implementation
|
||||
; of the quicksort algorithm.
|
||||
;
|
||||
; In this implementation, the pivot is supposed to be the rightmost
|
||||
; value of the slice of the array being sorted.
|
||||
;
|
||||
; Note that the code presented below should work on any array,
|
||||
; whether defined statically or dynamically.
|
||||
;
|
||||
; Calling conventions:
|
||||
; Except when mentionned otherwise, every parameter is to be passed on the stack.
|
||||
; The return values are also on the stack.
|
||||
; No assumption is to be made on the content of a register on a function call.
|
||||
; The values of the registers are to be locally saved for further use if necessary.
|
||||
main: SUBSP 4, i
|
||||
LDA 11, i
|
||||
ASLA
|
||||
STA 2, s
|
||||
LDA arr, i
|
||||
STA 0, s
|
||||
CALL printarr
|
||||
SUBSP 2, i
|
||||
LDA arr, i
|
||||
STA 0, s
|
||||
LDA 0, i
|
||||
STA 2, s
|
||||
LDA 10, i
|
||||
STA 4, s
|
||||
CALL qsort
|
||||
ADDSP 2, i
|
||||
CHARO '\n', i
|
||||
LDA 11, i
|
||||
ASLA
|
||||
STA 2, s
|
||||
LDA arr, i
|
||||
STA 0, s
|
||||
CALL printarr
|
||||
STOP
|
||||
|
||||
; Sorts an array using the quicksort algorithm
|
||||
;
|
||||
; Parameters:
|
||||
; - SP + 2: Address of the array
|
||||
; - SP + 4: Left bound
|
||||
; - SP + 6: Right bound
|
||||
; Returns:
|
||||
; void
|
||||
qsort: SUBSP 2, i
|
||||
LDA qsarrlb, s
|
||||
CPA qsarrrb, s
|
||||
BRGE qsortout
|
||||
SUBSP 6, i
|
||||
LDA 10, s
|
||||
STA 0, s
|
||||
LDA 12, s
|
||||
STA 2, s
|
||||
LDA 14, s
|
||||
STA 4, s
|
||||
CALL part
|
||||
LDA 10, s
|
||||
STA 0, s
|
||||
LDA 12, s
|
||||
STA 2, s
|
||||
LDA 6, s
|
||||
SUBA 1, i
|
||||
STA 4, s
|
||||
CALL qsort
|
||||
LDA 10, s
|
||||
STA 0, s
|
||||
LDA 6, s
|
||||
ADDA 1, i
|
||||
STA 2, s
|
||||
LDA 14, s
|
||||
STA 4, s
|
||||
CALL qsort
|
||||
ADDSP 6, i
|
||||
qsortout: ADDSP 2, i
|
||||
RET0
|
||||
; Address of the array
|
||||
qsarradd: .EQUATE 4
|
||||
; Left bound
|
||||
qsarrlb: .EQUATE 6
|
||||
; Right bound
|
||||
qsarrrb: .EQUATE 8
|
||||
; Pivot value returned by the part command
|
||||
qsortp: .EQUATE 0
|
||||
|
||||
; Partitions an array in two following the quicksort rules.
|
||||
;
|
||||
; All the lower values compared to the pivot will be on the left
|
||||
; All the upper values compared to the pivot will be on the right
|
||||
; The pivot's final index is then returned
|
||||
;
|
||||
; Parameters:
|
||||
; - SP + 2: Address of the array
|
||||
; - SP + 4: Left bound
|
||||
; - SP + 6: Right bound
|
||||
;
|
||||
; Returns:
|
||||
; - SP + 8: Pivot final index
|
||||
part: SUBSP 8, i
|
||||
LDA parrrb, s
|
||||
STA partpiv, s
|
||||
LDA parrlb, s
|
||||
STA pstind, s
|
||||
STA piter, s
|
||||
partflp: CPA parrrb, s
|
||||
BRGE partout
|
||||
LDX piter, s
|
||||
ASLX
|
||||
LDA paraddr, sxf
|
||||
STA parrival, s
|
||||
LDX partpiv, s
|
||||
ASLX
|
||||
LDA paraddr, sxf
|
||||
CPA parrival, s
|
||||
BRLT parlpinc
|
||||
SUBSP 6, i ; Call swap(arr, i, st_index)
|
||||
LDA 16, s
|
||||
STA 0, s
|
||||
LDA 8, s
|
||||
STA 2, s
|
||||
LDA 10, s
|
||||
STA 4, s
|
||||
CALL swap
|
||||
ADDSP 6, i
|
||||
LDA pstind, s
|
||||
ADDA 1, i
|
||||
STA pstind, s
|
||||
parlpinc: LDA piter, s
|
||||
ADDA 1, i
|
||||
STA piter, s
|
||||
BR partflp
|
||||
partout: SUBSP 6, i ; Call swap(arr, piv, st_index)
|
||||
LDA 16, s
|
||||
STA 0, s
|
||||
LDA 12, s
|
||||
STA 2, s
|
||||
LDA 10, s
|
||||
STA 4, s
|
||||
CALL swap
|
||||
ADDSP 6, i
|
||||
LDA pstind, s
|
||||
ADDSP 8, i
|
||||
STA 8, s
|
||||
RET0
|
||||
; Address of the array
|
||||
paraddr: .EQUATE 10
|
||||
; Left bound
|
||||
parrlb: .EQUATE 12
|
||||
; Right bound
|
||||
parrrb: .EQUATE 14
|
||||
; Pivot value
|
||||
partpiv: .EQUATE 6
|
||||
; st_index
|
||||
pstind: .EQUATE 4
|
||||
; For iterator value
|
||||
piter: .EQUATE 2
|
||||
; arr[i] value
|
||||
parrival: .EQUATE 0
|
||||
|
||||
; Swaps the value of two elements of an array of integers
|
||||
;
|
||||
; Parameters:
|
||||
; - SP + 2: Address of the array
|
||||
; - SP + 4: Index of the 1st element to swap
|
||||
; - SP + 6: Index of the 2nd element to swap
|
||||
;
|
||||
; Returns:
|
||||
; void
|
||||
swap: SUBSP 2, i
|
||||
LDX fstelind, s
|
||||
ASLX
|
||||
LDA arraddr, sxf
|
||||
STA swaptmp, s
|
||||
LDX secelind, s
|
||||
ASLX
|
||||
LDA arraddr, sxf
|
||||
LDX fstelind, s
|
||||
ASLX
|
||||
STA arraddr, sxf
|
||||
LDA swaptmp, s
|
||||
LDX secelind, s
|
||||
ASLX
|
||||
STA arraddr, sxf
|
||||
ADDSP 2, i
|
||||
RET0
|
||||
; Temporary value for the swap
|
||||
swaptmp: .EQUATE 0
|
||||
; Address of the array on which the swap is done
|
||||
arraddr: .EQUATE 4
|
||||
; Index of the first element
|
||||
fstelind: .EQUATE 6
|
||||
; Index of the second element
|
||||
secelind: .EQUATE 8
|
||||
|
||||
; Prints the content of an array
|
||||
;
|
||||
; Parameters:
|
||||
; SP + 2: Address of the array
|
||||
; SP + 4: Length of the array
|
||||
;
|
||||
; Returns:
|
||||
; void
|
||||
printarr: LDX 0, i
|
||||
parrlp: CPX 4, s
|
||||
BRGE parrout
|
||||
DECO 2, sxf
|
||||
CHARO ' ', i
|
||||
ADDX 2, i
|
||||
BR parrlp
|
||||
parrout: RET0
|
||||
|
||||
; Unsorted array for testing purposes
|
||||
arr: .WORD 9
|
||||
.WORD 5
|
||||
.WORD 8
|
||||
.WORD 10
|
||||
.WORD 4
|
||||
.WORD 7
|
||||
.WORD 0
|
||||
.WORD 3
|
||||
.WORD 2
|
||||
.WORD 1
|
||||
.WORD 6
|
||||
|
||||
.END
|
||||
61
samples/Pep8/stri_buf.pep
Normal file
61
samples/Pep8/stri_buf.pep
Normal file
@@ -0,0 +1,61 @@
|
||||
main:
|
||||
|
||||
; Reads a string in stdin, returns the buffer it was read in
|
||||
; Stops reading at the first encounter of a \n character.
|
||||
;
|
||||
; Parameters:
|
||||
; void
|
||||
;
|
||||
; Returns:
|
||||
; - X: Address of the buffer
|
||||
stri: SUBSP 2, i
|
||||
LDA 32, i
|
||||
CALL new
|
||||
CPX buflen, s
|
||||
BRGE strinlrg
|
||||
strinlrg: LDA buflen, d
|
||||
LDX 2, i
|
||||
CALL mult
|
||||
STA buflen
|
||||
CALL new
|
||||
|
||||
buflen: .EQUATE 0
|
||||
|
||||
; Copies the content of a buffer to another one
|
||||
;
|
||||
; Parameters:
|
||||
; - SP + 2: Destination buffer
|
||||
; - SP + 4: Source buffer
|
||||
; - SP + 6: Length to copy
|
||||
memcpy: LDX 0, i
|
||||
memcplp: CPX cpylen, s
|
||||
BREQ memcpout
|
||||
LDBYTEA srcbuf, sxf
|
||||
STBYTEA dstbuf, sxf
|
||||
ADDX 1, i
|
||||
BR memcplp
|
||||
memcpout: RET0
|
||||
; Destination buffer
|
||||
dtsbuf: .EQUATE 2
|
||||
; Source buffer
|
||||
srcbuf: .EQUATE 4
|
||||
; Copy length
|
||||
cpylen: .EQUATE 6
|
||||
|
||||
; Allocates a new structure in the heap
|
||||
;
|
||||
; Parameters:
|
||||
; - A: Length of the structure to allocate (bytes)
|
||||
;
|
||||
; Returns:
|
||||
; - X: Address of the allocated structure
|
||||
new: ADDA hpptr, d
|
||||
LDX hpptr, d
|
||||
STA hpptr, d
|
||||
RET0
|
||||
|
||||
; Pointer to the next available byte on the heap
|
||||
hpptr: .ADDRSS heap
|
||||
; Start of the heap
|
||||
heap: .BLOCK 1
|
||||
.END
|
||||
50
samples/Pep8/stristack.pep
Normal file
50
samples/Pep8/stristack.pep
Normal file
@@ -0,0 +1,50 @@
|
||||
main: SUBSP 34, i
|
||||
LDA 31, i
|
||||
STA 0, s
|
||||
CALL fgets
|
||||
ADDSP 2, i
|
||||
CALL ststro
|
||||
STOP
|
||||
|
||||
; Reads a string from stdin, stops reading when one of the following is true:
|
||||
; - Read a \n
|
||||
; - Read a maximum of `max` chars
|
||||
;
|
||||
; Parameters:
|
||||
; - SP + 2: `max`, the maximum number of chars to read
|
||||
; - SP + 4: `buffer` of length `max` + 1
|
||||
; Returns:
|
||||
; void
|
||||
fgets: LDX 0, i
|
||||
LDA 0, i
|
||||
fgetslp: CHARI buffer, sx
|
||||
LDBYTEA buffer, sx
|
||||
CPA '\n', i
|
||||
BREQ fout
|
||||
CPX max, s
|
||||
BREQ fout
|
||||
ADDX 1, i
|
||||
BR fgetslp
|
||||
fout: LDA '\x00', i
|
||||
STBYTEA buffer, sx
|
||||
RET0
|
||||
max: .EQUATE 2
|
||||
buffer: .EQUATE 4
|
||||
|
||||
; Prints a string stored in stack
|
||||
;
|
||||
; Parameters:
|
||||
; SP + 2: `string`
|
||||
; Returns:
|
||||
; void
|
||||
ststro: LDX 0, i
|
||||
LDA 0, i
|
||||
strolp: LDBYTEA string, sx
|
||||
CPA '\x00', i
|
||||
BREQ strout
|
||||
CHARO string, sx
|
||||
ADDX 1, i
|
||||
BR strolp
|
||||
strout: RET0
|
||||
string: .EQUATE 2
|
||||
.END
|
||||
11
samples/Perl/filenames/cpanfile
Normal file
11
samples/Perl/filenames/cpanfile
Normal file
@@ -0,0 +1,11 @@
|
||||
requires 'perl', '5.008001';
|
||||
|
||||
requires 'JSON';
|
||||
requires 'Path::Class', 0.26;
|
||||
requires 'WebService::Dropbox', 2.06;
|
||||
requires 'DateTime::Format::Strptime';
|
||||
requires 'Encode::Locale';
|
||||
|
||||
if ($^O eq 'darwin') {
|
||||
requires 'Encode::UTF8Mac';
|
||||
}
|
||||
335
samples/Ring/hello.ring
Normal file
335
samples/Ring/hello.ring
Normal file
@@ -0,0 +1,335 @@
|
||||
# The Ring Standard Library
|
||||
# Game Engine for 2D Games
|
||||
# Flappy Bird 3000 Game
|
||||
# 2016, Mahmoud Fayed <msfclipper@yahoo.com>
|
||||
|
||||
oGameState = NULL
|
||||
|
||||
Load "gameengine.ring"
|
||||
|
||||
func main
|
||||
|
||||
oGame = New Game
|
||||
|
||||
while true
|
||||
|
||||
oGameState = New GameState
|
||||
|
||||
oGame {
|
||||
title = "Flappy Bird 3000"
|
||||
sprite
|
||||
{
|
||||
file = "images/fbback.png"
|
||||
x = 0 y=0 width=800 height = 600 scaled = true animate = false
|
||||
keypress = func ogame,oself,nKey {
|
||||
if nkey = key_esc or nKey = GE_AC_BACK
|
||||
ogame.shutdown()
|
||||
but nKey = key_space
|
||||
oGameState.startplay=true
|
||||
ogame.shutdown=true
|
||||
ok
|
||||
}
|
||||
mouse = func ogame,oself,nType,aMouseList {
|
||||
if nType = GE_MOUSE_UP
|
||||
call oself.keypress(oGame,oSelf,Key_Space)
|
||||
ok
|
||||
}
|
||||
}
|
||||
text {
|
||||
animate = false
|
||||
size = 35
|
||||
file = "fonts/pirulen.ttf"
|
||||
text = "Flappy Bird 3000"
|
||||
x = 150 y=50
|
||||
}
|
||||
text {
|
||||
animate = false
|
||||
size = 25
|
||||
file = "fonts/pirulen.ttf"
|
||||
text = "Version 1.0"
|
||||
x = 280 y=100
|
||||
}
|
||||
text {
|
||||
animate = false
|
||||
size = 16
|
||||
file = "fonts/pirulen.ttf"
|
||||
text = "(C) 2016, Mahmoud Fayed"
|
||||
x = 245 y=140
|
||||
}
|
||||
|
||||
text {
|
||||
animate = false
|
||||
size = 25
|
||||
file = "fonts/pirulen.ttf"
|
||||
text = "To Win Get Score = 3000"
|
||||
x = 150 y=270
|
||||
}
|
||||
|
||||
text {
|
||||
animate = false
|
||||
size = 25
|
||||
file = "fonts/pirulen.ttf"
|
||||
text = "Press Space to start"
|
||||
x = 190 y=470
|
||||
}
|
||||
text {
|
||||
animate = false
|
||||
size = 20
|
||||
file = "fonts/pirulen.ttf"
|
||||
text = "Press Esc to Exit"
|
||||
x = 260 y=510
|
||||
}
|
||||
|
||||
animate {
|
||||
file = "images/fbbird.png"
|
||||
x = 200
|
||||
y = 200
|
||||
framewidth = 20
|
||||
scaled = true
|
||||
height = 50
|
||||
width = 50
|
||||
nStep = 3
|
||||
transparent = true
|
||||
animate = true
|
||||
direction = ge_direction_random
|
||||
state = func oGame,oSelf {
|
||||
oSelf {
|
||||
nStep--
|
||||
if nStep = 0
|
||||
nStep = 3
|
||||
if frame < 3
|
||||
frame++
|
||||
else
|
||||
frame=1
|
||||
ok
|
||||
ok
|
||||
if x <= 0 x=0 ok
|
||||
if y <= 0 y=0 ok
|
||||
if x >= 750 x= 750 ok
|
||||
if y > 550 y=550 ok
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sound {
|
||||
file = "sound/music2.wav"
|
||||
}
|
||||
}
|
||||
if oGameState.startplay
|
||||
oGame.refresh()
|
||||
playstart(oGame)
|
||||
oGame.refresh()
|
||||
ok
|
||||
|
||||
end
|
||||
|
||||
|
||||
func playstart oGame
|
||||
|
||||
oGame {
|
||||
FPS = 60
|
||||
FixedFPS = 120
|
||||
Title = "Flappy Bird 3000"
|
||||
Sprite {
|
||||
file = "images/fbback.png"
|
||||
x = 0 y=0 width=800 height = 600 scaled = true animate = false
|
||||
keypress = func ogame,oself,nKey {
|
||||
if nkey = key_esc or nKey = GE_AC_BACK
|
||||
ogame.shutdown()
|
||||
ok
|
||||
}
|
||||
}
|
||||
|
||||
Map {
|
||||
blockwidth = 80
|
||||
blockheight = 80
|
||||
aMap = [
|
||||
[0,0,0,0,0,0,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0],
|
||||
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0],
|
||||
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0],
|
||||
[0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,1,0,0,0],
|
||||
[0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,3,0,0,0],
|
||||
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],
|
||||
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],
|
||||
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0]
|
||||
]
|
||||
newmap(aMap)
|
||||
aImages = ["images/fbwall.png","images/fbwallup.png",
|
||||
"images/fbwalldown.png"]
|
||||
state = func oGame,oSelf {
|
||||
if oGameState.gameresult = false
|
||||
px = oGame.aObjects[3].x
|
||||
py = oGame.aObjects[3].y
|
||||
oSelf {
|
||||
x -= 3
|
||||
if x < - 2100
|
||||
x = 0
|
||||
newmap(aMap)
|
||||
ok
|
||||
nCol = getcol(px,0)
|
||||
if nCol=11 or nCol=15 or nCol=19 or nCol=23 or nCol=27
|
||||
if nCol != oGameState.lastcol
|
||||
oGameState.lastcol = nCol
|
||||
oGameState.Score += 100
|
||||
oGame { Sound {
|
||||
once = true
|
||||
file = "sound/sfx_point.wav"
|
||||
} }
|
||||
checkwin(oGame)
|
||||
ok
|
||||
ok
|
||||
}
|
||||
if oSelf.getvalue(px+40,py) != 0 or
|
||||
oSelf.getvalue(px+40,py+40) != 0 or
|
||||
oSelf.getvalue(px,py) != 0 or
|
||||
oSelf.getvalue(px,py+40) != 0
|
||||
oGameState.gameresult = true
|
||||
oGame {
|
||||
text {
|
||||
point = 550
|
||||
size = 30
|
||||
nStep = 3
|
||||
file = "fonts/pirulen.ttf"
|
||||
text = "Game Over !!!"
|
||||
x = 500 y=10
|
||||
state = func ogame,oself {
|
||||
if oself.y >= 550
|
||||
ogame.shutdown = true
|
||||
ok
|
||||
if oself.y = 90
|
||||
ogame {
|
||||
Sound {
|
||||
once = true
|
||||
file = "sound/sfx_die.wav"
|
||||
}
|
||||
}
|
||||
ok
|
||||
}
|
||||
}
|
||||
Sound {
|
||||
once = true
|
||||
file = "sound/sfx_hit.wav"
|
||||
}
|
||||
}
|
||||
ok
|
||||
ok
|
||||
}
|
||||
}
|
||||
|
||||
animate {
|
||||
file = "images/fbbird.png"
|
||||
x = 10
|
||||
y = 10
|
||||
framewidth = 20
|
||||
scaled = true
|
||||
height = 50
|
||||
width = 50
|
||||
nStep = 3
|
||||
transparent = true
|
||||
state = func oGame,oSelf {
|
||||
oSelf {
|
||||
nStep--
|
||||
if nStep = 0
|
||||
nStep = 3
|
||||
if frame < 3
|
||||
frame++
|
||||
else
|
||||
frame=1
|
||||
ok
|
||||
ok
|
||||
}
|
||||
|
||||
if not oGameState.playerwin
|
||||
oGameState.down --
|
||||
if oGameState.down = 0
|
||||
oGameState.down = 3
|
||||
oself {
|
||||
y += 25
|
||||
if y > 550 y=550 ok
|
||||
}
|
||||
ok
|
||||
ok
|
||||
|
||||
}
|
||||
keypress = func ogame,oself,nKey {
|
||||
if oGameState.gameresult = false
|
||||
oself {
|
||||
if nkey = key_space
|
||||
y -= 55
|
||||
oGameState.down = 60
|
||||
if y<=0 y=0 ok
|
||||
ok
|
||||
}
|
||||
ok
|
||||
}
|
||||
mouse = func ogame,oself,nType,aMouseList {
|
||||
if nType = GE_MOUSE_UP
|
||||
call oself.keypress(oGame,oSelf,Key_Space)
|
||||
ok
|
||||
}
|
||||
}
|
||||
|
||||
text {
|
||||
animate = false
|
||||
point = 400
|
||||
size = 30
|
||||
file = "fonts/pirulen.ttf"
|
||||
text = "Score : " + oGameState.score
|
||||
x = 500 y=10
|
||||
state = func oGame,oSelf {
|
||||
oSelf { text = "Score : " + oGameState.score }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func newmap aMap
|
||||
aV = [
|
||||
[1,1,3,0,0,2,1,1],
|
||||
[1,3,0,0,0,2,1,1],
|
||||
[1,1,1,3,0,2,1,1],
|
||||
[1,1,1,3,0,0,0,0],
|
||||
[0,0,0,0,2,1,1,1],
|
||||
[0,0,2,1,1,1,1,1],
|
||||
[0,0,0,2,1,1,1,1],
|
||||
[1,1,1,3,0,2,1,1],
|
||||
[1,1,1,1,1,3,0,0],
|
||||
[3,0,0,2,1,1,1,1],
|
||||
[3,0,0,2,3,0,0,2]
|
||||
]
|
||||
for x = 10 to 24 step 4
|
||||
aVar = aV[ (random(10)+1) ]
|
||||
for y = 1 to 8
|
||||
aMap[y][x] = aVar[y]
|
||||
next
|
||||
next
|
||||
|
||||
func checkwin ogame
|
||||
if oGameState.score = 3000
|
||||
oGameState.gameresult = true
|
||||
oGameState.playerwin = true
|
||||
oGame {
|
||||
text {
|
||||
point = 400
|
||||
size = 30
|
||||
nStep = 3
|
||||
file = "fonts/pirulen.ttf"
|
||||
text = "You Win !!!"
|
||||
x = 500 y=10
|
||||
state = func ogame,oself {
|
||||
if oself.y >= 400
|
||||
ogame.shutdown = true
|
||||
oGameState.Score = 0
|
||||
ok
|
||||
}
|
||||
}
|
||||
}
|
||||
ok
|
||||
|
||||
Class GameState
|
||||
down = 3
|
||||
gameresult = false
|
||||
Score = 0
|
||||
startplay=false
|
||||
lastcol = 0
|
||||
playerwin = false
|
||||
44
samples/Ring/natural.ring
Normal file
44
samples/Ring/natural.ring
Normal file
@@ -0,0 +1,44 @@
|
||||
New App
|
||||
{
|
||||
I want window
|
||||
The window title = "hello world"
|
||||
}
|
||||
|
||||
Class App
|
||||
|
||||
func geti
|
||||
if nIwantwindow = 0
|
||||
nIwantwindow++
|
||||
ok
|
||||
|
||||
func getwant
|
||||
if nIwantwindow = 1
|
||||
nIwantwindow++
|
||||
ok
|
||||
|
||||
func getwindow
|
||||
if nIwantwindow = 2
|
||||
nIwantwindow= 0
|
||||
see "Instruction : I want window" + nl
|
||||
ok
|
||||
if nWindowTitle = 0
|
||||
nWindowTitle++
|
||||
ok
|
||||
|
||||
func settitle cValue
|
||||
if nWindowTitle = 1
|
||||
nWindowTitle=0
|
||||
see "Instruction : Window Title = " + cValue + nl
|
||||
ok
|
||||
|
||||
private
|
||||
|
||||
# Attributes for the instruction I want window
|
||||
i want window
|
||||
nIwantwindow = 0
|
||||
# Attributes for the instruction Window title
|
||||
# Here we don't define the window attribute again
|
||||
title
|
||||
nWindowTitle = 0
|
||||
# Keywords to ignore, just give them any value
|
||||
the=0
|
||||
48
samples/Ring/weblib.ring
Normal file
48
samples/Ring/weblib.ring
Normal file
@@ -0,0 +1,48 @@
|
||||
# Sample : Using the Web Library
|
||||
|
||||
Load "weblib.ring"
|
||||
Load "datalib.ring"
|
||||
Import System.Web
|
||||
|
||||
website = "ex24.ring"
|
||||
|
||||
New SalaryController { Routing() }
|
||||
|
||||
Class SalaryModel from ModelBase
|
||||
|
||||
Class SalaryController From ControllerBase
|
||||
|
||||
Class SalaryView From ViewBase
|
||||
|
||||
oLanguage = new SalaryLanguageEnglish
|
||||
|
||||
Func AddFuncScript oPage,oController
|
||||
return oPage.scriptfuncajax("myadd",oController.cMainURL+
|
||||
oController.cOperation+"=add","mysubpage")
|
||||
|
||||
Func FormViewContent oController,oTranslation,oPage
|
||||
return [
|
||||
[ oTranslation.aColumnsTitles[2], "textbox", "name",
|
||||
oController.oModel.Name, oPage.stylewidth("100%") ],
|
||||
[ oTranslation.aColumnsTitles[3], "textbox", "salary",
|
||||
oController.oModel.Salary, oPage.stylewidth("50%") ]
|
||||
]
|
||||
|
||||
Class SalaryLanguageEnglish
|
||||
cTitle = "Salary Table"
|
||||
cBack = "back"
|
||||
aColumnsTitles = ["ID","Name","Salary"]
|
||||
cOptions = "Options"
|
||||
cSearch = "Search"
|
||||
comboitems = ["Select Option...","Edit","Delete"]
|
||||
cAddRecord = "Add Record"
|
||||
cEditRecord = "Edit Record"
|
||||
cRecordDeleted = "Record Deleted!"
|
||||
aMovePages = ["First","Prev","Next","Last"]
|
||||
cPage = "Page"
|
||||
cOf = "of"
|
||||
cRecordsCount = "Records Count"
|
||||
cSave = "Save"
|
||||
temp = new page
|
||||
cTextAlign = temp.StyleTextRight()
|
||||
cNoRecords = "No records!"
|
||||
174
samples/Ring/weighthistory.ring
Normal file
174
samples/Ring/weighthistory.ring
Normal file
@@ -0,0 +1,174 @@
|
||||
Load "guilib.ring"
|
||||
|
||||
MyApp = new qApp
|
||||
{
|
||||
$ApplicationObject = "oApp" # To be used when calling events
|
||||
oApp = new App
|
||||
exec()
|
||||
oApp.CloseDatabase()
|
||||
}
|
||||
|
||||
class App
|
||||
|
||||
cDir = currentdir() + "/"
|
||||
oCon
|
||||
aIDs = []
|
||||
|
||||
win1 = new qWidget()
|
||||
{
|
||||
setWindowTitle("Weight History")
|
||||
resize(600,600)
|
||||
layoutButtons = new qhboxlayout()
|
||||
{
|
||||
label1 = new qLabel(win1) { setText("Weight") }
|
||||
text1 = new qlineedit(win1)
|
||||
btnAdd = new qpushbutton(win1) {
|
||||
setText("Add")
|
||||
setClickEvent($ApplicationObject+".AddWeight()")
|
||||
}
|
||||
btnDelete = new qpushbutton(win1) {
|
||||
setText("Delete")
|
||||
setClickEvent($ApplicationObject+".Deleteweight()")
|
||||
}
|
||||
addwidget(label1)
|
||||
addwidget(text1)
|
||||
addwidget(btnAdd)
|
||||
addwidget(btnDelete)
|
||||
}
|
||||
layoutData = new qhboxlayout()
|
||||
{
|
||||
Table1 = new qTableWidget(win1) {
|
||||
setrowcount(0)
|
||||
setcolumncount(3)
|
||||
setselectionbehavior(QAbstractItemView_SelectRows)
|
||||
setHorizontalHeaderItem(0, new QTableWidgetItem("Date"))
|
||||
setHorizontalHeaderItem(1, new QTableWidgetItem("Time"))
|
||||
setHorizontalHeaderItem(2, new QTableWidgetItem("Weight"))
|
||||
setitemChangedEvent($ApplicationObject+".ItemChanged()")
|
||||
setAlternatingRowColors(true)
|
||||
horizontalHeader().setStyleSheet("color: blue")
|
||||
verticalHeader().setStyleSheet("color: red")
|
||||
}
|
||||
addWidget(Table1)
|
||||
}
|
||||
layoutClose = new qhboxlayout()
|
||||
{
|
||||
btnclose = new qpushbutton(win1) {
|
||||
setText("Close")
|
||||
setClickEvent("MyApp.Quit()")
|
||||
}
|
||||
addwidget(btnClose)
|
||||
}
|
||||
layoutMain = new qvboxlayout()
|
||||
{
|
||||
addlayout(layoutButtons)
|
||||
addLayout(LayoutData)
|
||||
addLayout(layoutClose)
|
||||
}
|
||||
setlayout(layoutMain)
|
||||
self.OpenDatabase()
|
||||
self.ShowRecords()
|
||||
show()
|
||||
}
|
||||
|
||||
Func OpenDatabase
|
||||
lCreate = False
|
||||
if not fexists(cDir + "weighthistory.db")
|
||||
lCreate = True
|
||||
ok
|
||||
new QSqlDatabase() {
|
||||
this.oCon = addDatabase("QSQLITE") {
|
||||
setDatabaseName("weighthistory.db")
|
||||
Open()
|
||||
}
|
||||
}
|
||||
if lCreate
|
||||
new QSqlQuery( ) {
|
||||
exec("create table weighthistory (id integer primary key,"+
|
||||
" f_date varchar(10),"+
|
||||
" f_time varchar(8), f_weight varchar(8) );")
|
||||
delete()
|
||||
}
|
||||
ok
|
||||
|
||||
|
||||
Func CloseDatabase
|
||||
oCon.Close()
|
||||
|
||||
Func AddWeight
|
||||
cWeight = text1.text()
|
||||
AddRecord(cWeight)
|
||||
|
||||
Func DeleteWeight
|
||||
Table1 {
|
||||
nRow = CurrentRow()
|
||||
if nRow >= 0
|
||||
nID = this.aIDs[nROW+1]
|
||||
new QSqlQuery( ) {
|
||||
exec("delete from weighthistory where id = " + nID )
|
||||
}
|
||||
Del(this.aIDs,nRow+1)
|
||||
removerow(nRow)
|
||||
selectrow(nRow)
|
||||
ok
|
||||
}
|
||||
|
||||
|
||||
Func AddRecord cWeight
|
||||
new QSqlQuery( ) {
|
||||
cStr = "insert into weighthistory (f_date,f_time,f_weight) values"+
|
||||
" ('%f1','%f2','%f3')"
|
||||
cDate = Date()
|
||||
cTime = Time()
|
||||
cStr = substr(cStr,"%f1",cDate)
|
||||
cStr = substr(cStr,"%f2",cTime)
|
||||
cStr = substr(cStr,"%f3",cWeight)
|
||||
exec(cStr)
|
||||
delete()
|
||||
}
|
||||
ShowRecords()
|
||||
Table1.selectrow(table1.rowcount()-1)
|
||||
|
||||
|
||||
Func ShowRecords
|
||||
table1.setitemChangedEvent("")
|
||||
aIDs = []
|
||||
query = new QSqlQuery() {
|
||||
exec("select * from weighthistory")
|
||||
nRows = 0
|
||||
this.Table1.setrowcount(0)
|
||||
while movenext()
|
||||
this.table1 {
|
||||
insertRow(nRows)
|
||||
this.aIDs + query.value(0).tostring()
|
||||
for x = 1 to 3
|
||||
cStr = query.value(x).tostring()
|
||||
item = new qTableWidgetItem(cStr)
|
||||
setItem(nRows,x-1,item)
|
||||
next
|
||||
}
|
||||
nRows++
|
||||
end
|
||||
delete()
|
||||
}
|
||||
table1.setitemChangedEvent($ApplicationObject+".ItemChanged()")
|
||||
|
||||
Func ItemChanged
|
||||
nRow = table1.currentrow()
|
||||
if nRow >= 0
|
||||
myitem = Table1.item(table1.currentrow(),0)
|
||||
cDate = myitem.text()
|
||||
myitem = Table1.item(table1.currentrow(),1)
|
||||
cTime = myitem.text()
|
||||
myitem = Table1.item(table1.currentrow(),2)
|
||||
cWeight = myitem.text()
|
||||
new QSqlQuery( ) {
|
||||
cStr = "update weighthistory set f_date ='%f1' , f_time = '%f2' , "+
|
||||
"f_weight ='%f3' where id = " + this.aIDs[nROW+1]
|
||||
cStr = substr(cStr,"%f1",cDate)
|
||||
cStr = substr(cStr,"%f2",cTime)
|
||||
cStr = substr(cStr,"%f3",cWeight)
|
||||
exec(cStr)
|
||||
delete()
|
||||
}
|
||||
ok
|
||||
897
samples/Roff/trekmanual.nr
Normal file
897
samples/Roff/trekmanual.nr
Normal file
@@ -0,0 +1,897 @@
|
||||
.\" $FreeBSD: src/games/trek/DOC/trekmanual.nr,v 1.1.1.1.14.1 2002/08/15 18:10:56 schweikh Exp $
|
||||
.\" $DragonFly: src/games/trek/DOC/trekmanual.nr,v 1.2 2003/06/17 04:25:25 dillon Exp $
|
||||
.br
|
||||
.po 10
|
||||
.if n \!.
|
||||
.sp 15
|
||||
.tr ^ \"
|
||||
.ce 88
|
||||
^****^^^^*****^^^^^^*^^^^^^****^
|
||||
*^^^^^^^^^^*^^^^^^^*^*^^^^^*^^^*
|
||||
^***^^^^^^^*^^^^^^*****^^^^****^
|
||||
^^^^*^^^^^^*^^^^^^*^^^*^^^^*^^*^
|
||||
****^^^^^^^*^^^^^^*^^^*^^^^*^^^*
|
||||
|
||||
|
||||
*****^^^^****^^^^^*****^^^^*^^^*
|
||||
^^*^^^^^^*^^^*^^^^*^^^^^^^^*^^*^
|
||||
^^*^^^^^^****^^^^^***^^^^^^***^^
|
||||
^^*^^^^^^*^^*^^^^^*^^^^^^^^*^^*^
|
||||
^^*^^^^^^*^^^*^^^^*****^^^^*^^^*
|
||||
|
||||
|
||||
by
|
||||
|
||||
Eric Allman
|
||||
University of California
|
||||
Berkeley
|
||||
.ce 0
|
||||
.tr ^^
|
||||
.de HE
|
||||
'sp 4
|
||||
'tl 'STAR TREK''%'
|
||||
'sp 3
|
||||
..
|
||||
.de FO
|
||||
'bp
|
||||
..
|
||||
.wh 0 HE
|
||||
.wh -5 FO
|
||||
.de pp
|
||||
.sp
|
||||
.ti +4
|
||||
..
|
||||
.bp 1
|
||||
.ce
|
||||
INTRODUCTION
|
||||
.pp
|
||||
Well, the federation is once again at war with the Klingon empire.
|
||||
It is up to you,
|
||||
as captain of the U.S.S. Enterprise,
|
||||
to wipe out the invasion fleet and save the Federation.
|
||||
.pp
|
||||
For the purposes of the game
|
||||
the galaxy is divided into 64 quadrants
|
||||
on an eight by eight grid,
|
||||
with quadrant 0,0 in the upper left hand corner.
|
||||
Each quadrant is divided into 100 sectors
|
||||
on a ten by ten grid.
|
||||
Each sector contains one object
|
||||
(e.g., the Enterprise, a Klingon, or a star).
|
||||
.pp
|
||||
Navigation is handled in degrees,
|
||||
with zero being straight up
|
||||
and ninety being to the right.
|
||||
Distances are measured in quadrants.
|
||||
One tenth quadrant is one sector.
|
||||
.pp
|
||||
The galaxy contains starbases,
|
||||
at which you can dock to refuel,
|
||||
repair damages, etc.
|
||||
The galaxy also contains stars.
|
||||
Stars usually have a knack for getting in your way,
|
||||
but they can be triggered into going nova
|
||||
by shooting a photon torpedo at one,
|
||||
thereby (hopefully) destroying any adjacent Klingons.
|
||||
This is not a good practice however,
|
||||
because you are penalized for destroying stars.
|
||||
Also, a star will sometimes go supernova,
|
||||
which obliterates an entire quadrant.
|
||||
You must never stop in a supernova quadrant,
|
||||
although you may "jump over" one.
|
||||
.pp
|
||||
Some starsystems
|
||||
have inhabited planets.
|
||||
Klingons can attack inhabited planets
|
||||
and enslave the populace,
|
||||
which they then put to work building more Klingon battle cruisers.
|
||||
.bp
|
||||
.ce
|
||||
STARTING UP THE GAME
|
||||
.pp
|
||||
To request the game, issue the command
|
||||
.sp
|
||||
.ti +12
|
||||
/usr/games/trek
|
||||
.sp
|
||||
from the shell.
|
||||
If a filename is stated,
|
||||
a log of the game is written
|
||||
onto that file.
|
||||
If omitted,
|
||||
the file is not written.
|
||||
If the "-a" flag is stated before the filename,
|
||||
that file is appended to
|
||||
rather than created.
|
||||
.pp
|
||||
The game will ask you what length game
|
||||
you would like.
|
||||
Valid responses are "short", "medium", and "long".
|
||||
Ideally the length of the game does not
|
||||
affect the difficulty,
|
||||
but currently the shorter games
|
||||
tend to be harder than the longer ones.
|
||||
You may also type "restart",
|
||||
which restarts a previously saved game.
|
||||
.pp
|
||||
You will then be prompted for the skill,
|
||||
to which you must respond
|
||||
"novice", "fair", "good", "expert",
|
||||
"commodore", or "impossible".
|
||||
You should start out with a novice
|
||||
and work up,
|
||||
but if you really want to see how fast
|
||||
you can be slaughtered,
|
||||
start out with an impossible game.
|
||||
.pp
|
||||
In general,
|
||||
throughout the game,
|
||||
if you forget what is appropriate
|
||||
the game will tell you what it expects
|
||||
if you just type in
|
||||
a question mark.
|
||||
.pp
|
||||
To get a copy of these rules,
|
||||
execute the command
|
||||
.sp
|
||||
.ti +12
|
||||
nroff /usr/games/trekmanual.nr
|
||||
.sp
|
||||
.bp
|
||||
.ce
|
||||
ISSUING COMMANDS
|
||||
.pp
|
||||
If the game expects you to enter a command,
|
||||
.hc ^
|
||||
it will say ^"Command:\ "
|
||||
and wait for your response.
|
||||
Most commands can be abbreviated.
|
||||
.pp
|
||||
At almost any time you can type more than one thing on a line.
|
||||
For example,
|
||||
to move straight up one quadrant,
|
||||
you can type
|
||||
.ti +12
|
||||
move 0 1
|
||||
.br
|
||||
or you could just type
|
||||
.ti +12
|
||||
move
|
||||
.br
|
||||
and the game would prompt you with
|
||||
.ti +12
|
||||
Course:
|
||||
.br
|
||||
to which you could type
|
||||
.ti +12
|
||||
0 1
|
||||
.br
|
||||
The "1" is the distance,
|
||||
which could be put on still another line.
|
||||
Also, the "move" command
|
||||
could have been abbreviated
|
||||
"mov", "mo", or just "m".
|
||||
.pp
|
||||
If you are partway through a command
|
||||
and you change your mind,
|
||||
you can usually type "-1"
|
||||
to cancel the command.
|
||||
.pp
|
||||
Klingons generally cannot hit you
|
||||
if you don't consume anything
|
||||
(e.g., time or energy),
|
||||
so some commands are considered "free".
|
||||
As soon as you consume anything though -- POW!
|
||||
.bp
|
||||
.de **
|
||||
.if \\n+l .**
|
||||
.as x *
|
||||
..
|
||||
.de bl
|
||||
.nr l \\w'\\$1' -\\w'*'
|
||||
.ds x ****
|
||||
.**
|
||||
.sp 3
|
||||
.ne 3
|
||||
\\*x
|
||||
.br
|
||||
.if t *\h'\w'*'u'\fB\\$1\fP\h'\w'*'u'*
|
||||
.if n * \\$1 *
|
||||
.br
|
||||
\\*x
|
||||
.sp
|
||||
.in +8
|
||||
.nf
|
||||
..
|
||||
.de FF
|
||||
.in -8
|
||||
.fi
|
||||
..
|
||||
.if !\n(.V .ta \w'Full Commands: '+1
|
||||
.if \n(.V .ta \w'Full Commands: 'u
|
||||
.ce
|
||||
THE COMMANDS
|
||||
.bl "Short Range Scan"
|
||||
Mnemonic: srscan
|
||||
Shortest Abbreviation: s
|
||||
Full Commands: srscan
|
||||
srscan yes/no
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
The short range scan
|
||||
gives you a picture
|
||||
of the quadrant you are in,
|
||||
and (if you say "yes")
|
||||
a status report
|
||||
which tells you
|
||||
a whole bunch
|
||||
of interesting stuff.
|
||||
You can get a status report alone
|
||||
by using the
|
||||
.ul
|
||||
status
|
||||
command.
|
||||
An example follows:
|
||||
.sp
|
||||
.nf
|
||||
.in +4
|
||||
Short range sensor scan
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
0 . . . . . . . * . * 0 stardate 3702.16
|
||||
1 . . E . . . . . . . 1 condition RED
|
||||
2 . . . . . . . . . * 2 position 0,3/1,2
|
||||
3 * . . . . # . . . . 3 warp factor 5.0
|
||||
4 . . . . . . . . . . 4 total energy 4376
|
||||
5 . . * . * . . . . . 5 torpedoes 9
|
||||
6 . . . @ . . . . . 6 shields down, 78%
|
||||
7 . . . . . . . . . . 7 Klingons left 3
|
||||
8 . . . K . . . . . . 8 time left 6.43
|
||||
9 . . . . . . * . . . 9 life support damaged, reserves = 2.4
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
Distressed Starsystem Marcus XII
|
||||
|
||||
.in +8
|
||||
.ti -8
|
||||
The cast of characters is as follows:
|
||||
E the hero
|
||||
K the villain
|
||||
# the starbase
|
||||
* stars
|
||||
@ inhabited starsystem
|
||||
\&. empty space
|
||||
a black hole
|
||||
.in -12
|
||||
.fi
|
||||
.pp
|
||||
The name of the starsystem is listed underneath
|
||||
the short range scan.
|
||||
The word "distressed", if present,
|
||||
means that the starsystem
|
||||
is under attack.
|
||||
.pp
|
||||
Short range scans are absolutely free.
|
||||
They use no time, no energy,
|
||||
and they don't give the Klingons
|
||||
another chance to hit you.
|
||||
.bl "Status Report"
|
||||
Mnemonic: status
|
||||
Shortest Abbreviation: st
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
This command gives you information
|
||||
about the current status
|
||||
of the game and your ship, as follows:
|
||||
.in +8
|
||||
.de qq
|
||||
.sp
|
||||
.ti -4
|
||||
..
|
||||
.qq
|
||||
Stardate -- The current stardate.
|
||||
.qq
|
||||
Condition -- as follows:
|
||||
.in +4
|
||||
.nf
|
||||
RED -- in battle
|
||||
YELLOW -- low on energy
|
||||
GREEN -- normal state
|
||||
DOCKED -- docked at starbase
|
||||
CLOAKED -- the cloaking device is activated
|
||||
.fi
|
||||
.in -4
|
||||
.qq
|
||||
Position -- Your current quadrant and sector.
|
||||
.qq
|
||||
Warp Factor -- The speed you will move at
|
||||
when you move under warp power
|
||||
(with the
|
||||
.ul
|
||||
move
|
||||
command).
|
||||
.qq
|
||||
Total Energy -- Your energy reserves.
|
||||
If they drop to zero,
|
||||
you die.
|
||||
Energy regenerates,
|
||||
but the higher the skill of the game,
|
||||
the slower it regenerates.
|
||||
.qq
|
||||
Torpedoes -- How many photon torpedoes you have left.
|
||||
.qq
|
||||
Shields -- Whether your shields are up or down,
|
||||
and how effective they are if up
|
||||
(what percentage of a hit they will absorb).
|
||||
.qq
|
||||
Klingons Left -- Guess.
|
||||
.qq
|
||||
Time Left -- How long the Federation can hold out
|
||||
if you sit on your fat ass and do nothing.
|
||||
If you kill Klingons quickly,
|
||||
this number goes up,
|
||||
otherwise,
|
||||
it goes down.
|
||||
If it hits zero,
|
||||
the Federation is conquered.
|
||||
.qq
|
||||
Life Support -- If "active", everything is fine.
|
||||
If "damaged", your reserves tell you
|
||||
how long you have
|
||||
to repair your life support
|
||||
or get to a starbase
|
||||
before you starve, suffocate,
|
||||
or something equally unpleasant.
|
||||
.qq
|
||||
Current Crew -- The number of crew members
|
||||
left.
|
||||
This figures does not include officers.
|
||||
.qq
|
||||
Brig Space -- The space left in your brig
|
||||
for Klingon captives.
|
||||
.qq
|
||||
Klingon Power -- The number of units
|
||||
needed to kill a Klingon.
|
||||
Remember, as Klingons fire at you
|
||||
they use up their own energy,
|
||||
so you probably need somewhat less
|
||||
than this.
|
||||
.qq
|
||||
Skill, Length -- The skill and length
|
||||
of the game you are playing.
|
||||
.in -8
|
||||
.pp
|
||||
Status information is absolutely free.
|
||||
.bl "Long Range Scan"
|
||||
Mnemonic: lrscan
|
||||
Shortest Abbreviation: l
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
Long range scan gives you information about the
|
||||
eight quadrants
|
||||
that surround the quadrant
|
||||
you're in.
|
||||
A sample long range scan follows:
|
||||
.sp
|
||||
.in +12
|
||||
.nf
|
||||
Long range scan for quadrant 0,3
|
||||
|
||||
2 3 4
|
||||
-------------------
|
||||
! * ! * ! * !
|
||||
-------------------
|
||||
0 ! 108 ! 6 ! 19 !
|
||||
-------------------
|
||||
1 ! 9 ! /// ! 8 !
|
||||
-------------------
|
||||
.sp
|
||||
.in -12
|
||||
.fi
|
||||
.pp
|
||||
The three digit numbers
|
||||
tell the number of objects
|
||||
in the quadrants.
|
||||
The units digit tells the number of stars,
|
||||
the tens digit the number of starbases,
|
||||
and the hundreds digit is the number of Klingons.
|
||||
"*" indicates the negative energy barrier
|
||||
at the edge of the galaxy,
|
||||
which you cannot enter.
|
||||
"///" means that that is a supernova quadrant
|
||||
and must not be entered.
|
||||
.bl "Damage Report"
|
||||
Mnemonic: damages
|
||||
Shortest Abbreviation: da
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
A damage report tells you what devices are damaged
|
||||
and how long it will take to repair them.
|
||||
Repairs proceed faster
|
||||
when you are docked
|
||||
at a starbase.
|
||||
.bl "Set Warp Factor"
|
||||
Mnemonic: warp
|
||||
Shortest Abbreviation: w
|
||||
Full Command: warp factor
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
The warp factor tells the speed of your starship
|
||||
when you move under warp power
|
||||
(with the
|
||||
.ul
|
||||
move
|
||||
command).
|
||||
The higher the warp factor,
|
||||
the faster you go,
|
||||
and the more energy you use.
|
||||
.pp
|
||||
The minimum warp factor is 1.0
|
||||
and the maximum is 10.0.
|
||||
At speeds above warp 6
|
||||
there is danger of the warp engines
|
||||
being damaged.
|
||||
The probability of this
|
||||
increases at higher warp speeds.
|
||||
Above warp 9.0 there is a chance of entering
|
||||
a time warp.
|
||||
.bl "Move Under Warp Power"
|
||||
Mnemonic: move
|
||||
Shortest Abbreviation: m
|
||||
Full Command: move course distance
|
||||
Consumes: time and energy
|
||||
.FF
|
||||
.pp
|
||||
This is the usual way of moving.
|
||||
The course is in degrees and the distance is in quadrants.
|
||||
To move one sector specify a distance of 0.1.
|
||||
.pp
|
||||
Time is consumed proportionately to
|
||||
the inverse of the warp factor squared,
|
||||
and directly to the distance.
|
||||
Energy is consumed as the warp factor cubed,
|
||||
and directly to the distance.
|
||||
If you move with your shields up
|
||||
it doubles the amount of energy consumed.
|
||||
.pp
|
||||
When you move in a quadrant containing Klingons,
|
||||
they get a chance to attack you.
|
||||
.pp
|
||||
The computer detects navigation errors.
|
||||
If the computer is out,
|
||||
you run the risk of running into things.
|
||||
.pp
|
||||
The course is determined by the
|
||||
Space Inertial Navigation System
|
||||
[SINS].
|
||||
As described in
|
||||
Star Fleet Technical Order TO:02:06:12,
|
||||
the SINS is calibrated,
|
||||
after which it becomes the base for navigation.
|
||||
If damaged,
|
||||
navigation becomes inaccurate.
|
||||
When it is fixed,
|
||||
Spock recalibrates it,
|
||||
however,
|
||||
it cannot be calibrated extremely accurately
|
||||
until you dock at starbase.
|
||||
.bl "Move Under Impulse Power"
|
||||
Mnemonic: impulse
|
||||
Shortest Abbreviation: i
|
||||
Full Command: impulse course distance
|
||||
Consumes: time and energy
|
||||
.FF
|
||||
.pp
|
||||
The impulse engines give you a chance to maneuver
|
||||
when your warp engines are damaged;
|
||||
however, they are incredibly slow
|
||||
(0.095 quadrants/stardate).
|
||||
They require 20 units of energy to engage,
|
||||
and ten units per sector to move.
|
||||
.pp
|
||||
The same comments about the computer and the SINS
|
||||
apply as above.
|
||||
.pp
|
||||
There is no penalty to move under impulse power
|
||||
with shields up.
|
||||
.bl "Deflector Shields"
|
||||
Mnemonic: shields
|
||||
Shortest Abbreviation: sh
|
||||
Full Command: shields up/down
|
||||
Consumes: energy
|
||||
.FF
|
||||
.pp
|
||||
Shields protect you from Klingon attack
|
||||
and nearby novas.
|
||||
As they protect you,
|
||||
they weaken.
|
||||
A shield which is 78% effective
|
||||
will absorb 78% of a hit
|
||||
and let 22% in to hurt you.
|
||||
.pp
|
||||
The Klingons have a chance to attack you
|
||||
every time you raise or lower shields.
|
||||
Shields do not rise and lower
|
||||
instantaneously,
|
||||
so the hit you receive
|
||||
will be computed with the shields
|
||||
at an intermediate effectiveness.
|
||||
.pp
|
||||
It takes energy to raise shields,
|
||||
but not to drop them.
|
||||
.bl "Cloaking Device"
|
||||
Mnemonic: cloak
|
||||
Shortest Abbreviation: cl
|
||||
Full Command: cloak up/down
|
||||
Consumes: energy
|
||||
.FF
|
||||
.pp
|
||||
When you are cloaked,
|
||||
Klingons cannot see you,
|
||||
and hence they do not fire at you.
|
||||
They are useful for entering
|
||||
a quadrant
|
||||
and selecting a good position,
|
||||
however,
|
||||
weapons cannot be fired through
|
||||
the cloak
|
||||
due to the huge energy drain
|
||||
that it requires.
|
||||
.pp
|
||||
The cloak up command
|
||||
only starts the cloaking process;
|
||||
Klingons will continue
|
||||
to fire at you
|
||||
until you do something
|
||||
which consumes time.
|
||||
.bl "Fire Phasers"
|
||||
Mnemonic: phasers
|
||||
Shortest Abbreviation: p
|
||||
Full Commands: phasers automatic amount
|
||||
phasers manual amt1 course1 spread1 ...
|
||||
Consumes: energy
|
||||
.FF
|
||||
.pp
|
||||
Phasers are energy weapons;
|
||||
the energy comes from your ship's reserves
|
||||
("total energy" on a srscan).
|
||||
It takes about 250 units of hits
|
||||
to kill a Klingon.
|
||||
Hits are cumulative as long as you stay
|
||||
in the quadrant.
|
||||
.pp
|
||||
Phasers become less effective
|
||||
the further from a Klingon you are.
|
||||
Adjacent Klingons receive about
|
||||
90% of what you fire,
|
||||
at five sectors about 60%,
|
||||
and at ten sectors about 35%.
|
||||
They have no effect outside of the quadrant.
|
||||
.pp
|
||||
Phasers cannot be fired while shields are up;
|
||||
to do so would fry you.
|
||||
They have no effect on starbases or stars.
|
||||
.pp
|
||||
In automatic mode
|
||||
the computer decides how to divide up the energy
|
||||
among the Klingons present;
|
||||
in manual mode you do that yourself.
|
||||
.pp
|
||||
In manual mode firing
|
||||
you specify a direction,
|
||||
amount (number of units to fire)
|
||||
and spread (0 -> 1.0)
|
||||
for each of the six phaser banks.
|
||||
A zero amount
|
||||
terminates the manual input.
|
||||
.bl "Fire Photon Torpedoes"
|
||||
Mnemonic: torpedo
|
||||
Shortest Abbreviation: t
|
||||
Full Command: torpedo course [yes/no] [burst angle]
|
||||
Consumes: torpedoes
|
||||
.FF
|
||||
.pp
|
||||
Torpedoes are projectile weapons -- there are no partial hits.
|
||||
You either hit your target or you don't.
|
||||
A hit on a Klingon destroys him.
|
||||
A hit on a starbase destroys that starbase
|
||||
(woops!).
|
||||
Hitting a star usually causes it to go nova,
|
||||
and occasionally supernova.
|
||||
.pp
|
||||
Photon torpedoes cannot be aimed precisely.
|
||||
They can be fired with shields up,
|
||||
but they get even more random
|
||||
as they pass through the shields.
|
||||
.pp
|
||||
Torpedoes may be fired in bursts of three.
|
||||
If this is desired,
|
||||
the burst angle is the angle
|
||||
between the three shots,
|
||||
which may vary from one to fifteen.
|
||||
The word "no"
|
||||
says that a burst is not wanted;
|
||||
the word "yes"
|
||||
(which may be omitted
|
||||
if stated on the same line as the course)
|
||||
says that a burst is wanted.
|
||||
.pp
|
||||
Photon torpedoes
|
||||
have no effect
|
||||
outside the quadrant.
|
||||
.bl "Onboard Computer Request"
|
||||
Mnemonic: computer
|
||||
Shortest Abbreviation: c
|
||||
Full Command: computer request; request;...
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
The computer command gives you access to the facilities
|
||||
of the onboard computer,
|
||||
which allows you to do all sorts of fascinating stuff.
|
||||
Computer requests are:
|
||||
.in +8
|
||||
.qq
|
||||
score -- Shows your current score.
|
||||
.qq
|
||||
course quad/sect -- Computes the course and distance from wherever
|
||||
you are to the given location.
|
||||
If you type "course /x,y"
|
||||
you will be given the course
|
||||
to sector x,y in the current quadrant.
|
||||
.qq
|
||||
move quad/sect -- Identical to the course
|
||||
request,
|
||||
except that the move is executed.
|
||||
.qq
|
||||
chart -- prints a chart of the known galaxy,
|
||||
i.e.,
|
||||
everything that you have seen with a long range scan.
|
||||
The format is the same as on a long range scan,
|
||||
except that "..." means
|
||||
that you don't yet know what is there,
|
||||
and ".1." means that you know that a starbase
|
||||
exists, but you don't know anything else.
|
||||
"$$$" mans the quadrant
|
||||
that you are currently in.
|
||||
.qq
|
||||
trajectory -- prints the course and distance
|
||||
to all the Klingons in the quadrant.
|
||||
.qq
|
||||
warpcost dist warp_factor -- computes the cost in time and energy
|
||||
to move `dist' quadrants at warp `warp_factor'.
|
||||
.qq
|
||||
impcost dist -- same as warpcost for impulse engines.
|
||||
.qq
|
||||
pheff range -- tells how effective your phasers are
|
||||
at a given range.
|
||||
.qq
|
||||
distresslist -- gives a list of currently distressed
|
||||
starbases
|
||||
and starsystems.
|
||||
.in -8
|
||||
.pp
|
||||
More than one request may be stated
|
||||
on a line
|
||||
by separating them
|
||||
with semicolons.
|
||||
.bl "Dock at Starbase"
|
||||
Mnemonic: dock
|
||||
Shortest Abbreviation: do
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
You may dock at a starbase
|
||||
when you are in one of the eight
|
||||
adjacent sectors.
|
||||
.pp
|
||||
When you dock you are resupplied
|
||||
with energy, photon torpedoes, and life support reserves.
|
||||
Repairs are also done faster at starbase.
|
||||
Any prisoners you have taken
|
||||
are unloaded.
|
||||
You do not receive points
|
||||
for taking prisoners
|
||||
until this time.
|
||||
.pp
|
||||
Starbases have their own deflector shields,
|
||||
so you are safe from attack while docked.
|
||||
.bl "Undock from Starbase"
|
||||
Mnemonic: undock
|
||||
Shortest Abbreviation: u
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
This just allows you to leave starbase
|
||||
so that you may proceed on your way.
|
||||
.bl "Rest"
|
||||
Mnemonic: rest
|
||||
Shortest Abbreviation: r
|
||||
Full Command: rest time
|
||||
Consumes: time
|
||||
.FF
|
||||
.pp
|
||||
This command allows you to rest to repair damages.
|
||||
It is not advisable to rest while under attack.
|
||||
.bl "Call Starbase For Help"
|
||||
Mnemonic: help
|
||||
Shortest Abbreviation: help
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
You may call starbase for help via your subspace radio.
|
||||
Starbase has long range transporter beams to get you.
|
||||
Problem is,
|
||||
they can't always rematerialize you.
|
||||
.pp
|
||||
You should avoid using this command unless absolutely necessary,
|
||||
for the above reason and because it counts heavily against you
|
||||
in the scoring.
|
||||
.bl "Capture Klingon"
|
||||
Mnemonic: capture
|
||||
Shortest Abbreviation: ca
|
||||
Consumes: time
|
||||
.FF
|
||||
.pp
|
||||
You may request that a Klingon surrender
|
||||
to you.
|
||||
If he accepts,
|
||||
you get to take captives
|
||||
(but only as many as your brig
|
||||
can hold).
|
||||
It is good if you do this,
|
||||
because you get points for captives.
|
||||
Also,
|
||||
if you ever get captured,
|
||||
you want to be sure that the Federation
|
||||
has prisoners to exchange for you.
|
||||
.pp
|
||||
You must go to a starbase
|
||||
to turn over your prisoners
|
||||
to Federation authorities.
|
||||
.bl "Visual Scan"
|
||||
Mnemonic: visual
|
||||
Shortest Abbreviation: v
|
||||
Full Command: visual course
|
||||
Consumes: time
|
||||
.FF
|
||||
.pp
|
||||
When your short range scanners are out,
|
||||
you can still see what is out "there"
|
||||
by doing a visual scan.
|
||||
Unfortunately,
|
||||
you can only see three sectors at one time,
|
||||
and it takes 0.005 stardates to perform.
|
||||
.pp
|
||||
The three sectors in the general direction
|
||||
of the course specified
|
||||
are examined
|
||||
and displayed.
|
||||
.bl "Abandon Ship"
|
||||
Mnemonic: abandon
|
||||
Shortest Abbreviation: abandon
|
||||
Consumes: nothing
|
||||
.FF
|
||||
.pp
|
||||
The officers escape the Enterprise in the shuttlecraft.
|
||||
If the transporter is working
|
||||
and there is an inhabitable starsystem
|
||||
in the area,
|
||||
the crew beams down,
|
||||
otherwise you leave them to die.
|
||||
You are given an old but still usable ship,
|
||||
the Faire Queene.
|
||||
.bl "Ram"
|
||||
Mnemonic: ram
|
||||
Shortest Abbreviation: ram
|
||||
Full Command: ram course distance
|
||||
Consumes: time and energy
|
||||
.FF
|
||||
.pp
|
||||
This command is identical to "move",
|
||||
except that the computer
|
||||
doesn't stop you
|
||||
from making navigation errors.
|
||||
.pp
|
||||
You get very nearly slaughtered
|
||||
if you ram anything.
|
||||
.bl "Self Destruct"
|
||||
Mnemonic: destruct
|
||||
Shortest Abbreviation: destruct
|
||||
Consumes: everything
|
||||
.FF
|
||||
.pp
|
||||
Your starship is self-destructed.
|
||||
Chances are you will destroy
|
||||
any Klingons
|
||||
(and stars,
|
||||
and starbases)
|
||||
left in your quadrant.
|
||||
.bl "Terminate the Game"
|
||||
Mnemonic: terminate
|
||||
Shortest Abbreviation: terminate
|
||||
Full Command: terminate yes/no
|
||||
.FF
|
||||
.pp
|
||||
Cancels the current game.
|
||||
No score is computed.
|
||||
If you answer yes,
|
||||
a new game will be started,
|
||||
otherwise trek exits.
|
||||
.bl "Call the Shell"
|
||||
Mnemonic: shell
|
||||
Shortest Abbreviation: shell
|
||||
.FF
|
||||
.pp
|
||||
Temporarily escapes to the shell.
|
||||
When you log out of the shell
|
||||
you will return to the game.
|
||||
.bp
|
||||
.ce
|
||||
SCORING
|
||||
.in +4
|
||||
.pp
|
||||
The scoring algorithm is rather complicated.
|
||||
Basically,
|
||||
you get points for each Klingon you kill,
|
||||
for your Klingon per stardate kill rate,
|
||||
and a bonus if you win the game.
|
||||
You lose
|
||||
points for the number of Klingons left
|
||||
in the galaxy
|
||||
at the end of the game,
|
||||
for getting killed,
|
||||
for each star, starbase, or inhabited starsystem
|
||||
you destroy,
|
||||
for calling for help,
|
||||
and for each casualty you incur.
|
||||
.pp
|
||||
You will be promoted
|
||||
if you play very well.
|
||||
You will never get a promotion if you
|
||||
call for help,
|
||||
abandon the Enterprise,
|
||||
get killed,
|
||||
destroy a starbase or inhabited starsystem,
|
||||
or destroy too many stars.
|
||||
.bp
|
||||
.ce
|
||||
REFERENCE PAGE
|
||||
.sp 2
|
||||
.ta 36 56
|
||||
.nf
|
||||
.ul
|
||||
Command Uses Consumes
|
||||
|
||||
ABANDON shuttlecraft, -
|
||||
transporter
|
||||
CApture subspace radio time
|
||||
CLoak Up/Down cloaking device energy
|
||||
Computer request; request;... computer -
|
||||
DAmages - -
|
||||
DESTRUCT computer -
|
||||
DOck - -
|
||||
HELP subspace radio -
|
||||
Impulse course distance impulse engines, time, energy
|
||||
computer, SINS
|
||||
Lrscan L.R. sensors -
|
||||
Move course distance warp engines, time, energy
|
||||
computer, SINS
|
||||
Phasers Automatic amount phasers, computer energy
|
||||
Phasers Manual amt1 course1 spread1 ... phasers energy
|
||||
Torpedo course [Yes] angle/No torpedo tubes torpedoes
|
||||
RAM course distance warp engines, time, energy
|
||||
computer, SINS
|
||||
Rest time - time
|
||||
SHELL - -
|
||||
SHields Up/Down shields energy
|
||||
Srscan [Yes/No] S.R. sensors -
|
||||
STatus - -
|
||||
TERMINATE Yes/No - -
|
||||
Undock - -
|
||||
Visual course - time
|
||||
Warp warp_factor - -
|
||||
.fi
|
||||
39
samples/Type Language/builtin.tl
Normal file
39
samples/Type Language/builtin.tl
Normal file
@@ -0,0 +1,39 @@
|
||||
// built-in types
|
||||
int#a8509bda ? = Int;
|
||||
long ? = Long;
|
||||
double ? = Double;
|
||||
string ? = String;
|
||||
null = Null;
|
||||
|
||||
vector {t:Type} # [ t ] = Vector t;
|
||||
coupleInt {alpha:Type} int alpha = CoupleInt<alpha>;
|
||||
coupleStr {gamma:Type} string gamma = CoupleStr gamma;
|
||||
|
||||
/* The name of the type variable is irrelevant: "gamma" could be replaced with "alpha"
|
||||
However, the combinator number will depend on the specific choice. */
|
||||
|
||||
intHash {alpha:Type} vector<coupleInt<alpha>> = IntHash<alpha>;
|
||||
strHash {alpha:Type} (vector (coupleStr alpha)) = StrHash alpha;
|
||||
intSortedHash {alpha:Type} intHash<alpha> = IntSortedHash<alpha>;
|
||||
strSortedHash {alpha:Type} (strHash alpha) = StrSortedHash alpha;
|
||||
|
||||
// custom types
|
||||
pair x:Object y:Object = Pair;
|
||||
triple x:Object y:Object z:Object = Triple;
|
||||
|
||||
user#d23c81a3 id:int first_name:string last_name:string = User;
|
||||
no_user#c67599d1 id:int = User;
|
||||
group id:int title:string last_name:string = Group;
|
||||
no_group = Group;
|
||||
|
||||
---functions---
|
||||
|
||||
// Maybe some built-in arithmetic functions; inverse quotes make "identifiers" out of arbitrary non-alphanumeric strings
|
||||
`+` Int Int = Int;
|
||||
`-` Int Int = Int;
|
||||
`+` Double Double = Double;
|
||||
// ...
|
||||
|
||||
// API functions (aka RPC functions)
|
||||
getUser#b0f732d5 int = User;
|
||||
getUsers#2d84d5f5 (Vector int) = Vector User;
|
||||
1102
samples/Type Language/scheme.tl
Normal file
1102
samples/Type Language/scheme.tl
Normal file
File diff suppressed because it is too large
Load Diff
14
samples/WebAssembly/add.wat
Normal file
14
samples/WebAssembly/add.wat
Normal file
@@ -0,0 +1,14 @@
|
||||
(module
|
||||
(import "env" "printInt" (func $printInt (param i32)))
|
||||
(func $add (param $lhs i32) (param $rhs i32) (result i32)
|
||||
get_local $lhs
|
||||
get_local $rhs
|
||||
i32.add
|
||||
)
|
||||
|
||||
(func $main
|
||||
(call $printInt
|
||||
(call $add (i32.const 9) (i32.const 8))))
|
||||
|
||||
(export "main" (func $main))
|
||||
)
|
||||
41
samples/WebAssembly/fibonacci.wat
Normal file
41
samples/WebAssembly/fibonacci.wat
Normal file
@@ -0,0 +1,41 @@
|
||||
(module
|
||||
(import "env" "printInt" (func $printInt (param i32)))
|
||||
(import "env" "print" (func $print (param i32 i32)))
|
||||
|
||||
(memory $memory 1)
|
||||
(data (i32.const 0) "\n")
|
||||
(data (i32.const 1) " ")
|
||||
|
||||
(func $endl
|
||||
(call $print (i32.const 0) (i32.const 1)))
|
||||
(func $space
|
||||
(call $print (i32.const 1) (i32.const 1)))
|
||||
|
||||
(func $fibonacci_rec (param $a i32) (param $b i32) (param $n i32) (result i32)
|
||||
(if (i32.eqz (get_local $n)) (return (get_local $a)))
|
||||
(call $printInt (get_local $b))
|
||||
(call $space)
|
||||
(set_local $a (i32.add (get_local $a) (get_local $b)))
|
||||
(call $fibonacci_rec (get_local $b) (get_local $a) (i32.sub (get_local $n) (i32.const 1)))
|
||||
)
|
||||
|
||||
(func $fibonacci_iter (param $a i32) (param $b i32) (param $n i32) (result i32)
|
||||
(loop $fi
|
||||
(if (i32.eqz (get_local $n)) (return (get_local $a)))
|
||||
(call $printInt (get_local $b))
|
||||
(call $space)
|
||||
(set_local $b (i32.add (get_local $a) (get_local $b)))
|
||||
(set_local $a (i32.sub (get_local $b) (get_local $a)))
|
||||
(set_local $n (i32.sub (get_local $n) (i32.const 1)))
|
||||
(br $fi))
|
||||
(get_local $b))
|
||||
|
||||
(func $main
|
||||
(drop (call $fibonacci_rec (i32.const 0) (i32.const 1) (i32.const 9)))
|
||||
(call $endl)
|
||||
(drop (call $fibonacci_iter (i32.const 0) (i32.const 1) (i32.const 9))))
|
||||
|
||||
(export "main" (func $main))
|
||||
(export "memory" (memory $memory))
|
||||
)
|
||||
|
||||
48
samples/WebAssembly/imported-min.wast
Normal file
48
samples/WebAssembly/imported-min.wast
Normal file
@@ -0,0 +1,48 @@
|
||||
(module
|
||||
(memory 256 256)
|
||||
(data (i32.const 10) "waka waka waka waka waka")
|
||||
;; stack imports are special
|
||||
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
|
||||
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
|
||||
;; other imports must not be touched!
|
||||
(import "env" "tempDoublePtr" (global $tempDoublePtr i32))
|
||||
(export "test1" $test1)
|
||||
(export "test2" $test2)
|
||||
(export "test3" $test3)
|
||||
;; ok to modify a global, if we keep it the same value
|
||||
(global $mine (mut i32) (i32.const 1))
|
||||
;; stack imports are ok to use. their uses are the same as other
|
||||
;; globals - must keep the same value (which means, unwind the stack)
|
||||
;; here the global names are "minified"
|
||||
(global $global0 (mut i32) (get_global $STACKTOP$asm2wasm$import))
|
||||
(global $global1 (mut i32) (get_global $STACK_MAX$asm2wasm$import))
|
||||
;; a global initialized by an import, so bad, but ok if not used
|
||||
(global $do-not-use (mut i32) (get_global $tempDoublePtr))
|
||||
(func $test1
|
||||
(local $temp i32)
|
||||
(set_global $mine (i32.const 1))
|
||||
(set_local $temp (get_global $global0))
|
||||
(set_global $global0 (i32.const 1337)) ;; bad
|
||||
(set_global $global0 (get_local $temp)) ;; save us
|
||||
(set_global $global1 (i32.const 913370)) ;; bad
|
||||
(set_global $global1 (get_local $temp)) ;; save us
|
||||
;; use the stack memory
|
||||
(i32.store (get_local $temp) (i32.const 1337))
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load (get_local $temp))
|
||||
(i32.const 1337)
|
||||
)
|
||||
(unreachable) ;; they should be equal, never get here
|
||||
)
|
||||
;; finally, do a valid store
|
||||
(i32.store8 (i32.const 12) (i32.const 115))
|
||||
)
|
||||
(func $test2
|
||||
(set_global $tempDoublePtr (i32.const 1)) ;; bad!
|
||||
(i32.store8 (i32.const 13) (i32.const 115))
|
||||
)
|
||||
(func $test3
|
||||
(i32.store8 (i32.const 14) (i32.const 115))
|
||||
)
|
||||
)
|
||||
164
samples/WebAssembly/local-cse.wast
Normal file
164
samples/WebAssembly/local-cse.wast
Normal file
@@ -0,0 +1,164 @@
|
||||
(module
|
||||
(memory 100 100)
|
||||
(func $basics
|
||||
(local $x i32)
|
||||
(local $y i32)
|
||||
(drop
|
||||
(i32.add (i32.const 1) (i32.const 2))
|
||||
)
|
||||
(drop
|
||||
(i32.add (i32.const 1) (i32.const 2))
|
||||
)
|
||||
(if (i32.const 0) (nop))
|
||||
(drop ;; we can't do this yet, non-linear
|
||||
(i32.add (i32.const 1) (i32.const 2))
|
||||
)
|
||||
(drop
|
||||
(i32.add (get_local $x) (get_local $y))
|
||||
)
|
||||
(drop
|
||||
(i32.add (get_local $x) (get_local $y))
|
||||
)
|
||||
(drop
|
||||
(i32.add (get_local $x) (get_local $y))
|
||||
)
|
||||
(call $basics) ;; side effects, but no matter for our locals
|
||||
(drop
|
||||
(i32.add (get_local $x) (get_local $y))
|
||||
)
|
||||
(set_local $x (i32.const 100))
|
||||
(drop ;; x was changed!
|
||||
(i32.add (get_local $x) (get_local $y))
|
||||
)
|
||||
)
|
||||
(func $recursive1
|
||||
(local $x i32)
|
||||
(local $y i32)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.add
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.add
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $recursive2
|
||||
(local $x i32)
|
||||
(local $y i32)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.add
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.add
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $self
|
||||
(local $x i32)
|
||||
(local $y i32)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.add
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $loads
|
||||
(drop
|
||||
(i32.load (i32.const 10))
|
||||
)
|
||||
(drop
|
||||
(i32.load (i32.const 10)) ;; implicit traps, sad
|
||||
)
|
||||
)
|
||||
(func $8 (param $var$0 i32) (result i32)
|
||||
(local $var$1 i32)
|
||||
(local $var$2 i32)
|
||||
(local $var$3 i32)
|
||||
(block $label$0 i32
|
||||
(i32.store
|
||||
(tee_local $var$2
|
||||
(i32.add
|
||||
(get_local $var$1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.and
|
||||
(i32.load
|
||||
(get_local $var$2)
|
||||
)
|
||||
(i32.xor
|
||||
(tee_local $var$2
|
||||
(i32.const 74)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(tee_local $var$1
|
||||
(i32.add
|
||||
(get_local $var$1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.or
|
||||
(i32.load
|
||||
(get_local $var$1)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $var$2)
|
||||
(i32.const 8)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
23
samples/WebAssembly/print.wat
Normal file
23
samples/WebAssembly/print.wat
Normal file
@@ -0,0 +1,23 @@
|
||||
(module
|
||||
(import "env" "printInt" (func $printInt (param i32)))
|
||||
(import "env" "printFloat" (func $printFloat (param f32)))
|
||||
(import "env" "print" (func $print (param i32 i32)))
|
||||
|
||||
(memory $memory 1)
|
||||
(data (i32.const 0) "\n")
|
||||
(data (i32.const 1) "Hello World!")
|
||||
|
||||
(func $endl
|
||||
(call $print (i32.const 0) (i32.const 1)))
|
||||
|
||||
(func $main
|
||||
(call $printInt (i32.const 9))
|
||||
(call $endl)
|
||||
(call $printFloat (f32.const 6.28))
|
||||
(call $endl)
|
||||
(call $print (i32.const 1) (i32.const 12))
|
||||
)
|
||||
|
||||
(export "main" (func $main))
|
||||
(export "memory" (memory $memory))
|
||||
)
|
||||
@@ -0,0 +1,81 @@
|
||||
(module
|
||||
(memory 256 256)
|
||||
(type $0 (func (param i32)))
|
||||
(type $1 (func))
|
||||
(type $2 (func (result i32)))
|
||||
(func $b14 (type $2)
|
||||
(drop
|
||||
(if i32 ;; with shrinking, this can become a select
|
||||
(i32.const 1)
|
||||
(block $block1 i32
|
||||
(i32.const 12)
|
||||
)
|
||||
(block $block3 i32
|
||||
(i32.const 27)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(if i32
|
||||
(i32.const 1)
|
||||
(i32.load (i32.const 10)) ;; load may have side effects, unless ignored
|
||||
(i32.const 27)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(if i32
|
||||
(i32.const 1)
|
||||
(i32.rem_s (i32.const 11) (i32.const 12)) ;; rem may have side effects, unless ignored
|
||||
(i32.const 27)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(if i32
|
||||
(i32.const 1)
|
||||
(i32.trunc_u/f64 (f64.const 12.34)) ;; float to int may have side effects, unless ignored
|
||||
(i32.const 27)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $join-br_ifs
|
||||
(block $out
|
||||
(br_if $out (i32.const 1))
|
||||
(br_if $out (i32.const 2))
|
||||
(br_if $out (i32.const 3))
|
||||
)
|
||||
(block $out2
|
||||
(block $out3
|
||||
(br_if $out2 (i32.const 1))
|
||||
(br_if $out3 (i32.const 2))
|
||||
(br_if $out2 (i32.const 3))
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(block $out4
|
||||
(block $out5
|
||||
(br_if $out4 (i32.const 1))
|
||||
(br_if $out5 (i32.const 2))
|
||||
(br_if $out5 (i32.const 3))
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(block $out6
|
||||
(block $out7
|
||||
(br_if $out6 (i32.const 1))
|
||||
(br_if $out6 (i32.const 2))
|
||||
(br_if $out7 (i32.const 3))
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(block $out8
|
||||
(br_if $out8 (call $b14)) ;; side effect
|
||||
(br_if $out8 (i32.const 0))
|
||||
)
|
||||
(block $out8
|
||||
(br_if $out8 (i32.const 1))
|
||||
(br_if $out8 (call $b14)) ;; side effect
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
16
samples/XML/xquery-tutorial.xspec
Normal file
16
samples/XML/xquery-tutorial.xspec
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"
|
||||
xmlns:functx="http://www.functx.com"
|
||||
query="http://www.functx.com"
|
||||
query-at="xquery-tutorial.xq">
|
||||
|
||||
<x:scenario label="Calling function capitalize-first">
|
||||
<x:call function="functx:capitalize-first">
|
||||
<x:param select="'hello'"/>
|
||||
</x:call>
|
||||
|
||||
<x:expect label="should capitalize the first character of the string" select="'Hello'"/>
|
||||
|
||||
</x:scenario>
|
||||
|
||||
</x:description>
|
||||
2
test/fixtures/Shell/ash-env
vendored
Normal file
2
test/fixtures/Shell/ash-env
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env ash
|
||||
echo "ash"
|
||||
2
test/fixtures/Shell/dash-env
vendored
Normal file
2
test/fixtures/Shell/dash-env
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env dash
|
||||
echo "dash"
|
||||
2
test/fixtures/Shell/ksh-env
vendored
Normal file
2
test/fixtures/Shell/ksh-env
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env ksh
|
||||
echo "ksh"
|
||||
2
test/fixtures/Shell/mksh
vendored
Normal file
2
test/fixtures/Shell/mksh
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/mksh
|
||||
echo "mksh"
|
||||
2
test/fixtures/Shell/pdksh-env
vendored
Normal file
2
test/fixtures/Shell/pdksh-env
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env pdksh
|
||||
echo "pdksh"
|
||||
@@ -58,6 +58,7 @@ class TestGenerated < Minitest::Test
|
||||
|
||||
# npm shrinkwrap file
|
||||
generated_sample_without_loading_data("Dummy/npm-shrinkwrap.json")
|
||||
generated_sample_without_loading_data("Dummy/package-lock.json")
|
||||
|
||||
# Godep saved dependencies
|
||||
generated_sample_without_loading_data("Godeps/Godeps.json")
|
||||
|
||||
@@ -6,7 +6,6 @@ class TestGrammars < Minitest::Test
|
||||
# List of projects that are allowed without licenses
|
||||
PROJECT_WHITELIST = [
|
||||
"vendor/grammars/Sublime-Lasso",
|
||||
"vendor/grammars/sublime-spintools",
|
||||
"vendor/grammars/blitzmax"
|
||||
].freeze
|
||||
|
||||
|
||||
@@ -212,20 +212,20 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["Perl", "Perl6", "Prolog"]
|
||||
# Candidate languages = ["Perl", "Perl 6", "Prolog"]
|
||||
def test_pl_prolog_perl_by_heuristics
|
||||
assert_heuristics({
|
||||
"Prolog" => all_fixtures("Prolog", "*.pl"),
|
||||
"Perl" => ["Perl/oo1.pl", "Perl/oo2.pl", "Perl/oo3.pl", "Perl/fib.pl", "Perl/use5.pl"],
|
||||
"Perl6" => all_fixtures("Perl6", "*.pl")
|
||||
"Perl 6" => all_fixtures("Perl 6", "*.pl")
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["Perl", "Perl6"]
|
||||
# Candidate languages = ["Perl", "Perl 6"]
|
||||
def test_pm_perl_by_heuristics
|
||||
assert_heuristics({
|
||||
"Perl" => all_fixtures("Perl", "*.pm"),
|
||||
"Perl6" => all_fixtures("Perl6", "*.pm")
|
||||
"Perl 6" => all_fixtures("Perl 6", "*.pm")
|
||||
})
|
||||
end
|
||||
|
||||
@@ -279,13 +279,13 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["Perl", "Perl6"]
|
||||
# Candidate languages = ["Perl", "Perl 6"]
|
||||
def test_t_perl_by_heuristics
|
||||
assert_heuristics({
|
||||
"Perl" => all_fixtures("Perl", "*.t"),
|
||||
"Perl6" => ["Perl6/01-dash-uppercase-i.t", "Perl6/01-parse.t", "Perl6/advent2009-day16.t",
|
||||
"Perl6/basic-open.t", "Perl6/calendar.t", "Perl6/for.t", "Perl6/hash.t",
|
||||
"Perl6/listquote-whitespace.t"]
|
||||
"Perl 6" => ["Perl 6/01-dash-uppercase-i.t", "Perl 6/01-parse.t", "Perl 6/advent2009-day16.t",
|
||||
"Perl 6/basic-open.t", "Perl 6/calendar.t", "Perl 6/for.t", "Perl 6/hash.t",
|
||||
"Perl 6/listquote-whitespace.t"]
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
@@ -16,8 +16,14 @@ class TestMD5 < Minitest::Test
|
||||
end
|
||||
|
||||
def test_hexdigest_integer
|
||||
assert_equal "7605ec17fd7fd213fdcd23cac302cbb4", MD5.hexdigest(1)
|
||||
assert_equal "097c311a46d330e4e119ba2b1dc0f9a5", MD5.hexdigest(2)
|
||||
# Ruby 2.4.0 merged Bignum and Fixnum into Integer which means we get different digests
|
||||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.4.0")
|
||||
assert_equal "eb70b9dc51f70acc91b4d984ef81570e", MD5.hexdigest(1)
|
||||
assert_equal "41f415a79361937c28fff32c2c6d056d", MD5.hexdigest(2)
|
||||
else
|
||||
assert_equal "7605ec17fd7fd213fdcd23cac302cbb4", MD5.hexdigest(1)
|
||||
assert_equal "097c311a46d330e4e119ba2b1dc0f9a5", MD5.hexdigest(2)
|
||||
end
|
||||
|
||||
refute_equal MD5.hexdigest("1"), MD5.hexdigest(1)
|
||||
end
|
||||
@@ -38,16 +44,30 @@ class TestMD5 < Minitest::Test
|
||||
|
||||
def test_hexdigest_array
|
||||
assert_equal "4410ec34d9e6c1a68100ca0ce033fb17", MD5.hexdigest([])
|
||||
assert_equal "759f28c1d0c20c22e79c91d339855d95", MD5.hexdigest([1])
|
||||
assert_equal "9efe07b352dd94cd1cdc9d1a8d054f8f", MD5.hexdigest([1, 2])
|
||||
assert_equal "60b1ef7201404f20c3d12f47499c3a1f", MD5.hexdigest([1, 2, 3])
|
||||
assert_equal "2f82cdc166616208077ff1dd0a8faeff", MD5.hexdigest([1, 2, [3]])
|
||||
# Ruby 2.4.0 merged Bignum and Fixnum into Integer which means we get different digests
|
||||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.4.0")
|
||||
assert_equal "7c6285c53bb82c9b58c0c28329f8d8f4", MD5.hexdigest([1])
|
||||
assert_equal "fdfbe9b65f652acb927b50ccba9f3270", MD5.hexdigest([1, 2])
|
||||
assert_equal "ba631f6acc179689c45be854705c08c9", MD5.hexdigest([1, 2, 3])
|
||||
assert_equal "d6eed665798037ebccaa2cc54a37ce93", MD5.hexdigest([1, 2, [3]])
|
||||
else
|
||||
assert_equal "759f28c1d0c20c22e79c91d339855d95", MD5.hexdigest([1])
|
||||
assert_equal "9efe07b352dd94cd1cdc9d1a8d054f8f", MD5.hexdigest([1, 2])
|
||||
assert_equal "60b1ef7201404f20c3d12f47499c3a1f", MD5.hexdigest([1, 2, 3])
|
||||
assert_equal "2f82cdc166616208077ff1dd0a8faeff", MD5.hexdigest([1, 2, [3]])
|
||||
end
|
||||
end
|
||||
|
||||
def test_hexdigest_hash
|
||||
assert_equal "fae8a9257e154175da4193dbf6552ef6", MD5.hexdigest({})
|
||||
assert_equal "868ee214faf277829a85667cf332749f", MD5.hexdigest({:a => 1})
|
||||
assert_equal "fa9df957c2b26de6fcca9d062ea8701e", MD5.hexdigest({:b => 2})
|
||||
# Ruby 2.4.0 merged Bignum and Fixnum into Integer which means we get different digests
|
||||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.4.0")
|
||||
assert_equal "edfd4aed358b4d346b7eb7adf0fd21d1", MD5.hexdigest({:a => 1})
|
||||
assert_equal "39bb725ffe02392759e0a075001e6119", MD5.hexdigest({:b => 2})
|
||||
else
|
||||
assert_equal "868ee214faf277829a85667cf332749f", MD5.hexdigest({:a => 1})
|
||||
assert_equal "fa9df957c2b26de6fcca9d062ea8701e", MD5.hexdigest({:b => 2})
|
||||
end
|
||||
|
||||
refute_equal MD5.hexdigest([:b, 2]), MD5.hexdigest({:b => 2})
|
||||
|
||||
|
||||
2
vendor/CodeMirror
vendored
2
vendor/CodeMirror
vendored
Submodule vendor/CodeMirror updated: 41da8714dd...99c8d8b902
23
vendor/README.md
vendored
23
vendor/README.md
vendored
@@ -59,6 +59,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **Click:** [stenverbois/language-click](https://github.com/stenverbois/language-click)
|
||||
- **CLIPS:** [psicomante/CLIPS-sublime](https://github.com/psicomante/CLIPS-sublime)
|
||||
- **Clojure:** [atom/language-clojure](https://github.com/atom/language-clojure)
|
||||
- **Closure Templates:** [mthadley/language-closure-templates](https://github.com/mthadley/language-closure-templates)
|
||||
- **CMake:** [textmate/cmake.tmbundle](https://github.com/textmate/cmake.tmbundle)
|
||||
- **COBOL:** [bitbucket:bitlang/sublime_cobol](https://bitbucket.org/bitlang/sublime_cobol)
|
||||
- **CoffeeScript:** [atom/language-coffee-script](https://github.com/atom/language-coffee-script)
|
||||
@@ -82,7 +83,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **Cython:** [textmate/cython.tmbundle](https://github.com/textmate/cython.tmbundle)
|
||||
- **D:** [textmate/d.tmbundle](https://github.com/textmate/d.tmbundle)
|
||||
- **D-ObjDump:** [nanoant/assembly.tmbundle](https://github.com/nanoant/assembly.tmbundle)
|
||||
- **Dart:** [guillermooo/dart-sublime-bundle](https://github.com/guillermooo/dart-sublime-bundle)
|
||||
- **Dart:** [dart-atom/dartlang](https://github.com/dart-atom/dartlang)
|
||||
- **desktop:** [Mailaender/desktop.tmbundle](https://github.com/Mailaender/desktop.tmbundle)
|
||||
- **Diff:** [textmate/diff.tmbundle](https://github.com/textmate/diff.tmbundle)
|
||||
- **DM:** [PJB3005/atomic-dreams](https://github.com/PJB3005/atomic-dreams)
|
||||
@@ -106,6 +107,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **F#:** [fsprojects/atom-fsharp](https://github.com/fsprojects/atom-fsharp)
|
||||
- **Factor:** [slavapestov/factor](https://github.com/slavapestov/factor)
|
||||
- **Fancy:** [fancy-lang/fancy-tmbundle](https://github.com/fancy-lang/fancy-tmbundle)
|
||||
- **Fantom** [rkoeninger/sublime-fantom](https://github.com/rkoeninger/sublime-fantom)
|
||||
- **fish:** [l15n/fish-tmbundle](https://github.com/l15n/fish-tmbundle)
|
||||
- **Forth:** [textmate/forth.tmbundle](https://github.com/textmate/forth.tmbundle)
|
||||
- **Fortran:** [textmate/fortran.tmbundle](https://github.com/textmate/fortran.tmbundle)
|
||||
@@ -136,7 +138,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **Graphviz (DOT):** [textmate/graphviz.tmbundle](https://github.com/textmate/graphviz.tmbundle)
|
||||
- **Groovy:** [textmate/groovy.tmbundle](https://github.com/textmate/groovy.tmbundle)
|
||||
- **Groovy Server Pages:** [textmate/java.tmbundle](https://github.com/textmate/java.tmbundle)
|
||||
- **Hack:** [brandonblack/php.tmbundle](https://github.com/brandonblack/php.tmbundle)
|
||||
- **Hack:** [textmate/php.tmbundle](https://github.com/textmate/php.tmbundle)
|
||||
- **Haml:** [ezekg/language-haml](https://github.com/ezekg/language-haml)
|
||||
- **Handlebars:** [daaain/Handlebars](https://github.com/daaain/Handlebars)
|
||||
- **Harbour:** [hernad/atom-language-harbour](https://github.com/hernad/atom-language-harbour)
|
||||
@@ -149,7 +151,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **HTML+ECR:** [atom-crystal/language-crystal](https://github.com/atom-crystal/language-crystal)
|
||||
- **HTML+EEX:** [elixir-lang/elixir-tmbundle](https://github.com/elixir-lang/elixir-tmbundle)
|
||||
- **HTML+ERB:** [aroben/ruby.tmbundle](https://github.com/aroben/ruby.tmbundle)
|
||||
- **HTML+PHP:** [brandonblack/php.tmbundle](https://github.com/brandonblack/php.tmbundle)
|
||||
- **HTML+PHP:** [textmate/php.tmbundle](https://github.com/textmate/php.tmbundle)
|
||||
- **HTTP:** [httpspec/sublime-highlighting](https://github.com/httpspec/sublime-highlighting)
|
||||
- **IDL:** [mgalloy/idl.tmbundle](https://github.com/mgalloy/idl.tmbundle)
|
||||
- **Idris:** [idris-hackers/idris-sublime](https://github.com/idris-hackers/idris-sublime)
|
||||
@@ -167,6 +169,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **JFlex:** [jflex-de/jflex.tmbundle](https://github.com/jflex-de/jflex.tmbundle)
|
||||
- **Jison:** [cdibbs/language-jison](https://github.com/cdibbs/language-jison)
|
||||
- **Jison Lex:** [cdibbs/language-jison](https://github.com/cdibbs/language-jison)
|
||||
- **Jolie:** [fmontesi/language-jolie](https://github.com/fmontesi/language-jolie)
|
||||
- **JSON:** [textmate/json.tmbundle](https://github.com/textmate/json.tmbundle)
|
||||
- **JSON5:** [atom/language-javascript](https://github.com/atom/language-javascript)
|
||||
- **JSONiq:** [wcandillon/language-jsoniq](https://github.com/wcandillon/language-jsoniq)
|
||||
@@ -247,13 +250,15 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **Ox:** [andreashetland/sublime-text-ox](https://github.com/andreashetland/sublime-text-ox)
|
||||
- **Oz:** [eregon/oz-tmbundle](https://github.com/eregon/oz-tmbundle)
|
||||
- **P4:** [TakeshiTseng/atom-language-p4](https://github.com/TakeshiTseng/atom-language-p4)
|
||||
- **Pan:** [quattor/language-pan](https://github.com/quattor/language-pan)
|
||||
- **Papyrus:** [Kapiainen/SublimePapyrus](https://github.com/Kapiainen/SublimePapyrus)
|
||||
- **Parrot Internal Representation:** [textmate/parrot.tmbundle](https://github.com/textmate/parrot.tmbundle)
|
||||
- **Pascal:** [textmate/pascal.tmbundle](https://github.com/textmate/pascal.tmbundle)
|
||||
- **PAWN:** [Southclaw/pawn-sublime-language](https://github.com/Southclaw/pawn-sublime-language)
|
||||
- **Pep8:** [R4PaSs/Sublime-Pep8](https://github.com/R4PaSs/Sublime-Pep8)
|
||||
- **Perl:** [textmate/perl.tmbundle](https://github.com/textmate/perl.tmbundle)
|
||||
- **Perl6:** [perl6/atom-language-perl6](https://github.com/perl6/atom-language-perl6)
|
||||
- **PHP:** [brandonblack/php.tmbundle](https://github.com/brandonblack/php.tmbundle)
|
||||
- **Perl 6:** [perl6/atom-language-perl6](https://github.com/perl6/atom-language-perl6)
|
||||
- **PHP:** [textmate/php.tmbundle](https://github.com/textmate/php.tmbundle)
|
||||
- **Pic:** [Alhadis/language-roff](https://github.com/Alhadis/language-roff)
|
||||
- **PicoLisp:** [textmate/lisp.tmbundle](https://github.com/textmate/lisp.tmbundle)
|
||||
- **PigLatin:** [goblindegook/sublime-text-pig-latin](https://github.com/goblindegook/sublime-text-pig-latin)
|
||||
@@ -282,7 +287,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **Rascal:** [usethesource/rascal-syntax-highlighting](https://github.com/usethesource/rascal-syntax-highlighting)
|
||||
- **RDoc:** [joshaven/RDoc.tmbundle](https://github.com/joshaven/RDoc.tmbundle)
|
||||
- **REALbasic:** [angryant0007/VBDotNetSyntax](https://github.com/angryant0007/VBDotNetSyntax)
|
||||
- **Reason:** [facebook/reason](https://github.com/facebook/reason)
|
||||
- **Reason:** [chenglou/sublime-reason](https://github.com/chenglou/sublime-reason)
|
||||
- **Rebol:** [Oldes/Sublime-REBOL](https://github.com/Oldes/Sublime-REBOL)
|
||||
- **Red:** [Oldes/Sublime-Red](https://github.com/Oldes/Sublime-Red)
|
||||
- **Regular Expression:** [Alhadis/language-regexp](https://github.com/Alhadis/language-regexp)
|
||||
@@ -307,8 +312,10 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **Scheme:** [textmate/scheme.tmbundle](https://github.com/textmate/scheme.tmbundle)
|
||||
- **Scilab:** [textmate/scilab.tmbundle](https://github.com/textmate/scilab.tmbundle)
|
||||
- **SCSS:** [MarioRicalde/SCSS.tmbundle](https://github.com/MarioRicalde/SCSS.tmbundle)
|
||||
- **ShaderLab:** [tgjones/shaders-tmLanguage](https://github.com/tgjones/shaders-tmLanguage)
|
||||
- **Shell:** [atom/language-shellscript](https://github.com/atom/language-shellscript)
|
||||
- **ShellSession:** [atom/language-shellscript](https://github.com/atom/language-shellscript)
|
||||
- **Shen:** [rkoeninger/sublime-shen](https://github.com/rkoeninger/sublime-shen)
|
||||
- **Slash:** [slash-lang/Slash.tmbundle](https://github.com/slash-lang/Slash.tmbundle)
|
||||
- **Slim:** [slim-template/ruby-slim.tmbundle](https://github.com/slim-template/ruby-slim.tmbundle)
|
||||
- **Smali:** [ShaneWilton/sublime-smali](https://github.com/ShaneWilton/sublime-smali)
|
||||
@@ -346,6 +353,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **Turtle:** [peta/turtle.tmbundle](https://github.com/peta/turtle.tmbundle)
|
||||
- **Twig:** [Anomareh/PHP-Twig.tmbundle](https://github.com/Anomareh/PHP-Twig.tmbundle)
|
||||
- **TXL:** [MikeHoffert/Sublime-Text-TXL-syntax](https://github.com/MikeHoffert/Sublime-Text-TXL-syntax)
|
||||
- **Type Language:** [goodmind/language-typelanguage](https://github.com/goodmind/language-typelanguage)
|
||||
- **TypeScript:** [Microsoft/TypeScript-Sublime-Plugin](https://github.com/Microsoft/TypeScript-Sublime-Plugin)
|
||||
- **Unified Parallel C:** [textmate/c.tmbundle](https://github.com/textmate/c.tmbundle)
|
||||
- **Unity3D Asset:** [atom/language-yaml](https://github.com/atom/language-yaml)
|
||||
@@ -364,6 +372,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **Wavefront Material:** [Alhadis/language-wavefront](https://github.com/Alhadis/language-wavefront)
|
||||
- **Wavefront Object:** [Alhadis/language-wavefront](https://github.com/Alhadis/language-wavefront)
|
||||
- **Web Ontology Language:** [textmate/xml.tmbundle](https://github.com/textmate/xml.tmbundle)
|
||||
- **WebAssembly:** [Alhadis/language-webassembly](https://github.com/Alhadis/language-webassembly)
|
||||
- **WebIDL:** [andik/IDL-Syntax](https://github.com/andik/IDL-Syntax)
|
||||
- **wisp:** [atom/language-clojure](https://github.com/atom/language-clojure)
|
||||
- **World of Warcraft Addon Data:** [nebularg/language-toc-wow](https://github.com/nebularg/language-toc-wow)
|
||||
@@ -381,4 +390,4 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **Yacc:** [textmate/bison.tmbundle](https://github.com/textmate/bison.tmbundle)
|
||||
- **YAML:** [atom/language-yaml](https://github.com/atom/language-yaml)
|
||||
- **YANG:** [DzonyKalafut/language-yang](https://github.com/DzonyKalafut/language-yang)
|
||||
- **Zephir:** [vmg/zephir-sublime](https://github.com/vmg/zephir-sublime)
|
||||
- **Zephir:** [phalcon/zephir-sublime](https://github.com/phalcon/zephir-sublime)
|
||||
|
||||
2
vendor/grammars/Elm
vendored
2
vendor/grammars/Elm
vendored
Submodule vendor/grammars/Elm updated: 195e71c6a7...581b9e6f5b
2
vendor/grammars/Handlebars
vendored
2
vendor/grammars/Handlebars
vendored
Submodule vendor/grammars/Handlebars updated: 63c28f7aa9...fa350d393d
2
vendor/grammars/LiveScript.tmbundle
vendored
2
vendor/grammars/LiveScript.tmbundle
vendored
Submodule vendor/grammars/LiveScript.tmbundle updated: 05dc46397a...2575013851
2
vendor/grammars/MagicPython
vendored
2
vendor/grammars/MagicPython
vendored
Submodule vendor/grammars/MagicPython updated: ed68ac42c5...ffab3f1ec0
2
vendor/grammars/Modelica
vendored
2
vendor/grammars/Modelica
vendored
Submodule vendor/grammars/Modelica updated: 10c5dc6484...e9cf6f5bfb
2
vendor/grammars/NimLime
vendored
2
vendor/grammars/NimLime
vendored
Submodule vendor/grammars/NimLime updated: 80787e7eee...bf48175e71
1
vendor/grammars/Sublime-Pep8
vendored
Submodule
1
vendor/grammars/Sublime-Pep8
vendored
Submodule
Submodule vendor/grammars/Sublime-Pep8 added at be653c638b
2
vendor/grammars/Sublime-SQF-Language
vendored
2
vendor/grammars/Sublime-SQF-Language
vendored
Submodule vendor/grammars/Sublime-SQF-Language updated: 0dffdffaaa...ee30a860e0
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user