From dfd39f0b14794b360fd6c961c65ab45d229e00b1 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 22 Jul 2018 13:59:08 -0700 Subject: Shifting further towards having inline tests. Also added a helper function for directly extracting source lines from a Source or AST. --- lib/os.nom | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') 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" -- cgit v1.2.3