cedric-demongivert / unidoc

A reactive parser written in typescript for a LaTeX and XML inspired tag language.
GNU General Public License v3.0
1 stars 0 forks source link

Exposing a SymbolProducer interface. #3

Closed cedric-demongivert closed 3 years ago

cedric-demongivert commented 3 years ago

Currently, the engine only allows to instantiate a producer of symbols by using a Reader that is a pull-based way to get symbols.

These pull-based objects must be converted into a push-based producer of Symbols via the UnidocSymbolReader.asProducer factory.

The addition of an UnidocSymbolProducer interface with user-friendly factories may be a great addition to the library.

The interface must allow to replace this kind of code :

const source: UnidocProducer<UnidocSymbol> = UnidocSymbolReader.asProducer(UnidocSymbolReader.fromString('document'))

By this kind of code :

const source: UnidocProducer<UnidocSymbol> = UnidocSymbolProducer.fromString('document')

Also, the interface may allow to define a 'read' method requirement that allow to start the reading process.

const source: UnidocSymbolProducer = UnidocSymbolProducer.fromString('document')

// Unidoc pipeline creation.

source.read()
cedric-demongivert commented 3 years ago

This kind of interface is also a way to mask pull-based and push-based-only implementations.

cedric-demongivert commented 3 years ago

Creation of a UnidocGenerator interface for pull-based implementations. Creation of a UnidocSymbolGenerator interface for pull-based symbol extractors. Creation of a UnidocSource interface for reading sources of symbols.