Class GherkinParser

java.lang.Object
io.karatelabs.parser.BaseParser
io.karatelabs.gherkin.GherkinParser

public class GherkinParser extends io.karatelabs.parser.BaseParser
  • Nested Class Summary

    Nested classes/interfaces inherited from class io.karatelabs.parser.BaseParser

    io.karatelabs.parser.BaseParser.Shift
  • Field Summary

    Fields inherited from class io.karatelabs.parser.BaseParser

    errorRecoveryEnabled, resource, tokens
  • Constructor Summary

    Constructors
    Constructor
    Description
    GherkinParser(io.karatelabs.common.Resource resource)
     
    GherkinParser(io.karatelabs.common.Resource resource, boolean errorRecovery)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    io.karatelabs.parser.Node
     
    static List<io.karatelabs.parser.Token>
    getTokens(io.karatelabs.common.Resource resource)
     
     
    Parses a match expression string into a MatchExpression object.

    Methods inherited from class io.karatelabs.parser.BaseParser

    anyOf, anyOf, consume, consumeIf, consumeNext, consumeSoft, enter, enter, enter, enter, enterIf, enterIf, error, error, error, exit, exit, exit, exitSoft, getErrors, getPosition, hasErrors, isCallerType, lastConsumed, lastConsumedText, markerNode, next, noLineTerminatorBefore, peek, peekAnyOf, peekAnyOf, peekIf, peekToken, recoverTo, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GherkinParser

      public GherkinParser(io.karatelabs.common.Resource resource)
    • GherkinParser

      public GherkinParser(io.karatelabs.common.Resource resource, boolean errorRecovery)
  • Method Details

    • getTokens

      public static List<io.karatelabs.parser.Token> getTokens(io.karatelabs.common.Resource resource)
    • getAst

      public io.karatelabs.parser.Node getAst()
      Returns:
      the AST root node (G_FEATURE) for IDE features
    • parse

      public Feature parse()
    • parseMatchExpression

      public static MatchExpression parseMatchExpression(String expression)
      Parses a match expression string into a MatchExpression object. Uses token positions to preserve exact spacing in expressions like json['key']. The LHS is evaluated as JS by the step executor.
      Parameters:
      expression - e.g., "foo == bar" or "each item contains { a: 1 }"
      Returns:
      parsed MatchExpression
      Throws:
      RuntimeException - if the expression cannot be parsed