Gather all parser-related files to parser/ dir
This commit is contained in:
parent
f0fcdb0949
commit
e306691af5
|
|
@ -1,4 +1,4 @@
|
|||
import { IntervalLabelTokenValue } from "./tokenizer";
|
||||
import { IntervalLabelTokenValue } from "./parser/tokenizer";
|
||||
|
||||
export type Workout = {
|
||||
name: string;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import * as fs from "fs";
|
|||
import { generateZwo } from "./generateZwo";
|
||||
import { parse } from "./parser";
|
||||
import { stats } from "./stats";
|
||||
import { tokenize } from "./tokenizer";
|
||||
|
||||
const opts = { stats: false, filename: "" };
|
||||
if (process.argv[2] === "--stats") {
|
||||
|
|
@ -12,7 +11,7 @@ if (process.argv[2] === "--stats") {
|
|||
opts.filename = process.argv[2];
|
||||
}
|
||||
|
||||
const workout = parse(tokenize(fs.readFileSync(opts.filename, "utf8")));
|
||||
const workout = parse(fs.readFileSync(opts.filename, "utf8"));
|
||||
|
||||
if (opts.stats) {
|
||||
console.log(stats(workout));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
import { Workout } from "../ast";
|
||||
import { parseTokens } from "./parser";
|
||||
import { tokenize } from "./tokenizer";
|
||||
|
||||
export const parse = (source: string): Workout => parseTokens(tokenize(source));
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { Interval, Workout } from "./ast";
|
||||
import { Interval, Workout } from "../ast";
|
||||
import { isIntervalLabelTokenValue, Token } from "./tokenizer";
|
||||
|
||||
type Header = Partial<Omit<Workout, "intervals">>;
|
||||
|
|
@ -105,7 +105,7 @@ const parseIntervals = (tokens: Token[]): Interval[] => {
|
|||
return intervals;
|
||||
};
|
||||
|
||||
export const parse = (tokens: Token[]): Workout => {
|
||||
export const parseTokens = (tokens: Token[]): Workout => {
|
||||
const [header, intervalTokens] = parseHeader(tokens);
|
||||
return {
|
||||
name: header.name || "",
|
||||
Loading…
Reference in New Issue