doc.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. //
  17. // Grammar:
  18. // stmt -> section | stmt'
  19. // stmt' -> epsilon | expr
  20. // expr -> value (stmt)* | equal_expr (stmt)*
  21. // equal_expr -> value ( ':' | '=' ) equal_expr'
  22. // equal_expr' -> number | string | quoted_string
  23. // quoted_string -> " quoted_string'
  24. // quoted_string' -> string quoted_string_end
  25. // quoted_string_end -> "
  26. //
  27. // section -> [ section'
  28. // section' -> section_value section_close
  29. // section_value -> number | string_subset | boolean | quoted_string_subset
  30. // quoted_string_subset -> " quoted_string_subset'
  31. // quoted_string_subset' -> string_subset quoted_string_end
  32. // quoted_string_subset -> "
  33. // section_close -> ]
  34. //
  35. // value -> number | string_subset | boolean
  36. // string -> ? UTF-8 Code-Points except '\n' (U+000A) and '\r\n' (U+000D U+000A) ?
  37. // string_subset -> ? Code-points excepted by <string> grammar except ':' (U+003A), '=' (U+003D), '[' (U+005B), and ']' (U+005D) ?
  38. //
  39. // SkipState will skip (NL WS)+
  40. //
  41. // comment -> # comment' | ; comment'
  42. // comment' -> epsilon | value
  43. package ini