Compare commits
3 Commits
5625e0c83a
...
bb62fb3966
Author | SHA1 | Date | |
---|---|---|---|
bb62fb3966 | |||
dc6dc5e6f8 | |||
75139fb15e |
2
external/libfigure/chooser.js
vendored
2
external/libfigure/chooser.js
vendored
|
@ -14,6 +14,8 @@
|
||||||
// `chooser('chooser_boolean').name => 'chooser_boolean'`
|
// `chooser('chooser_boolean').name => 'chooser_boolean'`
|
||||||
// Choosers can be compared with ===
|
// Choosers can be compared with ===
|
||||||
|
|
||||||
|
import { libfigureUniq, throw_up } from "./util.js"
|
||||||
|
|
||||||
var defined_choosers = {}
|
var defined_choosers = {}
|
||||||
|
|
||||||
function defineChooser(name) {
|
function defineChooser(name) {
|
||||||
|
|
5
external/libfigure/dance.js
vendored
5
external/libfigure/dance.js
vendored
|
@ -1,3 +1,6 @@
|
||||||
|
import { dancerSubstitution } from "./define-figure.js"
|
||||||
|
import { throw_up } from "./util.js"
|
||||||
|
|
||||||
var invertPairHash = {
|
var invertPairHash = {
|
||||||
ladles: "gentlespoons",
|
ladles: "gentlespoons",
|
||||||
gentlespoons: "ladles",
|
gentlespoons: "ladles",
|
||||||
|
@ -10,7 +13,7 @@ var invertPairHash = {
|
||||||
// If this names 2 dancers, this returns the names for the other 2 dancers
|
// If this names 2 dancers, this returns the names for the other 2 dancers
|
||||||
// it's sketchy, because it assumes 4 dancers, so only use it in contra moves.
|
// it's sketchy, because it assumes 4 dancers, so only use it in contra moves.
|
||||||
// Formerly known as dancers complement.
|
// Formerly known as dancers complement.
|
||||||
function invertPair(whostr, dialect) {
|
export function invertPair(whostr, dialect) {
|
||||||
if (!whostr) {
|
if (!whostr) {
|
||||||
return "others"
|
return "others"
|
||||||
} // undefined is ok
|
} // undefined is ok
|
||||||
|
|
19
external/libfigure/define-figure.js
vendored
19
external/libfigure/define-figure.js
vendored
|
@ -8,12 +8,21 @@
|
||||||
// and related support functions for dealing with figures
|
// and related support functions for dealing with figures
|
||||||
|
|
||||||
import { formalParamIsDancers } from "./param.js"
|
import { formalParamIsDancers } from "./param.js"
|
||||||
import { libfigureObjectCopy, throw_up } from "./util.js"
|
import {
|
||||||
|
PUNCTUATION_CHARSET_STRING,
|
||||||
|
libfigureObjectCopy,
|
||||||
|
longestFirstSortFn,
|
||||||
|
parseHeyLength,
|
||||||
|
regExpEscape,
|
||||||
|
textInDialect,
|
||||||
|
throw_up
|
||||||
|
} from "./util.js"
|
||||||
import {
|
import {
|
||||||
FLATTEN_FORMAT_HTML,
|
FLATTEN_FORMAT_HTML,
|
||||||
FLATTEN_FORMAT_SAFE_TEXT,
|
FLATTEN_FORMAT_SAFE_TEXT,
|
||||||
FLATTEN_FORMAT_UNSAFE_TEXT,
|
FLATTEN_FORMAT_UNSAFE_TEXT,
|
||||||
Words,
|
Words,
|
||||||
|
lingoLineWords,
|
||||||
words,
|
words,
|
||||||
} from "./words.js";
|
} from "./words.js";
|
||||||
|
|
||||||
|
@ -118,7 +127,7 @@ export function parameter_strings(move, parameter_values, dialect) {
|
||||||
return parameter_strings_or_words(move, parameter_values, dialect, false)
|
return parameter_strings_or_words(move, parameter_values, dialect, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parameter_words(move, parameter_values, dialect) {
|
export function parameter_words(move, parameter_values, dialect) {
|
||||||
return parameter_strings_or_words(move, parameter_values, dialect, true)
|
return parameter_strings_or_words(move, parameter_values, dialect, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +162,7 @@ function parameterSubstitution(formal_parameter, actual_parameter, dialect) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when we do know the parameter is a dancer
|
// called when we do know the parameter is a dancer
|
||||||
function dancerSubstitution(dancer_term, dialect) {
|
export function dancerSubstitution(dancer_term, dialect) {
|
||||||
return dialect.dancers[dancer_term] || dancer_term
|
return dialect.dancers[dancer_term] || dancer_term
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +195,7 @@ export function moveSubstitution(move_term, dialect) {
|
||||||
return sub.replace(moveSubstitutionPercentSRegexp, " ").trim()
|
return sub.replace(moveSubstitutionPercentSRegexp, " ").trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveSubstitutionWithEscape(move_term, dialect) {
|
export function moveSubstitutionWithEscape(move_term, dialect) {
|
||||||
return dialect.moves[move_term] || move_term
|
return dialect.moves[move_term] || move_term
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +210,7 @@ function moveSubstitutionWithEscape(move_term, dialect) {
|
||||||
// Oh hey, the word 'form' and the word 'a' are both entered by the
|
// Oh hey, the word 'form' and the word 'a' are both entered by the
|
||||||
// user, and so are optional.
|
// user, and so are optional.
|
||||||
// Check the specs for lots of examples.
|
// Check the specs for lots of examples.
|
||||||
function moveSubstitutionWithoutForm(
|
export function moveSubstitutionWithoutForm(
|
||||||
move_term,
|
move_term,
|
||||||
dialect,
|
dialect,
|
||||||
add_article,
|
add_article,
|
||||||
|
|
7
external/libfigure/figure.js
vendored
7
external/libfigure/figure.js
vendored
|
@ -6,7 +6,7 @@
|
||||||
//
|
//
|
||||||
// keep it sorted alphabetically
|
// keep it sorted alphabetically
|
||||||
|
|
||||||
import { param } from "./param.js"
|
import { param, stringParamHand, stringParamShoulders, stringParamShouldersTerse } from "./param.js"
|
||||||
import {
|
import {
|
||||||
defineFigure,
|
defineFigure,
|
||||||
defineFigureAlias,
|
defineFigureAlias,
|
||||||
|
@ -15,8 +15,13 @@ import {
|
||||||
goodBeatsMinFn,
|
goodBeatsMinFn,
|
||||||
moveSubstitution,
|
moveSubstitution,
|
||||||
parameter_strings,
|
parameter_strings,
|
||||||
|
parameter_words,
|
||||||
|
moveSubstitutionWithoutForm,
|
||||||
|
moveSubstitutionWithEscape,
|
||||||
} from "./define-figure.js"
|
} from "./define-figure.js"
|
||||||
|
import { dancerIsPair, heyLengthMeetTimes, indefiniteArticleFor, parseHeyLength, throw_up } from "./util.js";
|
||||||
import { comma, words } from "./words.js";
|
import { comma, words } from "./words.js";
|
||||||
|
import { invertPair } from "./dance.js";
|
||||||
|
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// ALLEMANDE //
|
// ALLEMANDE //
|
||||||
|
|
12
external/libfigure/param.js
vendored
12
external/libfigure/param.js
vendored
|
@ -10,7 +10,7 @@
|
||||||
// figures have a subject telling who's acted on by the figure.
|
// figures have a subject telling who's acted on by the figure.
|
||||||
//
|
//
|
||||||
|
|
||||||
import { throw_up } from "./util.js"
|
import { parseHeyLength, throw_up } from "./util.js"
|
||||||
import { chooser, dancerMenuForChooser } from "./chooser.js"
|
import { chooser, dancerMenuForChooser } from "./chooser.js"
|
||||||
import {
|
import {
|
||||||
degreesToPlaces,
|
degreesToPlaces,
|
||||||
|
@ -18,6 +18,10 @@ import {
|
||||||
moveCaresAboutPlaces,
|
moveCaresAboutPlaces,
|
||||||
moveCaresAboutRotations,
|
moveCaresAboutRotations,
|
||||||
} from "./move.js";
|
} from "./move.js";
|
||||||
|
import {
|
||||||
|
lingoLineWords,
|
||||||
|
} from "./words.js";
|
||||||
|
import { dancerSubstitution, stringInDialect } from "./define-figure.js";
|
||||||
|
|
||||||
const __params = {}
|
const __params = {}
|
||||||
|
|
||||||
|
@ -196,13 +200,13 @@ var stringParamClock = makeTurnStringParam(
|
||||||
"____"
|
"____"
|
||||||
)
|
)
|
||||||
var stringParamLeftRight = makeTurnStringParam("left", "right", "*", "____")
|
var stringParamLeftRight = makeTurnStringParam("left", "right", "*", "____")
|
||||||
var stringParamShoulders = makeTurnStringParam(
|
export var stringParamShoulders = makeTurnStringParam(
|
||||||
"right shoulders",
|
"right shoulders",
|
||||||
"left shoulders",
|
"left shoulders",
|
||||||
"* shoulders",
|
"* shoulders",
|
||||||
"____"
|
"____"
|
||||||
)
|
)
|
||||||
var stringParamShouldersTerse = makeTurnStringParam(
|
export var stringParamShouldersTerse = makeTurnStringParam(
|
||||||
"rights",
|
"rights",
|
||||||
"lefts",
|
"lefts",
|
||||||
"* shoulders",
|
"* shoulders",
|
||||||
|
@ -214,7 +218,7 @@ var stringParamHandStarHand = makeTurnStringParam(
|
||||||
"* hand",
|
"* hand",
|
||||||
"____"
|
"____"
|
||||||
)
|
)
|
||||||
var stringParamHand = makeTurnStringParam("right", "left", "*", "____")
|
export var stringParamHand = makeTurnStringParam("right", "left", "*", "____")
|
||||||
|
|
||||||
// spin = clockwise | ccw | undefined
|
// spin = clockwise | ccw | undefined
|
||||||
defineParam("spin", {
|
defineParam("spin", {
|
||||||
|
|
17
external/libfigure/util.js
vendored
17
external/libfigure/util.js
vendored
|
@ -1,3 +1,8 @@
|
||||||
|
import { dancers, dancerMenuForChooser, chooser } from "./chooser.js"
|
||||||
|
import { moves, parameters } from "./define-figure.js"
|
||||||
|
import { formalParamIsDancers } from "./param.js"
|
||||||
|
import { peek } from "./words.js"
|
||||||
|
|
||||||
export const PUNCTUATION_CHARSET_STRING =
|
export const PUNCTUATION_CHARSET_STRING =
|
||||||
"[\u2000-\u206F\u2E00-\u2E7F'!\"#$%&()*+,/:;<=>?@\\[\\]^_`{|}~\\.-]"
|
"[\u2000-\u206F\u2E00-\u2E7F'!\"#$%&()*+,/:;<=>?@\\[\\]^_`{|}~\\.-]"
|
||||||
|
|
||||||
|
@ -11,7 +16,7 @@ export const throw_up = str => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// a little weird that this takes a Words now, not a string
|
// a little weird that this takes a Words now, not a string
|
||||||
function indefiniteArticleFor(w) {
|
export function indefiniteArticleFor(w) {
|
||||||
var str = peek(w)
|
var str = peek(w)
|
||||||
return /[aeiou]/.test(str) ? "an" : "a"
|
return /[aeiou]/.test(str) ? "an" : "a"
|
||||||
}
|
}
|
||||||
|
@ -101,7 +106,7 @@ function copyDialect(dialect) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function textInDialect(dialect) {
|
export function textInDialect(dialect) {
|
||||||
// see also ruby-side implementation
|
// see also ruby-side implementation
|
||||||
return !!dialect.text_in_dialect
|
return !!dialect.text_in_dialect
|
||||||
}
|
}
|
||||||
|
@ -115,7 +120,7 @@ export const libfigureObjectCopy = hash => {
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
function libfigureUniq(array) {
|
export function libfigureUniq(array) {
|
||||||
// suboptimal O(n^2)
|
// suboptimal O(n^2)
|
||||||
var output = []
|
var output = []
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
|
@ -157,7 +162,7 @@ function figuresUseDancers(figures, dancers_term) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// unpacks a hey length into a pair, [dancer, meeting_count] or ['full', meeting_count]
|
// unpacks a hey length into a pair, [dancer, meeting_count] or ['full', meeting_count]
|
||||||
function parseHeyLength(hey_length) {
|
export function parseHeyLength(hey_length) {
|
||||||
if (hey_length === "full" || hey_length === "between half and full") {
|
if (hey_length === "full" || hey_length === "between half and full") {
|
||||||
return [hey_length, 2]
|
return [hey_length, 2]
|
||||||
} else if (hey_length === "half" || hey_length === "less than half") {
|
} else if (hey_length === "half" || hey_length === "less than half") {
|
||||||
|
@ -175,11 +180,11 @@ function parseHeyLength(hey_length) {
|
||||||
throw_up("unparseable hey length - " + hey_length)
|
throw_up("unparseable hey length - " + hey_length)
|
||||||
}
|
}
|
||||||
|
|
||||||
function heyLengthMeetTimes(hey_length) {
|
export function heyLengthMeetTimes(hey_length) {
|
||||||
return parseHeyLength(hey_length)[1]
|
return parseHeyLength(hey_length)[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
function dancerIsPair(dancer) {
|
export function dancerIsPair(dancer) {
|
||||||
return dancerMenuForChooser(chooser("chooser_pair")).indexOf(dancer) >= 0
|
return dancerMenuForChooser(chooser("chooser_pair")).indexOf(dancer) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
external/libfigure/words.js
vendored
3
external/libfigure/words.js
vendored
|
@ -2,6 +2,7 @@ import {
|
||||||
longestFirstSortFn,
|
longestFirstSortFn,
|
||||||
PUNCTUATION_CHARSET_STRING,
|
PUNCTUATION_CHARSET_STRING,
|
||||||
regExpEscape,
|
regExpEscape,
|
||||||
|
throw_up,
|
||||||
} from "./util.js"
|
} from "./util.js"
|
||||||
import { dancers } from "./chooser.js"
|
import { dancers } from "./chooser.js"
|
||||||
import { moves } from "./define-figure.js"
|
import { moves } from "./define-figure.js"
|
||||||
|
@ -10,7 +11,7 @@ export function Words(arr) {
|
||||||
this.arr = arr
|
this.arr = arr
|
||||||
}
|
}
|
||||||
|
|
||||||
export const words = function() {
|
export const words = function () {
|
||||||
return new Words(Array.prototype.slice.call(arguments))
|
return new Words(Array.prototype.slice.call(arguments))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user