How to classify this interpreter

39 Views Asked by At

Currently, I am working on an interpreter(?) for a DSL. I'm having trouble finding how exactly to classify it though. I'm not even sure if you could call it an interpreter.

I've tried searching about the different types of interpreters, but so far the ones I've found don't seem to cover what I have.

TLDR: It essentially works by constructing an object with a network of predefined functors. When the object is called it traverses this network doing any work that needs done.

How it works:

  • Each file describes a behavior (essentially, when this condition is met do this) in a YAML like syntax

partial example:

Action:
 Condition: *list of sub conditions*
 Response: *list of sub actions*
  • At runtime, for each file, a new behavior object is created

  • each part with a ':' is a component, each component is implemented as a functor that gets added to its parent component. or the behavior itself if its a top level component

example:

Action:  // adds a new action functor with its child components
  Condition: 10 seconds elapsed // creates a time elapsed functor with 10 seconds bound to it
  Response: set value 5 // creates a set functor with the value 5 bound to it (made up example)

This results in value being set to 5 every 10 seconds.

  • Each of the behaviors is then held in a higher object and periodically called upon from there

Thank you very much.

I'm not the best at explaining myself so if you have any questions please ask.

1

There are 1 best solutions below

0
banan3'14 On

It's not an interpreter, it's a parser of a declaration language.

A parser, in turn, takes a sequence of tokens and produces an abstract syntax tree (AST) of a language. The rules by which a parser operates are usually specified by a formal grammar. An interpreter is a program that interprets the AST of the source of a program on the fly (without compiling it first).