# Module: lexicalAnalyzer

Contains all functions used for parsing command arguments and/or business rule argumetns.

Author:
  - Seth Hollingsead
Copyright:
  - Copyright © 2022-… by Seth Hollingsead. All rights reserved
Source:
  - businessRules/rules/lexicalAnalyzer.js, line 1

### Requires

- module:ruleParsing
- module:configurator
- module:loggers
- @haystacks/constants
- path

### Methods

#### (inner) analyzeArgument(inputData, inputMetaData) → {string|array.<(string|integer|boolean|object)>}

Does additional parsing of an individual argument. Identifies the case that the argument needs to be treated as an array, then the function will clean the array string tags and split the string into an array and return it. This function can also identify the case that an argument contains a regular expression that must be formally created, using the RegExp constructor, then the RegExp object will be returned as part of the return object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The argument string that needs additional parsing.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/lexicalAnalyzer.js, line 90

##### Returns:

The argument that should be returned and sued by the system after all necessary parsing.

Type
  string | array.<(string|integer|boolean|object)>

#### (inner) analyzeForRegularExpression(inputData, inputMetaData) → {boolean}

Analyzes the argument value to determine if it incudes a regular expression or no regular expression.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The business rule argument that should be analyzed to determine if it includes a regular expression or not regular expression.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/lexicalAnalyzer.js, line 186

##### Returns:

True or False to indicate if the argument contains a regular expression or no regular expression.

Type
  boolean

#### (inner) parseArgumentAsArray(inputData, inputMetaData) → {array.<string>}

Parses teh argument as an array and return the array.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | A string that contains an array, we will use the secondary command delimiter to split the string into an array.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/lexicalAnalyzer.js, line 265

##### Returns:

An array of strings.

Type
  array.<string>

#### (inner) parseArgumentAsRegularExpression(inputData, inputMetaData) → {object}

Parses the argument as a regular expression and returns a new RegExp object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The argument string that should be parsed as a RegExp.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/lexicalAnalyzer.js, line 217

##### Returns:

A RegExp object.

Type
  object

#### (inner) parseBusinessRuleArgument(inputData, inputMetaData) → {string|array.<(string|integer|boolean|object)>}

Parses a single business rule argument and returns it after cleaning it up or doing required operations on it to convert it to valid input for a command as necessary.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | array.<(string|integer|boolean|object)> | The value of the argument, could be an array or a string.
`inputMetaData` | integer | The index of the argument (1, 2, 3, 4).

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/lexicalAnalyzer.js, line 28

##### Returns:

The value of the argument as it should be passed into the business rule call.

Type
  string | array.<(string|integer|boolean|object)>

#### (inner) removeStringLiteralTagsFromArray(inputData, inputMetaData) → {array.<string>}

Removes all string literal tags from all the argument array elements passed as input to the function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | array.<string> | The argument array that should have the string literal tags removed. The string literal tag is the tilde character: "~"
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/lexicalAnalyzer.js, line 358

##### Returns:

Teh same as the input, but just with the string literal tags removed from all array elements.

Type
  array.<string>