doc.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Package ini is an LL(1) parser for configuration files.
  2. //
  3. // Example:
  4. // sections, err := ini.OpenFile("/path/to/file")
  5. // if err != nil {
  6. // panic(err)
  7. // }
  8. //
  9. // profile := "foo"
  10. // section, ok := sections.GetSection(profile)
  11. // if !ok {
  12. // fmt.Printf("section %q could not be found", profile)
  13. // }
  14. //
  15. // Below is the BNF that describes this parser
  16. // Grammar:
  17. // stmt -> section | stmt'
  18. // stmt' -> epsilon | expr
  19. // expr -> value (stmt)* | equal_expr (stmt)*
  20. // equal_expr -> value ( ':' | '=' ) equal_expr'
  21. // equal_expr' -> number | string | quoted_string
  22. // quoted_string -> " quoted_string'
  23. // quoted_string' -> string quoted_string_end
  24. // quoted_string_end -> "
  25. //
  26. // section -> [ section'
  27. // section' -> section_value section_close
  28. // section_value -> number | string_subset | boolean | quoted_string_subset
  29. // quoted_string_subset -> " quoted_string_subset'
  30. // quoted_string_subset' -> string_subset quoted_string_end
  31. // quoted_string_subset -> "
  32. // section_close -> ]
  33. //
  34. // value -> number | string_subset | boolean
  35. // string -> ? UTF-8 Code-Points except '\n' (U+000A) and '\r\n' (U+000D U+000A) ?
  36. // string_subset -> ? Code-points excepted by <string> grammar except ':' (U+003A), '=' (U+003D), '[' (U+005B), and ']' (U+005D) ?
  37. //
  38. // SkipState will skip (NL WS)+
  39. //
  40. // comment -> # comment' | ; comment'
  41. // comment' -> epsilon | value
  42. package ini