aboutsummaryrefslogtreecommitdiff
path: root/lib/os.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-22 13:59:08 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-22 13:59:08 -0700
commitdfd39f0b14794b360fd6c961c65ab45d229e00b1 (patch)
tree51f0c30ef3a32c969c63321da8164436a3ba8b31 /lib/os.nom
parent01d5f810ed7fd6e9b261b1fe793f8666970b2068 (diff)
Shifting further towards having inline tests. Also added a helper
function for directly extracting source lines from a Source or AST.
Diffstat (limited to 'lib/os.nom')
-rw-r--r--lib/os.nom8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/os.nom b/lib/os.nom
index 1f8d6a7..1acc41f 100644
--- a/lib/os.nom
+++ b/lib/os.nom
@@ -45,3 +45,11 @@ action [..]
action [line number of %pos in %str] (=lua "Files.get_line_number(\%str, \%pos)")
action [line %line_num in %str] (=lua "Files.get_line(\%str, \%line_num)")
+action [source lines of %tree]:
+ %source = (%tree.source if (%tree is syntax tree) else %tree)
+ %file = (read file %source.filename)
+ return (..)
+ (..)
+ (line % in %file) for % in (line number of %source.start in %file) to (..)
+ line number of %source.stop in %file
+ ..joined with "\n"