本文整理匯總了TypeScript中parsimmon.Parser.desc方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Parser.desc方法的具體用法?TypeScript Parser.desc怎麽用?TypeScript Parser.desc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類parsimmon.Parser
的用法示例。
在下文中一共展示了Parser.desc方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: success
barPar = barPar = fooPar.result(bar);
fooOrBarPar = fooPar.fallback(bar);
// -- -- -- -- -- -- -- -- -- -- -- -- --
fooArrPar = fooPar.many();
fooArrPar = fooPar.times(num);
fooArrPar = fooPar.times(num, num);
fooArrPar = fooPar.atMost(num);
fooArrPar = fooPar.atLeast(num);
fooMarkPar = fooPar.mark();
fooPar = fooPar.desc(str);
// -- -- -- -- -- -- -- -- -- -- -- -- --
strPar = P.string(str);
strPar = P.regex(regex);
fooPar = P.succeed(foo);
fooArrPar = P.seq(fooPar, fooPar);
var par: Parser<[Bar, Foo, number]> = P.seq(barPar, fooPar, numPar);
var par2: Parser<number> = P.seq(barPar, fooPar, numPar).map(([a, b, c]: [Bar, Foo, number]) => 42);
fooPar = P.custom<Foo>((success, failure) => (stream, i) => { str = stream; num = i; return success(num, foo); });
fooPar = P.custom<Foo>((success, failure) => (stream, i) => failure(num, str));
示例2:
barPar = barPar = fooPar.result(bar);
fooOrBarPar = fooPar.fallback(bar);
// -- -- -- -- -- -- -- -- -- -- -- -- --
fooArrPar = fooPar.many();
fooArrPar = fooPar.times(num);
fooArrPar = fooPar.times(num, num);
fooArrPar = fooPar.atMost(num);
fooArrPar = fooPar.atLeast(num);
fooMarkPar = fooPar.mark();
fooPar = fooPar.desc(str);
fooPar = fooPar.desc([str, str]);
// -- -- -- -- -- -- -- -- -- -- -- -- --
strPar = P.string(str);
strPar = P.regex(/rgx/);
fooPar = P.succeed(foo);
fooArrPar = P.seq(fooPar, fooPar);
const par: Parser<[Bar, Foo, number]> = P.seq(barPar, fooPar, numPar);
const par2: Parser<number> = P.seq(barPar, fooPar, numPar).map(([a, b, c]: [Bar, Foo, number]) => 42);
interface SeqObj {
first: number;
示例3: assertParse
}
],
functionReturn: 'void'
});
assertParse(functionType, '(info: OnClickData, tab?: chrome.tabs.Tab) => void');
interface FunctionDeclaration {
functionName: string;
functionArguments: FunctionArgument[];
functionReturn: TypeSignature;
}
const exportFunctionDeclaration: Parser<FunctionDeclaration> =
seq(
lexemeS('export')
.then(lexemeS('function'))
.then(identifier.desc('function name')),
lparen
.then(sepBy(functionArgument, lexemeS(',')))
.skip(rparen),
colon
.then(typeSignature)
.skip(string(';')) // Let's not eat whitespace here.
).map(([functionName, functionArguments, functionReturn]: [string, FunctionArgument[], TypeSignature]) => ({
functionName,
functionArguments,
functionReturn
}));
assertParse(
exportFunctionDeclaration,
'export function remove(menuItemId: string, callback?: () => void): void;',