Skip to main content

module analysis::grammars::LOC

rascal-Not specified

Generic utilities to compute (S)LOC metrics based on grammars

Usage​

import analysis::grammars::LOC;

Dependencies​

import ParseTree;
import List;
import util::FileSystem;
import util::Reflective;

Description​

We use this definition to separate lines from: http://en.wikipedia.org/wiki/Newline:

  • LF: Line Feed, U+000A
  • VT: Vertical Tab, U+000B
  • FF: Form Feed, U+000C
  • CR: Carriage Return, U+000D
  • CR+LF: CR (U+000D) followed by LF (U+000A)
  • NEL: Next Line, U+0085
  • LS: Line Separator, U+2028
  • PS: Paragraph Separator, U+2029

alias Stats​

tuple[int total, map[loc file, int sloc] dist]

function slocStats​

Stats slocStats(file(loc l), Stats stats)

Stats slocStats(directory(loc l, kids), Stats stats)

default Stats slocStats(FileSystem _, Stats stats)

data Output​

data Output  
= newline()
| stuff()
;

function countSLOC​

int countSLOC(Tree t)

function isLayout​

bool isLayout(appl(prod(\layouts(_), _, _), _))

bool isLayout(amb({*_, appl(prod(\layouts(_), _, _), _)}))

default bool isLayout(Tree t)

function isComment​

bool isComment(appl(p:prod(_, _, {*_, \tag("category"("Comment"))}), _))

bool isComment(appl(p:prod(_, _, {*_, \tag("category"("comment"))}), _))

default bool isComment(Tree _)

function isLF​

bool isLF(int c)

function isVT​

bool isVT(int c)

function isFF​

bool isFF(int c)

function isCR​

bool isCR(int c)

function isNEL​

bool isNEL(int c)

function isLS​

bool isLS(int c)

function isPS​

bool isPS(int c)

function isNewLineChar​

bool isNewLineChar(int c)