Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatchReport: rework internal data structure of matches. #51

Merged
merged 8 commits into from Feb 20, 2019

Autofix: tslint

[atomist:generated] [atomist:autofix=tslint]
  • Loading branch information...
atomist-bot committed Feb 20, 2019
commit 0f96b1e9437d0bd79b3d28f66412aec8b949ae18
Copy path View file
@@ -87,7 +87,7 @@ export class Microgrammar<T> implements Grammar<T> {
* @return {Updatable<T>}
*/
public static updatable<T>(matches: Array<T & PatternMatch>,
content: string): Updatable<T> {
content: string): Updatable<T> {
return new Updatable<T>(matches, content);
}

@@ -122,8 +122,8 @@ export class Microgrammar<T> implements Grammar<T> {
* @return {Microgrammar<T>}
*/
public static fromString<T = any>(spec: string,
components: TermsDefinition<T> = {} as any,
options: FromStringOptions = {}): Microgrammar<T> {
components: TermsDefinition<T> = {} as any,
options: FromStringOptions = {}): Microgrammar<T> {
return new Microgrammar<T>(
new MicrogrammarSpecParser().fromString(spec, components, options));
}
@@ -138,8 +138,8 @@ export class Microgrammar<T> implements Grammar<T> {
* @return {Microgrammar<T>}
*/
public static fromStringAs<T = any>(spec: string,
components: TermsDefinition<T> = {} as any,
options: FromStringOptions = {}): Microgrammar<AnyKeysOf<T>> {
components: TermsDefinition<T> = {} as any,
options: FromStringOptions = {}): Microgrammar<AnyKeysOf<T>> {
return this.fromString(spec, components, options);
}

@@ -171,9 +171,9 @@ export class Microgrammar<T> implements Grammar<T> {
* @return {PatternMatch[]}
*/
public findMatches(input: string | InputStream,
parseContext?: {},
l?: Listeners,
stopAfterMatch: (pm: PatternMatch) => boolean = () => false): Array<T & PatternMatch> {
parseContext?: {},
l?: Listeners,
stopAfterMatch: (pm: PatternMatch) => boolean = () => false): Array<T & PatternMatch> {
const lm = new LazyMatcher(this.matcher, stopAfterMatch);
lm.consume(input, parseContext, l);
return lm.matches as Array<T & PatternMatch>;
@@ -186,7 +186,7 @@ export class Microgrammar<T> implements Grammar<T> {
* @return {Promise<Array<T & PatternMatch>>}
*/
public async findMatchesAsync(input: string | InputStream,
parseContext?: {}): Promise<Array<T & PatternMatch>> {
parseContext?: {}): Promise<Array<T & PatternMatch>> {
const matches = [];
for (const m of matchesIn(this.matcher, input, parseContext)) {
matches.push(m);
Copy path View file
@@ -19,14 +19,14 @@ import { inputStateFromStream } from "./InputStateFactory";
import { failedMatchReport } from "./matchReport/failedMatchReport";

export function exactMatch<T>(matcher: MatchingLogic, input: string | InputStream,
parseContext = {},
l?: Listeners): PatternMatch & T | DismatchReport {
parseContext = {},
l?: Listeners): PatternMatch & T | DismatchReport {
return toPatternMatchOrDismatchReport<T>(perfectMatch(matcher, input, parseContext, l));
}

export function perfectMatch(matcher: MatchingLogic, input: string | InputStream,
parseContext = {},
l?: Listeners): MatchReport {
parseContext = {},
l?: Listeners): MatchReport {
const inputState = inputStateFromStream(toInputStream(input), l);

const result = matcher.matchPrefixReport(inputState, {}, parseContext);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.