Skip to content

Commit

Permalink
Feat: reducing regex complexity, keeping whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
01Parzival10 committed Oct 9, 2024
1 parent 057a139 commit cf8d5f0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/features/dfdElements/outputPortBehaviorValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ export class PortBehaviorValidator {
// Regex that validates assignments
// Matches "Assignment({input_Pins};Term;{out_Label})"
private static readonly ASSIGNMENT_REGEX =
/^Assignment\(\{(([A-Za-z0-9_\|]+(,\s*[A-Za-z0-9_\|]+)*)?)\};(\s*|!|TRUE|FALSE|\|\||&&|\(|\)|([A-Za-z][A-Za-z0-9_]*\.[A-Za-z][A-Za-z0-9_]*))+;\{(((([A-Za-z][A-Za-z0-9_\|]*)\.([A-Za-z][A-Za-z0-9_\|]*))+(,\s*(([A-Za-z][A-Za-z0-9_\|]*)\.([A-Za-z][A-Za-z0-9_\|]*)))*)?)\}\)+$/;
/^Assignment\(\{(([A-Za-z0-9_\|]+(,\s*[A-Za-z0-9_\|]+)*)?)\};(\s*|!|TRUE|FALSE|\|\||&&|\(|\)|([A-Za-z0-9_]*\.[A-Za-z0-9_]*))+;\{(((([A-Za-z0-9_\|]*)\.[A-Za-z0-9_\|]*)+(,\s*([A-Za-z0-9_\|]*\.[A-Za-z0-9_\|]*))*)?)\}\)+$/;

// Regex that validates forwarding
// Matches "Forwarding({input_pins})"
private static readonly FORWARDING_REGEX = /^Forwarding\(\{[A-Za-z0-9_\|]+(,\s*[A-Za-z0-9_\|]+)*\}\)$/;

// Regex that validates a term
// Matches Constants, Operants and Label References
private static readonly TERM_REGEX =
/^(\s*|!|TRUE|FALSE|\|\||&&|\(|\)|([A-Za-z][A-Za-z0-9_]*\.[A-Za-z][A-Za-z0-9_]*))+$/;
// Has the label type and label value that should be set as capturing groups.
private static readonly TERM_REGEX = /^(\s*|!|TRUE|FALSE|\|\||&&|\(|\)|([A-Za-z0-9_]*\.[A-Za-z0-9_]*))+$/;

// Regex matching alphanumeric characters.
public static readonly REGEX_ALPHANUMERIC = /[A-Za-z0-9_\|]+/;
Expand Down

0 comments on commit cf8d5f0

Please sign in to comment.