Skip to content

Literal

xtay2 edited this page Feb 15, 2023 · 7 revisions

Introduction

The Literal represents a terminal string in an EBNF which is a symbol that cannot be further decomposed into smaller sections. To initialise it, call the constructor with a literal String.

Methods

  • matches(String input): boolean: returns true if the input string matches the literal string, ignoring leading and trailing whitespaces.

  • maxMatchLength(String input): int: returns the length of the longest substring of the input string that matches the literal string, counting leading whitespaces. If there is no match, returns 0.

  • firstMatch(String input): int: returns the index of the first occurrence of the literal string in the input string, ignoring leading and trailing whitespaces. If there is no match, returns the length of the input string.

Example Matches

new Literal("abc");
"abc"
" abc "
"   abc"

Clone this wiki locally