Compare commits

...

3 Commits

7 changed files with 47 additions and 18 deletions

View File

@ -14,6 +14,8 @@
// `chooser('chooser_boolean').name => 'chooser_boolean'`
// Choosers can be compared with ===
import { libfigureUniq, throw_up } from "./util.js"
var defined_choosers = {}
function defineChooser(name) {

View File

@ -1,3 +1,6 @@
import { dancerSubstitution } from "./define-figure.js"
import { throw_up } from "./util.js"
var invertPairHash = {
ladles: "gentlespoons",
gentlespoons: "ladles",
@ -10,7 +13,7 @@ var invertPairHash = {
// 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.
// Formerly known as dancers complement.
function invertPair(whostr, dialect) {
export function invertPair(whostr, dialect) {
if (!whostr) {
return "others"
} // undefined is ok

View File

@ -8,12 +8,21 @@
// and related support functions for dealing with figures
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 {
FLATTEN_FORMAT_HTML,
FLATTEN_FORMAT_SAFE_TEXT,
FLATTEN_FORMAT_UNSAFE_TEXT,
Words,
lingoLineWords,
words,
} 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)
}
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)
}
@ -153,7 +162,7 @@ function parameterSubstitution(formal_parameter, actual_parameter, dialect) {
}
// 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
}
@ -186,7 +195,7 @@ export function moveSubstitution(move_term, dialect) {
return sub.replace(moveSubstitutionPercentSRegexp, " ").trim()
}
function moveSubstitutionWithEscape(move_term, dialect) {
export function moveSubstitutionWithEscape(move_term, dialect) {
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
// user, and so are optional.
// Check the specs for lots of examples.
function moveSubstitutionWithoutForm(
export function moveSubstitutionWithoutForm(
move_term,
dialect,
add_article,

View File

@ -6,7 +6,7 @@
//
// keep it sorted alphabetically
import { param } from "./param.js"
import { param, stringParamHand, stringParamShoulders, stringParamShouldersTerse } from "./param.js"
import {
defineFigure,
defineFigureAlias,
@ -15,8 +15,13 @@ import {
goodBeatsMinFn,
moveSubstitution,
parameter_strings,
parameter_words,
moveSubstitutionWithoutForm,
moveSubstitutionWithEscape,
} from "./define-figure.js"
import { dancerIsPair, heyLengthMeetTimes, indefiniteArticleFor, parseHeyLength, throw_up } from "./util.js";
import { comma, words } from "./words.js";
import { invertPair } from "./dance.js";
////////////////////////////////////////////////
// ALLEMANDE //

View File

@ -10,7 +10,7 @@
// 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 {
degreesToPlaces,
@ -18,6 +18,10 @@ import {
moveCaresAboutPlaces,
moveCaresAboutRotations,
} from "./move.js";
import {
lingoLineWords,
} from "./words.js";
import { dancerSubstitution, stringInDialect } from "./define-figure.js";
const __params = {}
@ -196,13 +200,13 @@ var stringParamClock = makeTurnStringParam(
"____"
)
var stringParamLeftRight = makeTurnStringParam("left", "right", "*", "____")
var stringParamShoulders = makeTurnStringParam(
export var stringParamShoulders = makeTurnStringParam(
"right shoulders",
"left shoulders",
"* shoulders",
"____"
)
var stringParamShouldersTerse = makeTurnStringParam(
export var stringParamShouldersTerse = makeTurnStringParam(
"rights",
"lefts",
"* shoulders",
@ -214,7 +218,7 @@ var stringParamHandStarHand = makeTurnStringParam(
"* hand",
"____"
)
var stringParamHand = makeTurnStringParam("right", "left", "*", "____")
export var stringParamHand = makeTurnStringParam("right", "left", "*", "____")
// spin = clockwise | ccw | undefined
defineParam("spin", {

View File

@ -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 =
"[\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
function indefiniteArticleFor(w) {
export function indefiniteArticleFor(w) {
var str = peek(w)
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
return !!dialect.text_in_dialect
}
@ -115,7 +120,7 @@ export const libfigureObjectCopy = hash => {
return o
}
function libfigureUniq(array) {
export function libfigureUniq(array) {
// suboptimal O(n^2)
var output = []
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]
function parseHeyLength(hey_length) {
export function parseHeyLength(hey_length) {
if (hey_length === "full" || hey_length === "between half and full") {
return [hey_length, 2]
} 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)
}
function heyLengthMeetTimes(hey_length) {
export function heyLengthMeetTimes(hey_length) {
return parseHeyLength(hey_length)[1]
}
function dancerIsPair(dancer) {
export function dancerIsPair(dancer) {
return dancerMenuForChooser(chooser("chooser_pair")).indexOf(dancer) >= 0
}

View File

@ -2,6 +2,7 @@ import {
longestFirstSortFn,
PUNCTUATION_CHARSET_STRING,
regExpEscape,
throw_up,
} from "./util.js"
import { dancers } from "./chooser.js"
import { moves } from "./define-figure.js"
@ -10,7 +11,7 @@ export function Words(arr) {
this.arr = arr
}
export const words = function() {
export const words = function () {
return new Words(Array.prototype.slice.call(arguments))
}