Skip to content

Brackets with nested functions that have multiple parameters #2

@jersonal-com

Description

@jersonal-com

Thanks a lot for the great library.

I am having trouble when nesting functions. I defined a simple minimum function that takes 2 parameters and returns the lower of the two (see below). When used in isolation the function works as expected.

When using min(1,min(2,3)) (or any other case where one function is nested into another one) I get a BrackedNotClosedException (line 438 in parser.dart).

It seems that the parser separates min(2, as a second parameter to the first min function.

class MathFunctionMin implements MathDefinitionFunctionFreeformImplemented {
  @override
  final name = 'min';
  @override
  final minArgumentsCount = 2;
  @override
  final maxArgumentsCount = 2;

  @override
  num calc(
      List<MathNode> args,
      MathVariableValues values, {
        required MathCustomFunctionsImplemented customFunctions,
      }) {
    return min(args[0].calc(values, customFunctions: customFunctions),
      args[1].calc(values, customFunctions: customFunctions),
    );
  }

  @override
  bool hasSameName(String other) {
    return other == name;
  }

  @override
  bool isCompatible(MathDefinitionFunctionFreeform other) {
    return hasSameName(other.name) &&
        minArgumentsCount == other.minArgumentsCount &&
        maxArgumentsCount == other.maxArgumentsCount;
  }

  const MathFunctionMin();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions