abusalimov

configfile-symbols.mk

Mar 12th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 3.33 KB | None | 0 0
  1. # Generated by GOLD Parser Builder using Mybuild program template.
  2.  
  3. # Symbol constructors for 'ConfigFile' grammar.
  4.  
  5. #
  6. # Each terminal symbol is converted by the corresponding constructor (if any).
  7. # Constructor is a function named '$(gold_grammar)_create-<ID>' (where ID is
  8. # a unique symbol identifier) with the following signature:
  9. #
  10. # Params:
  11. #   1. A list of decimal char codes representing the token.
  12. #
  13. # Return:
  14. #   The converted value, which is then passed as an argument to a production
  15. #   function of the rule containing that symbol in its RHS.
  16. #
  17. # If constructor for some symbol is not defined then the default behavior
  18. # is used, which is to decode an input by replacing all printable characters
  19. # with their values and the rest ones with spaces.
  20. #
  21. # Constructor may also use a special 'gold_default_create' function to get
  22. # the default value.
  23. #
  24.  
  25. # Symbol: BooleanLiteral
  26. define $(gold_grammar)_create-BooleanLiteral
  27.     $(if $(filter true,$(gold_default_create)),1)
  28. endef
  29.  
  30. # Symbol: Identifier
  31. define $(gold_grammar)_create-Identifier
  32.     $(gold_default_create:^%=%)
  33. endef
  34.  
  35. # Symbol: NumberLiteral
  36. define $(gold_grammar)_create-NumberLiteral
  37.     $(or \
  38.         $(filter-out 0x%,$(gold_default_create)),
  39.         $(call gold_report_warning,
  40.                 NYI: Hex literals)
  41.     )
  42. endef
  43.  
  44. # Symbol: StringLiteral
  45. define $(gold_grammar)_create-StringLiteral
  46.     $(subst \\ ,\,# Unescape '\' sequences.
  47.         $(subst \',',
  48.             $(if $(eq ",$(call gold_default_create,$(firstword $1))),
  49.                 # Regular "..." string.
  50.                 $(subst \",",$(subst \t,$(\t),$(subst \n,$(\n),$(subst \r,,
  51.                     $(subst \\,\\ ,
  52.                         $(call gold_default_create,
  53.                             # Remove '"' at the ends.
  54.                             $(wordlist 3,$(words $1),x $1)
  55.                         )
  56.                     )
  57.                 )))),
  58.                 # Verbatim '''...''' string.
  59.                 $(subst \\,\\ ,
  60.                     $(call gold_default_create,
  61.                         # Remove ''' at the ends.
  62.                         $(wordlist 7,$(words $1),x x x $1)
  63.                     )
  64.                 )
  65.             )
  66.         )
  67.     )
  68. endef
  69.  
  70. #
  71. # Optimized contructors for constant terminals (i.e. keywords and punctuation).
  72. #
  73.  
  74. $(gold_grammar)_create-LParan           := (
  75. $(gold_grammar)_create-RParan           := )
  76. $(gold_grammar)_create-Comma            := ,
  77. $(gold_grammar)_create-Dot              := .
  78. $(gold_grammar)_create-DotTimes         := .*
  79. $(gold_grammar)_create-LBrace           := {
  80. $(gold_grammar)_create-RBrace           := }
  81. $(gold_grammar)_create-Eq               := =
  82. $(gold_grammar)_create-configuration    := configuration
  83. $(gold_grammar)_create-import           := import
  84. $(gold_grammar)_create-include          := include
  85. $(gold_grammar)_create-package          := package
  86.  
  87. #
  88. # For each regular terminal we also define a constant with a human-readable
  89. # description used for error reporting.
  90. #
  91.  
  92. $(gold_grammar)_name_of-LParan          := '('
  93. $(gold_grammar)_name_of-RParan          := ')'
  94. $(gold_grammar)_name_of-Comma           := ','
  95. $(gold_grammar)_name_of-Dot             := '.'
  96. $(gold_grammar)_name_of-DotTimes        := '.*'
  97. $(gold_grammar)_name_of-LBrace          := '{'
  98. $(gold_grammar)_name_of-RBrace          := '}'
  99. $(gold_grammar)_name_of-Eq              := '='
  100. $(gold_grammar)_name_of-configuration   := configuration
  101. $(gold_grammar)_name_of-Identifier      := Identifier
  102. $(gold_grammar)_name_of-import          := import
  103. $(gold_grammar)_name_of-include         := include
  104. $(gold_grammar)_name_of-package         := package
Advertisement
Add Comment
Please, Sign In to add comment