logoPlayer-lexique.galgas 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. lexique logoPlayer_lexique {
  2. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  3. # Identifiers and keywords *
  4. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  5. @string tokenString
  6. style keywordsStyle -> "Keywords"
  7. $identifier$ ! tokenString error message "an identifier"
  8. #--- This is the keyword list
  9. list keyWordList style keywordsStyle error message "the '%K' keyword" {
  10. "begin",
  11. "end"
  12. }
  13. rule 'a'->'z' | 'A'->'Z' {
  14. repeat
  15. enterCharacterIntoString (!?tokenString !*)
  16. while 'a'->'z' | 'A'->'Z' | '_' | '0'->'9' :
  17. end
  18. send search tokenString in keyWordList default $identifier$
  19. }
  20. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  21. # Literal decimal integers *
  22. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  23. style integerStyle -> "Integer Constants"
  24. @uint uint32value
  25. $integer$ !uint32value style integerStyle error message "a 32-bit unsigned decimal number"
  26. message decimalNumberTooLarge : "decimal number too large"
  27. message internalError : "internal error"
  28. rule '0'->'9' {
  29. enterCharacterIntoString (!?tokenString !*)
  30. repeat
  31. while '0'->'9' :
  32. enterCharacterIntoString (!?tokenString !*)
  33. while '_' :
  34. end
  35. convertDecimalStringIntoUInt (!tokenString !?uint32value error decimalNumberTooLarge, internalError)
  36. send $integer$
  37. }
  38. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  39. # Literal character strings *
  40. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  41. style stringStyle -> "String Constants"
  42. $"string"$ ! tokenString style stringStyle %nonAtomicSelection error message "a character string constant \"...\""
  43. message incorrectStringEnd : "string does not end with '\"'"
  44. rule '"' {
  45. repeat
  46. while ' ' | '!' | '#'-> '\uFFFD' :
  47. enterCharacterIntoString (!?tokenString !*)
  48. end
  49. select
  50. case '"' :
  51. send $"string"$
  52. default
  53. error incorrectStringEnd
  54. end
  55. }
  56. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  57. # Delimiters *
  58. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  59. style delimitersStyle -> "Delimiters"
  60. list delimitorsList style delimitersStyle error message "the '%K' delimitor" {
  61. ":", ",", ";", "!", "{", "}", "->", "@", "*", "-"
  62. }
  63. rule list delimitorsList
  64. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  65. # Comments *
  66. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  67. style commentStyle -> "Comments"
  68. $comment$ style commentStyle %nonAtomicSelection error message "a comment"
  69. rule '#' {
  70. repeat
  71. while '\u0001' -> '\u0009' | '\u000B' | '\u000C' | '\u000E' -> '\uFFFD' :
  72. end
  73. drop $comment$
  74. }
  75. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  76. # Separators *
  77. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  78. rule '\u0001' -> ' ' {
  79. }
  80. #———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  81. }