diff --git a/src/parser/parse-chars.ts b/src/parser/parse-chars.ts index b41a529..af7b053 100644 --- a/src/parser/parse-chars.ts +++ b/src/parser/parse-chars.ts @@ -31,7 +31,7 @@ export const parseChars = ( if (token.is("(")) { const subList = parseChars(file, { nested: true }); - subList.mayBeTuple = true; + subList.setAttribute("tuple?", true); list.push(subList); continue; } diff --git a/src/parser/syntax-macros/functional-notation.ts b/src/parser/syntax-macros/functional-notation.ts index d1bf9c9..bbeff4e 100644 --- a/src/parser/syntax-macros/functional-notation.ts +++ b/src/parser/syntax-macros/functional-notation.ts @@ -28,7 +28,7 @@ export const functionalNotation = (list: List): List => { return handleNextExpression(acc, expr, nextExpr, array, index); } - if (list.mayBeTuple && idIs(expr, ",")) { + if (list.getAttribute("tuple?") && idIs(expr, ",")) { isTuple = true; } @@ -76,12 +76,12 @@ const finalizeResult = (result: ListValue[], isTuple: boolean): List => { }; const processGenerics = (expr: Expr, generics: List, params?: List): List => { - generics.mayBeTuple = false; + generics.setAttribute("tuple?", false); const list = params || new List([]); list.insert(expr); list.insert(",", 1); - list.mayBeTuple = false; + list.setAttribute("tuple?", false); const functional = functionalNotation(list); functional.insert(functionalNotation(generics), 2); @@ -92,6 +92,6 @@ const processGenerics = (expr: Expr, generics: List, params?: List): List => { const processParamList = (expr: Expr, params: List): List => { params.insert(expr); params.insert(",", 1); - params.mayBeTuple = false; + params.setAttribute("tuple?", false); return functionalNotation(params); }; diff --git a/src/syntax-objects/list.ts b/src/syntax-objects/list.ts index 267f722..2e9db1a 100644 --- a/src/syntax-objects/list.ts +++ b/src/syntax-objects/list.ts @@ -15,15 +15,12 @@ type ListOpts = export class List extends Syntax { readonly syntaxType = "list"; - /** True when the list was defined by the user using parenthesis i.e. (hey, there) */ - mayBeTuple?: boolean; #store = new ChildList(undefined, this); constructor(opts: ListOpts) { opts = Array.isArray(opts) ? { value: opts } : opts; super(opts); const value = opts.value; - this.mayBeTuple = opts.isParentheticalList; if (!value || value instanceof Array) { this.push(...(value ?? [])); @@ -213,7 +210,6 @@ export class List extends Syntax { return new List({ ...super.getCloneOpts(parent), value: this.#store.toClonedArray(), - isParentheticalList: this.mayBeTuple, }); } }