gml.pegjs 667 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. file = _ head _ id _ list _
  2. head = (pair)*
  3. list = "[" _ some_items* _ "]" _
  4. some_items = id list2 / pair
  5. list2 = _ "[" _ some_items* _ "]" _
  6. pair = (id string) / (id id) / (id fpnum) / (id digit)
  7. digit = (("-"[0-9]+ _ ) / ("+"[0-9]+ _ ) / ([0-9]+ _ ))
  8. fpnum = (("-"[0-9]*["."][0-9]* _ ) / ("+"[0-9]*["."][0-9]* _ ) / ([0-9]*["."][0-9]* _ ))
  9. id = [a-zA-Z_]+[a-zA-Z_0-9]* _
  10. string = '"' char* '"' _
  11. char =
  12. "\\" "\""
  13. / "\\" "\\"
  14. / "\\" "b"
  15. / "\\" "f"
  16. / "\\" "n"
  17. / "\\" "r"
  18. / "\\" "t"
  19. / (!"\"" .)
  20. _ = (space / comment / endofline)*
  21. space = (" " / "\t" / endofline)
  22. comment = "#" (!endofline .)*
  23. endofline = ( "\r\n" / "\n" / "\r" / "\n\r" )