tom-weatherhead/thaw-parser

View on GitHub
src/ll1-parser.ts

Summary

Maintainability
C
1 day
Test Coverage

Function llDriver has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    private llDriver(tokenList: IToken[], parse: boolean): unknown {
        if (tokenList.length === 0) {
            throw new ParserException('Token list is empty');
        }

Severity: Minor
Found in src/ll1-parser.ts - About 6 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function llDriver has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private llDriver(tokenList: IToken[], parse: boolean): unknown {
        if (tokenList.length === 0) {
            throw new ParserException('Token list is empty');
        }

Severity: Major
Found in src/ll1-parser.ts - About 3 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                    } else if (symbolX === tokenAsSymbol) {
                        // console.log(`Matched token/symbol ${X}`);
    
                        if (parse) {
                            this.grammar.pushTokenOntoSemanticStack(
    Severity: Major
    Found in src/ll1-parser.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for (let i = p.rhs.length - 1; i >= 0; --i) {
                              if ((p.rhs[i] as GrammarSymbol) !== GrammarSymbol.Lambda) {
                                  // Push semantic actions, and any symbols except Lambda.
                                  parseStack.push(p.rhs[i]);
                              }
      Severity: Major
      Found in src/ll1-parser.ts - About 45 mins to fix

        Function fillParseTable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private fillParseTable(): ReadonlyMap<string, IProduction> {
                const parseTable = new Map<string, IProduction>();
        
                for (const p of this.grammar.productions) {
                    const pValue = this.predict.get(p);
        Severity: Minor
        Found in src/ll1-parser.ts - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function fillPredict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private fillPredict(): ReadonlyMap<IProduction, IImmutableSet<GrammarSymbol>> {
                const predict = new Map<IProduction, IImmutableSet<GrammarSymbol>>();
        
                for (const p of this.grammar.productions) {
                    let s = this.computeFirst(p.getRHSWithNoSemanticActions());
        Severity: Minor
        Found in src/ll1-parser.ts - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        There are no issues that match your filters.

        Category
        Status