Compare commits

...

19 Commits

Author SHA1 Message Date
Colin Seymour
e60384b018 Release v5.1.0 (#3725)
* sublime-spintools now has a license so no need for whitelist

* Bump version: 5.0.12

* Use the more apt release of v5.1.0
2017-07-22 14:16:16 +01:00
Santiago M. Mola
470a82d9f5 shell: add more interpreters (#3708)
* ash: only interpreter, extension is more commonly used for
  Kingdom of Loathing scripting, e.g. github.com/twistedmage/assorted-kol-scripts

* dash: only interpreter, extension is more commonly used for
  dashboarding-related stuff

* ksh: extension was already present

* mksh

* pdksh
2017-07-20 10:33:28 +01:00
Santiago M. Mola
37979b26b0 improve .ms disambiguation (Unix Assembly / MAXScript) (#3707)
A few MAXScript files were misclassified as Unix Assembly.
Some of them can be found at github.com/davestewart/maxscript

* This commit changes the heuristic which looked for labels
  such as ".LG7E0:" to actually match the full label including
  the colon. This reduced the number of MAXScript files
  misclassified as Unix Assembly, without any new Unix Assembly
  misclassified so far.

* add MAXScript sample rolloutCreator.ms, extrated from MIT repo:
  https://github.com/davestewart/maxscript/blob/master/3D/3ds2ae/02_resources/max%20scripts/3ds%20ax%20scripts/rolloutCreator.ms
2017-07-10 10:03:12 +01:00
Santiago M. Mola
1a6df12902 fix Coq sample JsNumber.v (#3710)
It was fetched as HTML from GitHub instead of raw.
2017-07-10 09:41:36 +01:00
John Gardner
24e196df4e Add NCSA to license whitelist (#3714)
References:
* https://github.com/github/linguist/pull/3689#issuecomment-313665976
2017-07-08 00:59:05 +10:00
James Adams
8d178bfaed Improve Pan language support (#3691)
* Add a larger set of sample files for Pan

This is a fairly good cross section of Pan based on code from:
* https://github.com/quattor/template-library-examples
* https://github.com/quattor/template-library-core

* Add Pan language grammar
2017-07-03 18:49:15 +02:00
Chris Wilkinson
e9ec699931 Add xspec as XML file extension (#3702) 2017-07-03 18:39:39 +02:00
John Gardner
9a6c3f2c4d Register "cpanfile" as a Perl filename (#3704) 2017-07-03 20:45:20 +10:00
Theodore Dubois
648720301d Add misclassified C sample (#3652)
This sample is misclassified as Objective-C.
2017-06-30 17:11:50 +01:00
David Aylaian
c552e25bd7 Add C sample (#3698)
* Add C sample

Sample was incorrectly being identified as C++

* Changed asm.h license to the Unlicense

* Changed asm.h license to Apache 2.0
2017-06-30 09:32:16 +01:00
Justin Lecher
d5c8db3fb9 Add new language for the Easybuild framework (#3466)
The hpcugent/easybuild-framework is a python framework for the installation
of application in an HPC context. The actual package build description are
written in python but having .eb as extension.

Signed-off-by: Justin Lecher <jlec@gentoo.org>
2017-06-26 09:07:36 +01:00
Mahmoud Samir Fayed
632bcdc1ad Added Ring Language Support (#3662)
* update .gitmodules

* Update grammars.yml

* Create hello.ring

* Create Natural.ring

* Create weblib.ring

* vendor/grammars/language-ring

* fix order in grammars.yml

* remove two files from samples

* delete hello.ring

* Update languages.yml - add the R

* Create hello.ring

* Create natural.ring

* Create weblib.ring

* Create grammars.yml

* Create .gitmodules

* Create languages.yml

* Create languages.yml

* Create language-ring.txt

* Update .gitmodules

Prefer HTTPS links.

* Update hello.ring

Sample file from "real" applications (under permissive license) to train the Bayesian classifier.

* Update languages.yml

* Update weblib.ring

Reduce the file size

* Update .gitmodules

* Update .gitmodules

* Update .gitmodules

* Update .gitmodules

* Update submodule : language-ring

* Update weblib.ring

Sample : Using the web library.

* Create weighthistory

Add Sample

* Rename weighthistory to weighthistory.ring

* Update weblib.ring
2017-06-24 16:22:01 +01:00
Colby Pines
6b221172c0 Update vendor.yml: skeleton.css (#3682) 2017-06-24 13:19:43 +02:00
Robert Koeninger
6f0d801375 Added syntax definition for Fantom language (#3660)
* Added mgiannini/sublime-factor as a submodule

Provided better color for Fantom
Added license for sublime-fantom
Specified tm_scope for Fantom

* Redirected submodule for Fantom to fork with updated grammar

* Triggering build

* Updating sublime-fantom submodule

* Updated submodule sublime-fantom

* Adding Fantom samples
2017-06-21 09:29:13 +02:00
John Gardner
128abe3533 Fix spelling of Perl 6 (#3672)
Resolves #3671.
2017-06-20 19:39:39 +10:00
Colin Seymour
9312353d20 Improve running from cloned repo docs (#3669)
* Improve running from cloned repo docs
2017-06-20 10:29:17 +02:00
John Gardner
b6460f8ed6 Add recognition and classification of WebAssembly (#3650) 2017-05-30 18:02:03 +10:00
andretshurotshka
60f864a138 Support for Type Language (#3593)
* Support for Type Language

* Update Type Language

* Add one more sample for Type Language

* Update Type Language grammar
2017-05-29 06:46:56 +01:00
Colin Seymour
ca6121e3ea Update MD5 digest for testing under Ruby 2.4 (#3643)
* Update md5 sums for Ruby 2.4

Ruby 2.4 deprecated Fixnum & Bignum into Integer. This means the MD5 digests for the integers in our tests have a class of Integer instead of Fixnum which means we need to update the digests specifically for 2.4.

* Use Gem::Version for safer version comparison
2017-05-26 08:16:12 +01:00
160 changed files with 3825 additions and 1113 deletions

15
.gitmodules vendored
View File

@@ -836,6 +836,9 @@
[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
@@ -848,3 +851,15 @@
[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

View File

@@ -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

View File

@@ -427,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:
@@ -436,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
@@ -455,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:
@@ -620,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

View File

@@ -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

View File

@@ -1084,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
@@ -1231,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:
@@ -2469,6 +2479,7 @@ Makefile:
- Makefile.frag
- Makefile.in
- Makefile.inc
- Makefile.wat
- makefile
- makefile.sco
- mkfile
@@ -3119,7 +3130,7 @@ Pan:
color: "#cc0000"
extensions:
- ".pan"
tm_scope: none
tm_scope: source.pan
ace_mode: text
language_id: 276
Papyrus:
@@ -3206,10 +3217,12 @@ Perl:
- ".pod"
- ".psgi"
- ".t"
filenames:
- cpanfile
interpreters:
- perl
language_id: 282
Perl6:
Perl 6:
type: programming
color: "#0000fb"
extensions:
@@ -3735,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:
@@ -4101,7 +4122,12 @@ Shell:
- PKGBUILD
- gradlew
interpreters:
- ash
- bash
- dash
- ksh
- mksh
- pdksh
- rc
- sh
- zsh
@@ -4487,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"
@@ -4684,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:
@@ -4828,6 +4877,7 @@ XML:
- ".xml.dist"
- ".xproj"
- ".xsd"
- ".xspec"
- ".xul"
- ".zcml"
filenames:

View File

@@ -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)$

View File

@@ -1,3 +1,3 @@
module Linguist
VERSION = "5.0.11"
VERSION = "5.1.0"
end

27
samples/C/asm.h Normal file
View 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
View 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

File diff suppressed because it is too large Load Diff

View 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'

View 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)
}
}

View 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")
}
}
}

View 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
*/

View 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
View 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
View 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
View 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
View 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;
};

View 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
View 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
View 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
View 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);

View 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
View 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
View 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
View 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"),
);

View 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
View 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
View 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
View 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
View 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")),
),
);

View 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
View 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
View 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
View 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!"

View 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

View 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;

File diff suppressed because it is too large Load Diff

View 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))
)

View 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))
)

View 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))
)
)

View 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)
)
)
)

View 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))
)

View File

@@ -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
)
)
)

View 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
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env ash
echo "ash"

2
test/fixtures/Shell/dash-env vendored Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env dash
echo "dash"

2
test/fixtures/Shell/ksh-env vendored Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env ksh
echo "ksh"

2
test/fixtures/Shell/mksh vendored Normal file
View File

@@ -0,0 +1,2 @@
#!/bin/mksh
echo "mksh"

2
test/fixtures/Shell/pdksh-env vendored Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env pdksh
echo "pdksh"

View File

@@ -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

View File

@@ -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

View File

@@ -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})

6
vendor/README.md vendored
View File

@@ -107,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)
@@ -249,13 +250,14 @@ 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)
- **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)
@@ -351,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)
@@ -369,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)

Some files were not shown because too many files have changed in this diff Show More