types.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * ECAL
  3. *
  4. * Copyright 2020 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the MIT
  7. * License, If a copy of the MIT License was not distributed with this
  8. * file, You can obtain one at https://opensource.org/licenses/MIT.
  9. */
  10. package util
  11. import "devt.de/krotik/ecal/parser"
  12. /*
  13. Processor models a top level execution instance for ECAL.
  14. */
  15. type Processor interface {
  16. }
  17. /*
  18. ECALImportLocator is used to resolve imports.
  19. */
  20. type ECALImportLocator interface {
  21. /*
  22. Resolve a given import path and parse the imported file into an AST.
  23. */
  24. Resolve(path string) (string, error)
  25. }
  26. /*
  27. ECALFunction models a callable function in ECAL.
  28. */
  29. type ECALFunction interface {
  30. /*
  31. Run executes this function. The envirnment provides a unique instanceID for
  32. every code location in the running code, the variable scope of the function,
  33. an instance state which can be used in combinartion with the instanceID
  34. to store instance specific state (e.g. for iterator functions) and a list
  35. of argument values which were passed to the function by the calling code.
  36. */
  37. Run(instanceID string, vs parser.Scope, is map[string]interface{}, args []interface{}) (interface{}, error)
  38. /*
  39. DocString returns a descriptive text about this function.
  40. */
  41. DocString() (string, error)
  42. }
  43. /*
  44. Logger is required external object to which the interpreter releases its log messages.
  45. */
  46. type Logger interface {
  47. /*
  48. LogError adds a new error log message.
  49. */
  50. LogError(v ...interface{})
  51. /*
  52. LogInfo adds a new info log message.
  53. */
  54. LogInfo(v ...interface{})
  55. /*
  56. LogDebug adds a new debug log message.
  57. */
  58. LogDebug(v ...interface{})
  59. }