Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 3ae455119b
Fetching contributors…

Cannot retrieve contributors at this time

203 lines (164 sloc) 5.684 kB
module lib/editor-common
imports
libstratego-lib
libstratego-sglr
libstratego-gpp
mobl
strategies
/*parse-file =
parse-file(strsglr-perror, strsglr-report-parse-error| <memo-open-parse-table> <import-term(include/MoBL.tbl)>)*/
parse-file =
parse-file(
strsglr-perror, strsglr-report-parse-error
| <import-term(include/MoBL.tbl)>
)
/*parse-string =
parse-string(|<import-term(include/MoBL.tbl)>)*/
project-path = prim("SSL_EXT_projectpath")
plugin-path = prim("SSL_EXT_pluginpath")
pp-mobl-string =
ast2abox(|[<import-term(include/MoBL.generated.pp.af)>,
<import-term(include/MoBL.pp.af)>]);
box2text-string(|100)
strategies
/**
* Processes an import during semantic analysis.
* Ensures proper caching of files and prevents
* processing duplicate imports more than once.
*
* @param resolve-path Resolves the filesystem path of this import
* @param parse-file Parses a file (optionally removing definition bodies
* so only signatures are stored in the cache)
* @param record-declarations
* Performs semantic analysis on a tree
*/
open-import(resolve-path, parse-file, externalize):
import -> defs
where
if not(!import => COMPLETION(_)) then
path := <resolve-path> import;
cache-path := <import-cache-path> path;
if not(<CachedImport> path) then
if <CachedParseAst> import then
defs := <externalize <+ debug(!"Could not externalize: "); fail> <CachedParseAst> import
else
if <is-newer> (cache-path, path) then
defs := <ReadFromFile> cache-path
else
defs := <parse-file; externalize <+ debug(!"Could not parse/externalize: "); fail> path;
if <file-exists> path then
// Only cache if on filesystem (e.g., ignore libstratego-lib)
<WriteToBinaryFile> (cache-path, defs)
end
end
end
; rules (
CachedImport : path -> defs
)
else
defs := <CachedImport> path
end
end
open-wildcard-import(resolve-path, parse-file, record-declarations, is-source-file):
import -> import
where
if not(!import => COMPLETION(_)) then
path := <resolve-path> import;
readdir;
list-loop(
if is-source-file then
<open-import(resolve-path, parse-file, record-declarations)>
$[[path]/[<id>]]
<+
try(?one-failed)
end
);
not(!one-failed)
end
import-cache-path:
full-path -> cache-path
with
project-path := "."; // <prim("SSL_EXT_projectpath")>;
cache-dir := <file-exists <+ mkdir> $[[project-path]/.cache];
full-path' := <string-replace(|"/", "+"); string-replace(|"\\", "+"); string-replace(|":", "+")> full-path;
cache-path := $[[cache-dir]/[full-path'].sig]
is-newer:
(file1, file2) -> <id>
where
<gt> (<file-exists; modification-time> file1, <file-exists; modification-time> file2)
strategies
refresh-workspace-file :
f -> <try(not(Standalone); prim("SSL_EXT_refreshresource", f))>
dummy-rule = rules ( Standalone := 0 )
project-path = prim("SSL_EXT_projectpath")
strategies
desugar-position(desugar|ast):
position -> position'
where
ast' := <at-position(!<id>{MARKER()}|position)> ast;
ast'' := <topdown(repeat(preserve-annos({?x; desugar; not(?x)})))> ast';
position' := <position-of-term({?_{a*}; <one(?MARKER())> a*})> ast''
at-position(s|position):
c#(t*) -> t'
where
!position => [i | position']
where
t' := c#(<at-index(at-position(s|position'))> (i, t*))
at-position(s|position):
t -> t'
where
!position => [];
t' := <s> t
position-of-term(is-term):
t -> []
where
is-term
position-of-term(is-term):
_#(t*) -> <position-of-term(is-term|0)> t*
position-of-term(is-term|start-index):
[t | t*] -> position
where
if i* := <position-of-term(is-term)> t then
position := [start-index | i*]
else
position := <position-of-term(is-term | <inc> start-index)> t*
end
term-at-position(|position):
t -> t'
where
at-position(?t'|position)
parent-at-position(|position):
t -> t'
where
!position => [i, _];
t' := <subterm-at(|i)> t
parent-at-position(|position):
t -> <parent-at-position(|position')> t'
where
!position => [i | position' @ [_, _ | _]];
t' := <subterm-at(|i)> t
subterm-at(|index):
_#(t*) -> <index(|<inc> index)> t*
strategies
origin-term = prim("SSL_EXT_origin_term", <id>)
origin-text = prim("SSL_EXT_origin_text", <id>)
origin-location = prim("SSL_EXT_origin_location", <id>)
origin-line = origin-location => (<id>, _, _, _)
origin-column = origin-location => (_, <id>, _, _)
origin-strip = prim("SSL_EXT_origin_strip", <id>)
origin-equal(|t) = prim("SSL_EXT_origin_equal", <id>, t)
origin-surrounding-comments =
prim("SSL_EXT_origin_surrounding_comments", "MoBL", <id>)
origin-documentation-comment =
origin-surrounding-comments;
filter(string-as-chars(documentation-comment-chars));
concat-strings
documentation-comment-chars:
['*' | c*] -> <ltrim(' ' + '\t' + '\n' + '\r')> c*
origin-track-forced(s) =
!Some(<id>); all(s); ?Some(<id>)
signature constructors
COMPLETION : String -> Term
NOCONTEXT : Term -> Term
UNKNOWN : Term -> Term
MARKER : Term
Jump to Line
Something went wrong with that request. Please try again.