gml.pegjs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright t lefering
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * These are the four essential freedoms with GNU GPL software:
  18. * 1: freedom to run the program, for any purpose
  19. * 2: freedom to study how the program works, and change it to make it do what you wish
  20. * 3: freedom to redistribute copies to help your Free Software friends
  21. * 4: freedom to distribute copies of your modified versions to your Free Software friends
  22. * , ,
  23. * / \
  24. * ((__-^^-,-^^-__))
  25. * `-_---' `---_-'
  26. * `--|o` 'o|--'
  27. * \ ` /
  28. * ): :(
  29. * :o_o:
  30. * "-"
  31. *
  32. * SPDX-License-Identifier: GPL-3.0+
  33. * License-Filename: LICENSE
  34. */
  35. file = _ head _ id _ list _
  36. head = (pair)*
  37. list = "[" _ some_items* _ "]" _
  38. some_items = id list2 / pair
  39. list2 = _ "[" _ some_items* _ "]" _
  40. pair = (id string) / (id id) / (id fpnum) / (id digit)
  41. digit = (("-"[0-9]+ _ ) / ("+"[0-9]+ _ ) / ([0-9]+ _ ))
  42. fpnum = (("-"[0-9]*["."][0-9]* _ ) / ("+"[0-9]*["."][0-9]* _ ) / ([0-9]*["."][0-9]* _ ))
  43. id = [a-zA-Z_]+[a-zA-Z_0-9]* _
  44. string = '"' char* '"' _
  45. char =
  46. "\\" "\""
  47. / "\\" "\\"
  48. / "\\" "b"
  49. / "\\" "f"
  50. / "\\" "n"
  51. / "\\" "r"
  52. / "\\" "t"
  53. / (!"\"" .)
  54. _ = (space / comment / endofline)*
  55. space = (" " / "\t" / endofline)
  56. comment = "#" (!endofline .)*
  57. endofline = ( "\r\n" / "\n" / "\r" / "\n\r" )