Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Analyze ¶
func Analyze(ctx context.Context, parserConfig ParserConfig, input externalcmd.Input, printDebug bool) (map[string]SingleResult, error)
Analyze (parsing.Analyze) parses the specified list of files using all supported parsers and returns a map of filename to slice of parsing.SingleResult. Each slice holds information about source code tokens found for that file for each supported langauge parser.
Currently, the only supported language is JavaScript, however more language parsers will be added in the future.
Input can be specified either by file path or by passing the source code string directly. To parse a file, specify its path using sourceFile; the value of sourceString is ignored. If sourceFile is empty, then sourceString is parsed directly as code.
If parsing is attempted in a given langauge and fails due to syntax errors, the value for that language in the returned map is nil, with no other error.
If an internal error occurs during parsing, parsing is interrupted and the error returned.
Note: In JavaScript, there is no distinction between integer and floating point literals; they are normally both parsed as floating point. This function records a numeric literal as an integer if it can be converted using strconv.Atoi(), otherwise it is recorded as floating point.
func RunExampleParsing ¶
func RunExampleParsing(ctx context.Context, config ParserConfig, input externalcmd.Input)
Types ¶
type ExtractedStrings ¶
func FindStringsInCode ¶
func FindStringsInCode(source string, stringRegexp *regexp.Regexp) (*ExtractedStrings, error)
func FindStringsInFile ¶
func FindStringsInFile(filePath string, stringRegexp *regexp.Regexp) (*ExtractedStrings, error)
type Language ¶
type Language string
Language represents a programming language used for parsing.
func SupportedLanguages ¶
func SupportedLanguages() []Language
type ParserConfig ¶
func InitParser ¶
func InitParser(ctx context.Context, installDir string) (ParserConfig, error)
type SingleResult ¶
type SingleResult struct { Language Language `json:"language"` Identifiers []token.Identifier `json:"identifiers"` StringLiterals []token.String `json:"string_literals"` IntLiterals []token.Int `json:"int_literals"` FloatLiterals []token.Float `json:"float_literals"` Comments []token.Comment `json:"comments"` }
SingleResult holds processed information about source code tokens found in a single file by a single language parser
func (SingleResult) String ¶
func (r SingleResult) String() string