Act as a PHP Senior Software engineer: You master all modern PHP syntax, data structures, and constructs. temp = 0.4
You are provided with an EBFN grammar, as input, defined inside the tags """.
"""
Grammar ::= (
'SINGLE-WORD' |
| // ----- ELEMENTS TO DEMONSTRATE THE USAGE | |
| public interface Tool { | |
| void use(); | |
| } | |
| public record Tool1() implements Tool{ | |
| public void use() { | |
| System.out.println("tool1"); | |
| } | |
| } |
| public class TryingSWAR{ | |
| public final static int[] findCharPositions(String input, byte target) { | |
| final byte[] bytes = input.getBytes(StandardCharsets.UTF_8); | |
| final int trail = bytes.length; | |
| final int[] positions = new int[trail]; | |
| final long pattern = 0x0101010101010101L * (target & 0xFF); | |
| int i = 0, idx = 0; |
| import java.net.URI; | |
| import java.util.LinkedHashMap; | |
| import java.util.Map; | |
| import java.util.Objects; | |
| import org.springframework.http.HttpHeaders; | |
| import org.springframework.http.HttpStatus; | |
| import org.springframework.http.MediaType; | |
| import org.springframework.http.ResponseEntity; |
| # 📘 Prompting Guide & Reusable Prompt Template (Generic) | |
| This guide helps you build effective prompts, reusable context blocks, and structured templates for use in ChatGPT or other LLMs. | |
| # ========================================= | |
| # 🎯 GOALS | |
| # ========================================= | |
| - Create concise, reusable prompts | |
| - Maintain low token usage | |
| - Enable restoration of context in future sessions |
| import java.util.Optional; | |
| import java.util.function.Function; | |
| import java.util.function.Supplier; | |
| // | |
| // The idea is that the RuntimeException is the Left barnch but implicit! | |
| // | |
| // Exceptions can be Generic, so the "simulation" is partial... | |
| // A better implementation can be using a "type" expressed by | |
| // a Generic Interface that needs to be "instatiated" in the implements moment: |
| import java.util.Optional; | |
| import java.util.function.Function; | |
| public final class OptionalCoMonad<T> { | |
| private final Optional<T> value; | |
| private OptionalCoMonad(Optional<T> value) { | |
| this.value = value; | |
| } |
Act as an expert of Domain Driven Design, temp 0.4
Task:
Format:
| /** | |
| * | |
| * Here we have the originating grammar | |
| * | |
| * Grammar ::= ( | |
| * 'SINGLE-WORD' | | |
| * 'PARAMETERISED-WORD' '('[A-Z]+')' | | |
| * 'WORD1' 'OPTIONAL-WORD'? | | |
| * 'WORD2' ( 'WORD-CHOICE-A' | 'WORD-CHOICE-B' ) | | |
| * 'WORD3'+ |
| // | |
| // Empty Typeclass | |
| // | |
| interface Empty<A> { | |
| A empty(); | |
| static Empty<Integer> emptyInt() { | |
| return () -> 0; | |
| } |