# domain specific language

A domain-specific language is created specifically to solve problems in a particular domain and is not intended to be able to solve problems outside of it (although that may be technically possible)

# category

  1. internal dsl
  2. external dsl
  3. Language Workbench(dsl gui)

# relationship

# understandability

workbench > external dsl > internal dsl(declarative) > command-query api (imperative)

# difficulty

workbench > external dsl > internal dsl(declarative) > command-query api (imperative)

# when should i use it

when the benefits of using a dsl outweigh the cost of building it

# simple tutorial (external dsl)

base domain specific language book and use typescript translate

# state machine model

dsl miss state

code (opens new window)

test (opens new window)

# custom syntax


events
    doorClosed   D1CL
    drawerOpened D2OP
    lightOn      L1ON
    doorOpened   D1OP
    panelClosed  PNCL
end

resetEvents
    doorOpened
end

commands
    unlockPanel PNUL
    lockPanel   PNLK
    lockDoor    D1LK
    unlockDoor  D1UL
end

state idle
    actions {unlockDoor lockPanel}
    doorClosed => active
end

state active
    drawerOpened => waitingForLight
    lightOn => waitingForDrawer
end

state waitingForLight
    lightOn => unlockedPanel
end

state waitingForDrawer
    drawerOpened => unlockedPanel
end

state unlockedPanel
    actions {unlockPanel lockDoor}
    panelClosed => idle
end

# lexical parser

process: input > scannerPatterns scanRecognizer > tokens > stateMachineTokenizer

code (opens new window)

test (opens new window)

# syntax parser

code (opens new window)

test (opens new window)

# parser combinators

code (opens new window)

test (opens new window)

# parser generator(antlr)

code (opens new window)

test (opens new window)

# other

wikipedia dsl (opens new window)

jetbrains dsl (opens new window)

domain specific language (opens new window)

language deplementation patterns (opens new window)

antlr 4 (opens new window)

antlr.org (opens new window)

antlr 4 ts (opens new window)