This subsystem translates given text to an stream of tokens. It is necessary intermediate step for building AST (abstract syntax tree).
You can plug in this subsystem into your code as:
import * as Scanner from '<path-to-framework>/DSLF.Scanner'
This subsystem has such public components:
namespace Scanner.Token
namespace Scanner.Types
interface Scanner.Component
interface Scanner.Context
class Scanner.Base
💡
Scanner.Token
is the namespaces that contains basic definition for Token- Token is an object that contains specific information about language symbol
- Members:
namespace Types
class Base
- basic definition for type of tokenclass Basic
- most frequently used types of token
namespace Information
interface Base<T>
- basic definition of additional information about tokennamespace Defaults
- most frequently used types of additional information about tokenclass Placement
- class that have information about token's placement
type Base
- basic definition of tokentype: Token.Types.Base
- type of tokenvalue: Token.Value
- value of tokenplacement: Token.Information.Defaults.Placement
- information about placement of symbol
Scanner.Types
is the namespace that contains basic type declarations that necessary for scanner- Members:
type Cursor
type Accumulator
Scanner.Component
is the basic definition for scanner component- Components are main functional parts of scanner (a.k.a "subscanners")
- Members:
Scan(context: Scanner.Context, cursor: Scanner.Commons.Cursor): Scanner.Token.Base | void
- scanning strategy
Scanner.Context
is the basic definition for context, where components of scanner can share some information
Scanner.Base
is the type of scanner itself- This class has two main methods to use:
Scan(input: string): Scanner.Token.Base[]
- scans input by customisable handlerUse(component: () => Scanner.Component): void
- adds customisable handler
This subsystem translates given stream of token to AST (abstract syntax tree).
You can plug in this subsystem into your code as:
import * as Parser from '<path-to-framework>/DSLF.Parser'
This subsystem has such public components:
namespace Parser.Types
namespace Parser.Nodes
namespace Parser.Components
abstract class Parser.Layer<T extends Parser.Nodes.Base>
abstract class Parser.LayerWithReferenceToTop<T extends Parser.Nodes.Base>
class Parser.Base<T extends Parser.Nodes.Base>
💡
- Parser.Types is the namespace that contains basic type declarations that necessary for parser
- Parser.Nodes is the namespace that contains basic definitions for nodes
- Node is an element of AST (abstract syntax tree).
- Members:
interface Base
- basic definition of nodeinterface Translatable
- definition for translatable nodeTranslatable.Translate(): string
- translation strategy
interface Executable<T> extends Base
- definition for executable nodeExecutable.Execute(context: Parser.Nodes.Additional.Context): T
- execution strategy
namespace Default
- namespace that contains default nodes realisationsnamespace Default.Block
namespace Default.Primitives
namespace Additional
interface Context
namespace Categories
- namespace that contains various categories for nodestype Terminal
- type forterminal node
Parser.Components
is the namespace that contains basic definitions for components- Components are the main functional parts of the parser (a.k.a "subparsers"). The main purpose of the components is generation AST (abstract syntax tree)
- Members:
interface Base<T extends Parser.Nodes.Base>
- definition for basic componentBase.Parse(environment: Environment<T>): T
- parsing strategy
Parser.Layers
is the namespace that contains basic layer definition- Members:
abstract class Base<T extends Parser.Nodes.Base>
- is a part of recursive descent parsingExecuteSuccessorParser(): T
- method that calls successor layer parser
abstract class WithReferenceToTop<T extends Parser.Nodes.Base>
- is the same asParser.Layer
but with reference to top layerExecuteSuccessorParser(): T
- method that calls successor layer parserExecuteTopParser(): T
- method that calls top layer parser
Parser.Base
is the type of parser itself.- This class has two main methods you can use:
UseTerminal(parser: () => Parser.Component.Base<T>): void
- methods that adds terminal expression parsers to base parserUse(priority: number, parser: () => Parser.Component.Base<T>): void
- method that adds non-terminal expression parsers to base parser with given priority (biggerpriority
<=> less priority)Parse(): T[]
Go to file Examples/Example.ts
and look at how this used for create your own programming language
- Go to folder with your project
- Open terminal in this folder
- After downloading, type
npm i js-ds-language-framework --save-dev
- You're ready! Enjoy! ❤️
This package created by Saitov Denis