logoPlayer-lexique.galgas 2.0 KB

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