Skip to content

Commit c133416

Browse files
committed
Reorder some parser definitions to avoid laziness
1 parent 411a68b commit c133416

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/language/parsing/atom.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import {
33
anySingleCharacter,
44
as,
55
butNot,
6-
lazy,
76
literal,
87
map,
98
oneOf,
109
oneOrMore,
1110
sequence,
12-
zeroOrMore,
11+
zeroOrMore
1312
} from '@matt.kantor/parsing'
1413
import { optionallySurroundedByParentheses } from './parentheses.js'
1514
import { whitespace } from './trivia.js'
@@ -40,9 +39,6 @@ const atomComponentsRequiringQuotation = [
4039
literal('*/'),
4140
] as const
4241

43-
export const atomParser: Parser<Atom> = optionallySurroundedByParentheses(
44-
lazy(() => oneOf([unquotedAtomParser, quotedAtomParser])),
45-
)
4642

4743
export const atomWithAdditionalQuotationRequirements = (
4844
additionalQuoteRequiringComponent: Parser<unknown>,
@@ -99,3 +95,7 @@ const quotedAtomParser = map(
9995
]),
10096
([_1, contents, _2]) => contents,
10197
)
98+
99+
export const atomParser: Parser<Atom> = optionallySurroundedByParentheses(
100+
oneOf([unquotedAtomParser, quotedAtomParser]),
101+
)

src/language/parsing/molecule.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ import { trivia } from './trivia.js'
2020

2121
export type Molecule = { readonly [key: Atom]: Molecule | Atom }
2222

23-
export const moleculeParser: Parser<Molecule> = lazy(
24-
() => potentiallySugaredMolecule,
25-
)
26-
2723
// Keyless properties are automatically assigned numeric indexes, which uses some mutable state.
2824
type Indexer = () => string
2925
const makeIncrementingIndexer = (): Indexer => {
@@ -210,3 +206,5 @@ const potentiallySugaredMolecule: Parser<Molecule> = (() => {
210206
potentiallySugaredNonApply,
211207
])
212208
})()
209+
210+
export const moleculeParser: Parser<Molecule> = potentiallySugaredMolecule

0 commit comments

Comments
 (0)