parser.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package muesli
  2. import (
  3. _ "bytes"
  4. _ "errors"
  5. _ "fmt"
  6. _ "io"
  7. _ "reflect"
  8. _ "runtime"
  9. _ "strings"
  10. _ "unicode"
  11. _ "io"
  12. _ "os"
  13. _ "bufio"
  14. _ "unicode"
  15. // "gitlab.com/beoran/woe/graphviz"
  16. // _ "gitlab.com/beoran/woe/monolog"
  17. "gitlab.com/beoran/gdast/tree"
  18. )
  19. type AstKind int
  20. const (
  21. AstKindProgram = AstKind(iota)
  22. AstKindStatements
  23. AstKindStatement
  24. AstKindCommand
  25. AstKindArguments
  26. AstKindBlock
  27. AstKindList
  28. AstKindCapture
  29. AstKindWordValue
  30. AstKindWord
  31. AstKindType
  32. AstKindValue
  33. AstKindEox
  34. AstKindError
  35. )
  36. /* Run time values */
  37. type Value interface {
  38. }
  39. type IntValue int64
  40. type FloatValue float64
  41. type StringValue string
  42. type BoolValue bool
  43. type WordValue string
  44. type TypeValue string
  45. type AnyValue struct {
  46. }
  47. type ListValue struct {
  48. List []Value
  49. }
  50. type Token struct {
  51. TokenKind
  52. Value
  53. Position
  54. }
  55. /* AST node kind */
  56. type Ast struct {
  57. tree.Node
  58. AstKind
  59. * Token
  60. }
  61. type Parser struct {
  62. Lexer
  63. Ast
  64. }
  65. func (parser * Parser) ParseProgram() error {
  66. /*
  67. for parser.Position < len(Input) {
  68. }
  69. */
  70. return nil
  71. }
  72. func (parser * Parser) Parse() (Ast, error) {
  73. parser.Index = 0
  74. err := parser.ParseProgram()
  75. return parser.Ast, err
  76. }