statement.go 982 B

123456789101112131415161718192021222324252627282930313233343536
  1. package ini
  2. // Statement is an empty AST mostly used for transitioning states.
  3. func newStatement() AST {
  4. return newAST(ASTKindStatement, AST{})
  5. }
  6. // SectionStatement represents a section AST
  7. func newSectionStatement(tok Token) AST {
  8. return newASTWithRootToken(ASTKindSectionStatement, tok)
  9. }
  10. // ExprStatement represents a completed expression AST
  11. func newExprStatement(ast AST) AST {
  12. return newAST(ASTKindExprStatement, ast)
  13. }
  14. // CommentStatement represents a comment in the ini definition.
  15. //
  16. // grammar:
  17. // comment -> #comment' | ;comment'
  18. // comment' -> epsilon | value
  19. func newCommentStatement(tok Token) AST {
  20. return newAST(ASTKindCommentStatement, newExpression(tok))
  21. }
  22. // CompletedSectionStatement represents a completed section
  23. func newCompletedSectionStatement(ast AST) AST {
  24. return newAST(ASTKindCompletedSectionStatement, ast)
  25. }
  26. // SkipStatement is used to skip whole statements
  27. func newSkipStatement(ast AST) AST {
  28. return newAST(ASTKindSkipStatement, ast)
  29. }