Advertisement
Guest User

strj string quotation bug

a guest
May 31st, 2010
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.96 KB | None | 0 0
  1. module sdf2imp/project/create-common-trans
  2.  
  3. imports
  4. sdf2imp/util/-
  5.  
  6. strategies
  7.  
  8. create-common-trans =
  9. name := <trans-module-name>;
  10. sdf-name := <get-sdf-main-module>;
  11.  
  12. try(<file-exists <+ mkdir> "lib");
  13. <output-text-file(|["lib"], "editor-common.generated.str")>
  14. ${module lib/editor-common.generated
  15.  
  16. imports
  17. libstratego-lib
  18. libstratego-sglr
  19. libstratego-gpp
  20.  
  21. strategies
  22.  
  23. parse-file = parse-{name}-file
  24. parse-{name}-file =
  25. parse-file(
  26. strsglr-perror, strsglr-report-parse-error
  27. | <import-term(include/{sdf-name}.tbl)>
  28. )
  29.  
  30. parse-string = parse-{name}-string
  31. parse-{name}-string =
  32. parse-string(
  33. strsglr-report-parse-error
  34. | <import-term(include/{sdf-name}.tbl)>
  35. )
  36.  
  37. parse-stream = parse-{name}-stream
  38. parse-{name}-stream =
  39. parse-stream(
  40. strsglr-report-parse-error
  41. | <import-term(include/{sdf-name}.tbl)>
  42. )
  43.  
  44. pp-{name}-string =
  45. ast2abox(|[<import-term(include/{sdf-name}.generated.pp.af)>,
  46. <import-term(include/{sdf-name}.pp.af)>]);
  47. box2text-string(|100)
  48.  
  49. strategies
  50.  
  51. /**
  52. * Processes an import during semantic analysis.
  53. * Ensures proper caching of files and prevents
  54. * processing duplicate imports more than once.
  55. *
  56. * @param resolve-path Resolves the filesystem path of this import
  57. * @param parse-file Parses a file (optionally removing definition bodies
  58. * so only signatures are stored in the cache)
  59. * @param record-declarations
  60. * Performs semantic analysis on a tree
  61. */
  62. open-import(resolve-path, parse-file, record-declarations):
  63. import -> import
  64. where
  65. if not(!import => COMPLETION(_)) then
  66. path := <resolve-path> import;
  67. cache-path := <import-cache-path> path;
  68. if not(<IsImported> path) then
  69. rules(
  70. IsImported: path
  71. );
  72. if <is-newer> (cache-path, path) then
  73. file := <ReadFromFile> cache-path
  74. else
  75. file := <parse-file> path;
  76. if <file-exists> path then
  77. // Only cache if on filesystem (e.g., ignore libstratego-lib)
  78. <WriteToBinaryFile> (cache-path, file)
  79. end
  80. end;
  81. ${$| CurrentFile:
  82. rules(CurrentFile := path);
  83. <record-declarations> file
  84. |$}$
  85. end
  86. end
  87.  
  88. open-wildcard-import(resolve-path, parse-file, record-declarations, is-source-file):
  89. import -> import
  90. where
  91. if not(!import => COMPLETION(_)) then
  92. path := <resolve-path> import;
  93. readdir;
  94. list-loop(
  95. if is-source-file then
  96. <open-import(id, parse-file, record-declarations)>
  97. $[[path]/[<id>]]
  98. <+
  99. try(?one-failed)
  100. end
  101. );
  102. not(!one-failed)
  103. end
  104.  
  105. import-cache-path:
  106. full-path -> cache-path
  107. with
  108. project-path := <project-path>;
  109. cache-dir := <file-exists <+ mkdir> $[[project-path]/.cache];
  110. full-path' := <string-replace(|"/", "+"); string-replace(|"{"\\\\"}", "+"); string-replace(|":", "+")> full-path;
  111. cache-path := $[[cache-dir]/[full-path'].sig]
  112.  
  113. project-path = prim("SSL_EXT_projectpath")
  114.  
  115. is-newer:
  116. (file1, file2) -> <id>
  117. where
  118. <gt> (<file-exists; modification-time> file1, <file-exists; modification-time> file2)
  119.  
  120. strategies
  121.  
  122. editor-init =
  123. // Ensure all dynamic rules are properly scoped
  124. try(dr-scope-all-end);
  125. dr-scope-all-start
  126.  
  127. refresh-workspace-file:
  128. path -> <prim("SSL_EXT_refreshresource", path)>
  129.  
  130. strategies
  131.  
  132. origin-term = prim("SSL_EXT_origin_term", <id>)
  133. origin-text = prim("SSL_EXT_origin_text", <id>)
  134. origin-location = prim("SSL_EXT_origin_location", <id>)
  135. origin-line = origin-location => (<id>, _, _, _)
  136. origin-column = origin-location => (_, <id>, _, _)
  137. origin-strip = prim("SSL_EXT_origin_strip", <id>)
  138. origin-equal(|t) = prim("SSL_EXT_origin_equal", <id>, t)
  139.  
  140. origin-surrounding-comments =
  141. prim("SSL_EXT_origin_surrounding_comments", "{sdf-name}", <id>)
  142.  
  143. origin-documentation-comment =
  144. origin-surrounding-comments;
  145. filter(string-as-chars(documentation-comment-chars));
  146. concat-strings
  147.  
  148. documentation-comment-chars:
  149. ['*' | c*] -> <ltrim(' ' + '\t' + '\n' + '\r')> c*
  150.  
  151. origin-track-forced(s) =
  152. !Some(<id>); all(s); ?Some(<id>)
  153.  
  154. strategies
  155.  
  156. desugar-position(desugar|ast):
  157. position -> position'
  158. where
  159. ast' := <at-position(!<id>${$MARKER()$}$|position)> ast;
  160. ast'' := <topdown(repeat(preserve-annos(${$?x; desugar; not(?x)$}$)))> ast';
  161. position' := <position-of-term({$[{?_{a*}; <one(?MARKER())> a*}]})> ast''
  162.  
  163. at-position(s|position):
  164. c#(t*) -> t'
  165. where
  166. !position => [i | position']
  167. where
  168. t' := c#(<at-index(at-position(s|position'))> (i, t*))
  169.  
  170. at-position(s|position):
  171. t -> t'
  172. where
  173. !position => [];
  174. t' := <s> t
  175.  
  176. position-of-term(is-term):
  177. t -> []
  178. where
  179. is-term
  180.  
  181. position-of-term(is-term):
  182. _#(t*) -> <position-of-term(is-term|0)> t*
  183.  
  184. position-of-term(is-term|start-index):
  185. [t | t*] -> position
  186. where
  187. if i* := <position-of-term(is-term)> t then
  188. position := [start-index | i*]
  189. else
  190. position := <position-of-term(is-term | <inc> start-index)> t*
  191. end
  192.  
  193. term-at-position(|position):
  194. t -> t'
  195. where
  196. at-position(?t'|position)
  197.  
  198. parent-at-position(|position):
  199. t -> t'
  200. where
  201. !position => [i, _];
  202. t' := <subterm-at(|i)> t
  203.  
  204. parent-at-position(|position):
  205. t -> <parent-at-position(|position')> t'
  206. where
  207. !position => [i | position' @ [_, _ | _]];
  208. t' := <subterm-at(|i)> t
  209.  
  210. subterm-at(|index):
  211. _#(t*) -> <index(|<inc> index)> t*
  212.  
  213. signature constructors
  214.  
  215. COMPLETION : String -> Term
  216. NOCONTEXT : Term -> Term
  217. MARKER : Term
  218.  
  219. // Below are copies of the signatures of the terms used in example
  220. // trans/{name}.str file. These definitions should also be automatically
  221. // generated in the imported include/{sdf-name}.str module. However,
  222. // to ensure that the example transformation doesn't break when the
  223. // syntax is changed, we also hard-coded them here.
  224.  
  225. Module : ID * List(Entity) -> Module
  226. Entity : ID * List(Property) -> Entity
  227. Property : ID * Type -> Property
  228. Type : ID -> Type
  229.  
  230. strategies
  231.  
  232. // Set markers for a given file. Use when checking files from a queued strategy.
  233. // Current term: (ast-desugared, errors, warnings, notes) tuple
  234. // ast: the root node of the file to set markers on
  235. set-markers(|ast) = prim("SSL_EXT_set_markers", ast)
  236.  
  237. // Indicate that one or more files need analysis.
  238. // Current term: either a list of absolute file paths, or a single absolute file path to analyze
  239. queue-analysis =
  240. (is-list; list-loop(queue-analysis))
  241. <+ prim("SSL_EXT_queue_analysis")
  242.  
  243. // Set the total number of work units to complete. Can be called multiple times.
  244. // Current term: number of work units (int).
  245. set-total-work-units = prim("SSL_EXT_set_total_work_units")
  246.  
  247. // Complete one work unit and update progress monitors.
  248. // Current term: ignored
  249. complete-work-unit = prim("SSL_EXT_complete_work_unit")
  250.  
  251. // Queue a strategy for background processing with a progress indicator.
  252. // Current term: the term to pass to the background strategy
  253. // s: the strategy, as string
  254. // description: name of the task (will be shown in progress view)
  255. queue-strategy(|s,description) = prim("SSL_EXT_queue_strategy", s, description)
  256.  
  257. // Return the result of this strategy to indicate a non-completed (backgrounded) analysis.
  258. // Editor services (hover, resolve) will be delayed until a complete analysis is performed.
  259. set-analysis-backgrounded = !"BACKGROUNDED"
  260.  
  261. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement