### Minimal Client Example (Python) Source: https://github.com/webfirstlanguage/wfl/blob/main/wfl-lsp/examples/README.md Demonstrates how to start the WFL MCP server as a subprocess and send/receive JSON-RPC requests using Python. Includes sending a 'parse_wfl' tool call. ```python import subprocess import json # Start MCP server proc = subprocess.Popen( ['wfl-lsp', '--mcp'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True ) # Send request request = { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "parse_wfl", "arguments": { "source": "store x as 5" } } } proc.stdin.write(json.dumps(request) + '\n') proc.stdin.flush() # Read response response = json.loads(proc.stdout.readline()) print(response) ``` -------------------------------- ### Quick Start: Create and Run a WFL Program Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/02-getting-started/index.md This snippet shows how to create a simple 'Hello, World!' WFL file and execute it from the command line. It's a fast way to get a WFL program running. ```bash # Create a file called hello.wfl echo 'display "Hello, World!"' > hello.wfl # Run it wfl hello.wfl ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/webfirstlanguage/wfl/blob/main/vscode-extension/IMPLEMENTATION-NOTES.md Navigate to the extension directory and install necessary Node.js packages. ```bash cd vscode-extension npm install ``` -------------------------------- ### Create WFL Example File Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Use 'vi' to create new WFL files for basic syntax or stdlib examples in the specified directories. ```bash # For basic syntax examples vi TestPrograms/docs_examples/basic_syntax/loops_01.wfl # For stdlib examples vi TestPrograms/docs_examples/stdlib/text_functions.wfl ``` -------------------------------- ### Basic WFL Output Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/wfl-documentation-policy.md A simple 'Hello, world!' example to guide beginners through their first WFL program. This demonstrates the basic syntax for displaying output. ```WFL Say 'Hello, world!' ``` -------------------------------- ### Install Package Command Source: https://github.com/webfirstlanguage/wfl/blob/main/wflpkg_prd.md Use this command to install a package from the web portal. ```bash wflpkg add ``` -------------------------------- ### Use Setup for Common Initialization Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/guides/testing-guide.md Utilize the `setup` block within `describe` blocks to perform common initialization tasks required by multiple tests. This reduces code duplication. ```wfl describe "List operations": setup: store test_list as [1, 2, 3, 4, 5] end setup test "list has correct length": expect test_list to have length 5 end test test "list contains all values": expect test_list to contain 3 end test end describe ``` -------------------------------- ### Install WFL Core Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/README.md Download and run the latest MSI installer from GitHub Releases. The installer includes options for WFL Core, LSP Server, and VS Code Extension. ```bash # Download and run the latest MSI installer from GitHub Releases # The installer includes options for: # - WFL Core (required) # - LSP Server for editor integration (optional) # - VS Code Extension with syntax highlighting (optional) ``` -------------------------------- ### Start Web Server Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/web_server_example.wfl.lex.txt Initializes and starts the web server, binding it to a specified host and port. Displays connection information upon successful startup. ```WFL KeywordTry at line 58, column 1 (length: 3) Colon at line 58, column 4 (length: 1) KeywordDisplay at line 59, column 5 (length: 7) StringLiteral("πŸš€ Starting web server on ") at line 59, column 13 (length: 30) KeywordWith at line 59, column 44 (length: 4) Identifier("server_host") at line 59, column 49 (length: 11) KeywordWith at line 59, column 61 (length: 4) StringLiteral(":") at line 59, column 66 (length: 3) KeywordWith at line 59, column 70 (length: 4) Identifier("server_port") at line 59, column 75 (length: 11) KeywordListen at line 60, column 5 (length: 6) KeywordOn at line 60, column 12 (length: 2) KeywordPort at line 60, column 15 (length: 4) Identifier("server_port") at line 60, column 20 (length: 11) KeywordAs at line 60, column 32 (length: 2) Identifier("web_server") at line 60, column 35 (length: 10) KeywordDisplay at line 62, column 5 (length: 7) StringLiteral("βœ“ Web server started successfully!") at line 62, column 13 (length: 38) KeywordDisplay at line 63, column 5 (length: 7) StringLiteral("βœ“ Server is ready to accept connections") at line 63, column 13 (length: 43) KeywordDisplay at line 64, column 5 (length: 7) StringLiteral("βœ“ Visit http://") at line 64, column 13 (length: 19) KeywordWith at line 64, column 33 (length: 4) Identifier("server_host") at line 64, column 38 (length: 11) KeywordWith at line 64, column 50 (length: 4) StringLiteral(":") at line 64, column 55 (length: 3) KeywordWith at line 64, column 59 (length: 4) Identifier("server_port") at line 64, column 64 (length: 11) KeywordWith at line 64, column 76 (length: 4) StringLiteral(" in your browser") at line 64, column 81 (length: 18) KeywordDisplay at line 65, column 5 (length: 7) StringLiteral("") at line 65, column 13 (length: 2) ``` -------------------------------- ### Sequential Example Naming Convention Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Demonstrates the naming convention for sequential code examples, using a topic and a number. ```bash Use `_.wfl` for sequential examples: - `variables_01.wfl` - First variables example - `variables_02.wfl` - Second variables example - `control_flow_01.wfl` - First control flow example ``` -------------------------------- ### Minimal Configuration Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/reference/configuration-reference.md Example of a minimal .wflcfg file. It sets essential parameters like timeout and log level, relying on defaults for other settings. ```ini # .wflcfg - Minimal settings (uses defaults for everything else) timeout_seconds = 120 log_level = info ``` -------------------------------- ### Module Organization Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/04-advanced-features/modules.md An example directory structure showing how to organize related functionality into modules. ```text project/ main.wfl database/ connection.wfl queries.wfl api/ handlers.wfl routes.wfl utils/ logging.wfl validation.wfl ``` -------------------------------- ### Install WFL (Windows) Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/README.md Download the MSI installer from the GitHub releases page for Windows installation. ```bash # Download MSI from GitHub releases (Windows) # Or: cargo build --release ``` -------------------------------- ### Directory Structure Example Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Illustrates the organization of code examples within the WFL documentation directory. ```bash docs_examples/ β”œβ”€β”€ README.md # This file β”œβ”€β”€ basic_syntax/ # Variables, control flow, functions β”œβ”€β”€ stdlib/ # Standard library demonstrations β”œβ”€β”€ web_features/ # Async, web servers, HTTP β”œβ”€β”€ error_examples/ # Intentional errors for documentation └── _meta/ # Validation metadata β”œβ”€β”€ manifest.json # Registry of all examples β”œβ”€β”€ expected_errors.json # Expected error patterns └── validation_cache.json # Validation results cache ``` -------------------------------- ### Task Manager Example with Containers and OOP Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/04-advanced-features/containers-oop.md A comprehensive example showcasing the creation of a Task container and a TaskList container, demonstrating object instantiation, method calls, and list manipulation. ```wfl create container Task: property description: Text property completed: Boolean property priority: Number action mark_complete: store completed as yes display "βœ“ Completed: " with description end action set_priority needs level: Number: store priority as level end action to_string: Text store status as "☐" check if completed is yes: change status to "βœ“" end check return status with " " with description with " (P" with priority with ")" end end create container TaskList: property tasks: List action add_task needs task: Task: push with tasks and task end action show_all: display "=== Task List ===" for each task in tasks: store task_str as task.to_string() display task_str end for end action complete_first: check if length of tasks is greater than 0: store first_task as tasks[0] first_task.mark_complete() end check end end // Usage create new Task as task1: description is "Learn WFL" completed is no priority is 1 end create new Task as task2: description is "Build web server" completed is no priority is 2 end create new TaskList as my_tasks: tasks is [] end my_tasks.add_task(task1) my_tasks.add_task(task2) my_tasks.show_all() my_tasks.complete_first() display "" my_tasks.show_all() ``` -------------------------------- ### WFL Time Module Complete Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/05-standard-library/time-module.md Demonstrates various functionalities of the WFL time module including getting current time, creating dates, performing date math, and calculating time differences. ```wfl display "=== Time Module Demo ===" display "" // Current time display "Right now:" display " Date: " with today display " Time: " with now display " DateTime: " with datetime_now display " Timestamp: " with current time in milliseconds display "" // Date creation store birthday as create_date of 1995 and 3 and 15 display "Birthday: " with birthday store components as "Components:" display " Year: " with year of birthday display " Month: " with month of birthday display " Day: " with day of birthday display "" // Date math store today_date as today store next_week as add_days of today_date and 7 store last_month as subtract_days of today_date and 30 display "Dates:" display " Today: " with today_date display " Next week: " with next_week display " Last month: " with last_month display "" // Time calculations store start_date as create_date of 2026 and 1 and 1 store end_date as create_date of 2026 and 12 and 31 store days_in_year as days_between of start_date and end_date display "Days in 2026: " with days_in_year display "" display "=== Demo Complete ===" ``` -------------------------------- ### Basic Configuration File Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/reference/configuration-reference.md Illustrates the fundamental key-value format with comments for WFL configuration files. ```ini # This is a comment timeout_seconds = 60 logging_enabled = true log_level = debug ``` -------------------------------- ### WFL Math Module Complete Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/05-standard-library/math-module.md Demonstrates the use of absolute value, rounding, and clamping functions. Includes a practical example of a temperature converter. ```wfl display "=== Math Module Demo ===" display "" // Absolute value store negative as -42 store positive as abs of negative display "Absolute value of -42: " with positive // Rounding store pi as 3.14159 display "Round: " with round of pi // 3 display "Floor: " with floor of pi // 3 display "Ceil: " with ceil of pi // 4 // More rounding examples store values as [2.1, 2.5, 2.9, -1.5] for each value in values: display value with " β†’ round: " with round of value with ", floor: " with floor of value with ", ceil: " with ceil of value end for display "" // Clamping store test_values as [-10, 0, 5, 10, 15, 20] for each test in test_values: store clamped as clamp of test between 0 and 10 display test with " clamped to [0,10]: " with clamped end for display "" // Practical example: Temperature converter with rounding store celsius as 23.7 store fahrenheit as celsius times 9 divided by 5 plus 32 store rounded_f as round of fahrenheit display celsius with "Β°C = " with fahrenheit with "Β°F (raw)" display celsius with "Β°C β‰ˆ " with rounded_f with "Β°F (rounded)" display "" display "=== Demo Complete ===" ``` -------------------------------- ### Complete WFL Test Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/guides/testing-guide.md Demonstrates a full test suite for a shopping cart, including setup, multiple test cases, and teardown. Ensure all describe and test blocks are properly closed. ```wfl describe "Shopping Cart": setup: display "Setting up test cart..." store cart_items as [] end setup test "starts empty": expect cart_items to be empty expect cart_items to have length 0 end test test "can add items": add "apple" to cart_items add "banana" to cart_items expect cart_items to have length 2 expect cart_items to contain "apple" end test test "total price calculation": store price as 10 plus 20 plus 30 expect price to equal 60 expect price to be greater than 50 end test teardown: display "Cleaning up test cart..." end teardown end describe ``` -------------------------------- ### Start a Web Server in WFL Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/01-introduction/first-look.md Use the built-in 'listen on port' command to start a web server. Handle incoming requests by checking the path and responding accordingly. ```wfl // Start a web server listen on port 8080 as web server display "Server running at http://127.0.0.1:8080" // Handle requests wait for request comes in on web server as req check if path is equal to "/": respond to req with "Welcome to WFL!" check if path is equal to "/about": respond to req with "WFL - Programming in Plain English" otherwise: respond to req with "Page not found" and status 404 end check ``` -------------------------------- ### Execute WFL Example Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Run a WFL example file to test its execution and observe its behavior. This is often the final step in troubleshooting. ```bash wfl example.wfl ``` -------------------------------- ### Accessibility for Beginners Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/wfl-foundation.md Provides an example of WFL's beginner-friendly syntax for variable declaration, 'Let name be 'Alice'', which is more intuitive than traditional JavaScript's 'var name = 'Alice';'. ```WFL Let name be 'Alice' ``` ```JavaScript var name = 'Alice'; ``` -------------------------------- ### WFL Style Configuration Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/06-best-practices/project-organization.md Example of a .wflcfg file for setting project-wide style preferences like line length and indentation. ```ini # .wflcfg max_line_length = 100 max_nesting_depth = 5 indent_size = 4 ``` -------------------------------- ### Register Example in Manifest Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Add an entry to '_meta/manifest.json' to register a new WFL example, specifying its documentation section, type, validation layers, tags, and purpose. ```json { "basic_syntax/loops_01.wfl": { "doc_section": "Docs/03-language-basics/loops-and-iteration.md#count-loop", "type": "executable", "validate_layers": [1, 2, 3, 4, 5], "tags": ["beginner", "loops", "count"], "doc_purpose": "Demonstrates basic count loop syntax" } } ``` -------------------------------- ### WFL Setup and Teardown Blocks Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/guides/testing-guide.md Use 'setup' and 'teardown' blocks to prepare test environments and clean up resources once per 'describe' block. ```wfl describe "Database operations": setup: display "Connecting to test database..." store test_data as [1, 2, 3, 4, 5] end setup test "can read data": expect test_data to have length 5 end test test "can process data": store sum as 0 for each item in test_data: change sum to sum plus item end for expect sum to equal 15 end test teardown: display "Cleaning up test database..." end teardown end describe ``` -------------------------------- ### REPL Session Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/02-getting-started/repl-guide.md Demonstrates defining and calling an action within the WFL REPL. ```wfl > define action called calculate area with parameters width and height: ... return width times height ... end action > calculate area with 10 and 20 200 > // Works! Let me save this to a file. ``` -------------------------------- ### Development Configuration Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/reference/configuration-reference.md Example of a .wflcfg file for development environments. It includes settings for relaxed code style, shell execution, and local web server configuration. ```ini # .wflcfg - Development settings timeout_seconds = 300 logging_enabled = true log_level = debug debug_report_enabled = true # Relaxed code style for development max_line_length = 120 snake_case_variables = false # Allow shell commands for development allow_shell_execution = true shell_execution_mode = sanitized warn_on_shell_execution = true # Local web server accessible from network web_server_bind_address = 0.0.0.0 ``` -------------------------------- ### Start Web Server Listener in WFL Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/reference/syntax-reference.md Set up a web server to listen on a specified port. ```wfl // Web Server listen on port 8080 as server ``` -------------------------------- ### Expected Fail Prefix Example Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Details the `_expected_fail_` prefix for examples that are intended to produce specific errors and require manifest configuration. ```bash For examples that should produce specific errors: - `_expected_fail_type_error.wfl` - Must specify `expected_failure_layer` and `expected_error_pattern` in manifest ``` -------------------------------- ### WFL Shopping List Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/03-language-basics/lists-and-collections.md A practical example of creating and displaying a shopping list. It demonstrates adding items to a list and iterating through it to display each item with a number. ```wfl create list shopping list: add "milk" add "eggs" add "bread" add "butter" end list display "=== Shopping List ===" store item number as 1 for each item in shopping list: display item number with ". " with item change item number to item number plus 1 end for store total items as length of shopping list display "" display "Total items: " with total items ``` -------------------------------- ### Module Path Resolution Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/04-advanced-features/modules.md Illustrates how module paths are resolved relative to the including file's directory. This example shows loading modules from subdirectories and parent directories. ```wfl load module from "utils/helpers.wfl" load module from "config/settings.wfl" ``` ```wfl # From helpers.wfl, load sibling file load module from "math.wfl" # Load from parent directory load module from "../config/settings.wfl" ``` -------------------------------- ### Loop Start Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/keywords-technical-reference.md Shows the `from` keyword used in `count` loops to specify the starting value of the loop counter. ```WFL count from 1 to 10: ``` -------------------------------- ### WFL Package Manifest Example Source: https://github.com/webfirstlanguage/wfl/blob/main/wflpkg/wflpkgdesign.md This is an example of a project.wfl file, showcasing the declaration of package name, version, description, author, license, entry point, and dependencies. ```wfl // project.wfl - Package manifest for a web application name is greeting version is 26.2.1 description is A web application that greets visitors author is Alice Smith license is MIT entry is src/main.wfl requires http-client 26.1 or newer requires json-parser 25.12 or newer requires text-utils any version requires test-runner 26.1 or newer for development ``` -------------------------------- ### WFL Error Message Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/wfl-documentation-policy.md Provides an example of a clear and actionable error message in WFL, guiding developers on how to resolve type mismatches. ```WFL Expected a number but found textβ€”try converting it first ``` -------------------------------- ### Complete Database Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/04-advanced-features/databases.md Demonstrates opening a SQLite database, creating a table, inserting data, querying, updating, and closing the connection. ```wfl open database at "sqlite://todo.db" as db store created as execute db with "CREATE TABLE IF NOT EXISTS tasks (id INTEGER PRIMARY KEY, title TEXT, done BOOLEAN)" store added as execute db with "INSERT INTO tasks (title, done) VALUES (?, ?)" and parameters ["Write docs" and no] display "Created task #" with added["last_insert_id"] store open_tasks as query db with "SELECT id, title FROM tasks WHERE done = ?" and parameters [no] store task_count as length of open_tasks display task_count with " open task(s)" for each task in open_tasks: display "- [" with task["id"] with "] " with task["title"] end for store finished as execute db with "UPDATE tasks SET done = ? WHERE title = ?" and parameters [yes and "Write docs"] display "Completed " with finished["affected_rows"] with " task(s)" close database db ``` -------------------------------- ### If Conditional Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/keywords-technical-reference.md Introduces the `if` keyword, which is an alternative to `check` for starting conditional statements. It evaluates a condition and executes code if the condition is true. ```WFL check if x is 5: ``` -------------------------------- ### Personal Information Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/03-language-basics/variables-and-types.md A comprehensive example demonstrating the declaration and display of various data types including strings, numbers, booleans, and floating-point values. ```wfl store first name as "Alice" store last name as "Johnson" store age as 28 store is employed as yes store salary as 75000.00 display "Name: " with first name with " " with last name display "Age: " with age display "Employed: " with is employed display "Salary: $" with salary ``` -------------------------------- ### Secure WFL Configuration Example Source: https://github.com/webfirstlanguage/wfl/blob/main/SECURITY.md This example shows a secure configuration file for WFL, highlighting settings for timeouts, logging, debugging, and recursion depth. Ensure these settings are appropriate for your production environment. ```ini # Example secure .wflcfg timeout_seconds = 30 # Reasonable timeout logging_enabled = true # Enable for audit trails debug_report_enabled = false # Disable in production-like environments max_nesting_depth = 5 # Prevent deep recursion attacks ``` -------------------------------- ### Filtering a List with a Loop in WFL Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/03-language-basics/loops-and-iteration.md Filter elements from one list into another based on a condition. This example filters items starting with 'a'. ```wfl create list all items: add "apple" add "apricot" add "banana" add "avocado" end list create list a items end list for each item in all items: store first letter as substring of item from 0 length 1 check if first letter is "a": push with a items and item end check end for display "Items starting with 'a':" for each item in a items: display " - " with item end for ``` -------------------------------- ### Create a 3-Line Web Server Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/04-advanced-features/index.md This snippet demonstrates how to create a basic web server that listens on a specified port and responds to requests with a simple message. It requires minimal setup. ```wfl listen on port 8080 as server wait for request comes in on server as req respond to req with "Hello, Web!" ``` -------------------------------- ### WFL Word Counter Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/03-language-basics/lists-and-collections.md Counts the number of words in a sentence by splitting the sentence into a list of words using a delimiter and then getting the length of the resulting list. ```wfl store sentence as "the quick brown fox jumps over the lazy dog" store words as split of sentence by " " store word count as length of words display "Word count: " with word count display "Words:" for each word in words: display " - " with word end for ``` -------------------------------- ### Express.js Web Server Setup Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/01-introduction/why-wfl.md This JavaScript code uses the Express.js framework to set up a basic web server. It requires installing dependencies and configuring routes. ```javascript const express = require('express'); // Install dependency const app = express(); // Setup app.get('/', (req, res) => { res.send('Hello, Web!'); }); app.listen(8080); // Start server ``` -------------------------------- ### Define Block Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/keywords-technical-reference.md Shows the `define` keyword used to start the declaration of structural elements like actions or containers. It is typically followed by the type of element being defined. ```WFL define action called test: ``` -------------------------------- ### Install WFL from Source Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/README.md Clone the WFL repository, build the project using Cargo, and optionally add the release binary to your PATH. ```bash # Clone the repository git clone https://github.com/WebFirstLanguage/wfl.git cd wfl # Build the project cargo build --release # Add to PATH (optional) export PATH="$PATH:$(pwd)/target/release" ``` -------------------------------- ### Complete Pattern Module Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/05-standard-library/pattern-module.md A comprehensive example showcasing pattern creation for email and phone numbers, testing matches, finding patterns within text, and extracting all occurrences of a pattern. This covers various use cases of the pattern module. ```wfl display "=== Pattern Module Demo ===" display "" // Create patterns create pattern email: one or more letter or digit followed by "@" followed by one or more letter or digit followed by "." followed by 2 to 4 letter end pattern create pattern phone: exactly 3 digit followed by "-" followed by exactly 3 digit followed by "-" followed by exactly 4 digit end pattern create pattern word: one or more letter end pattern // Test matching store email_addr as "user@example.com" check if email_addr matches email: display "βœ“ Valid email: " with email_addr end check store phone_num as "555-123-4567" check if phone_num matches phone: display "βœ“ Valid phone: " with phone_num end check display "" // Find pattern in text store contact_info as "Email: user@example.com, Phone: 555-123-4567" store email_match as find email in contact_info check if isnothing of email_match: display "No email found" otherwise: display "Found email: " with email_match.matched_text end check store phone_match as find phone in contact_info check if isnothing of phone_match: display "No phone found" otherwise: display "Found phone: " with phone_match.matched_text end check display "" // Find all matches store sentence as "The quick brown fox jumps over the lazy dog" store word_matches as find all word in sentence display "Words found: " with length of word_matches for each word_match in word_matches: display " - " with word_match.matched_text end for display "" display "=== Demo Complete ===" ``` -------------------------------- ### WFL Web Server Implementation Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/01-introduction/what-is-wfl.md Provides a basic example of setting up a web server in WFL, listening on a port and responding to incoming requests. ```wfl listen on port 8080 as server wait for request comes in on server as req respond to req with "Hello from WFL!" ``` -------------------------------- ### Try Block Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/keywords-technical-reference.md Shows the `try` keyword used to start a block of code that may potentially throw an error. This block is followed by `catch` or `when` clauses for error handling. ```WFL try: ``` -------------------------------- ### WFL Configuration Example Source: https://github.com/webfirstlanguage/wfl/blob/main/wflhub_language_gaps_prd.md Illustrates how to define project-specific configurations using a .wflcfg file. These settings are respected by new features. ```text database_url is "postgres://..." jwt_secret is "..." smtp_host is "..." smtp_port is 587 session_timeout is 1800000 rate_limit_default is 60 template_dir is "templates/" ``` -------------------------------- ### WFL Self-Documenting Code Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/03-language-basics/comments-and-documentation.md WFL's natural language syntax allows code to explain itself, reducing the need for traditional comments. This example demonstrates calculating a total price with discount and tax. ```wfl store subtotal as item price times quantity store discounted as subtotal times 1 minus discount rate store tax as discounted times tax rate store total as discounted plus tax ``` -------------------------------- ### Minimal Client Example (Node.js) Source: https://github.com/webfirstlanguage/wfl/blob/main/wfl-lsp/examples/README.md Demonstrates how to spawn the WFL MCP server as a child process and handle JSON-RPC communication using Node.js. Includes sending a 'parse_wfl' tool call. ```javascript const { spawn } = require('child_process'); const server = spawn('wfl-lsp', ['--mcp']); // Send request const request = { jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'parse_wfl', arguments: { source: 'store x as 5' } } }; server.stdin.write(JSON.stringify(request) + '\n'); // Read response server.stdout.on('data', (data) => { const response = JSON.parse(data.toString()); console.log(response); }); ``` -------------------------------- ### Verify WFL Installation Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/02-getting-started/installation.md Run these commands after installation to verify that WFL is correctly installed and accessible from your terminal. ```bash wfl --version wfl test.wfl ``` -------------------------------- ### Create a WFL 'Hello World' Program Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/02-getting-started/installation.md Create a simple WFL file to test the language's basic functionality. ```wfl display "WFL is installed and working!" ``` -------------------------------- ### Install Rust Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/development/building-from-source.md Installs Rust using the official script and verifies the installation. Ensure you have Rust 1.75 or later. ```bash # Visit https://rustup.rs/ or run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Verify installation rustc --version cargo --version ``` -------------------------------- ### Execute NPM Commands Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/04-advanced-features/interoperability.md Shows how to execute common NPM commands sequentially: install, build, and test. Useful for managing project dependencies and build processes. ```wfl display "Installing dependencies..." wait for execute command "npm install" display "Running build..." wait for execute command "npm run build" display "Running tests..." wait for execute command "npm test" ``` -------------------------------- ### Initialize WFL Configuration with CLI Source: https://github.com/webfirstlanguage/wfl/blob/main/AGENTS.md Create a `.wflcfg` configuration file interactively. Defaults to the current directory if no directory is specified. ```bash wfl --init [dir] ``` -------------------------------- ### Validate WFL Examples with Python Script Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Use the Python script to validate WFL examples. Options include validating a single file, an entire category, all examples, or running in CI mode. ```bash # Validate single file python scripts/validate_docs_examples.py --file TestPrograms/docs_examples/basic_syntax/loops_01.wfl # Validate entire category python scripts/validate_docs_examples.py --category basic_syntax # Validate all examples python scripts/validate_docs_examples.py ``` ```bash # Validate all examples python scripts/validate_docs_examples.py # Validate specific category python scripts/validate_docs_examples.py --category basic_syntax # Validate single file python scripts/validate_docs_examples.py --file path/to/example.wfl # CI mode (strict, no prompts) python scripts/validate_docs_examples.py --ci # Update manifest after validation python scripts/validate_docs_examples.py --update-manifest # Detailed report python scripts/validate_docs_examples.py --report --verbose ``` -------------------------------- ### Start Simple HTTP Server Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/guides/cookbook.md Creates a basic HTTP server that listens on a specified port and responds to all requests with a simple text message. Ensure the port is available before running. ```wfl listen on port 8080 as server wait for request comes in on server as req respond to req with "Hello!" ``` -------------------------------- ### Build Custom MSI Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/README.md Build a custom MSI installer with specific components. Options include interactive selection, including all components, or core only. ```bash # Interactive component selection python Tools/launch_msi_build.py --interactive ``` ```bash # Include all components python Tools/launch_msi_build.py --include-lsp --include-vscode ``` ```bash # Core only (default) python Tools/launch_msi_build.py ``` -------------------------------- ### Validate Documentation Examples Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/development/contributing-guide.md Command to validate WFL code examples used in documentation. ```bash python scripts/validate_docs_examples.py --file path/to/example.wfl ``` -------------------------------- ### List Module Demonstration Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/05-standard-library/list-module.md A comprehensive example showcasing various list operations including creation, adding elements with `push`, checking membership with `contains`, finding positions with `indexof`, and removing elements with `pop`. ```wfl display "=== List Module Demo ===" display "" // Create a list create list tasks: add "Write code" add "Test code" add "Deploy code" end list display "Initial tasks: " with tasks display "Count: " with length of tasks display "" // Add item push with tasks and "Document code" display "After push: " with tasks display "New count: " with length of tasks display "" // Check membership check if contains of tasks and "Test code": display "Testing is in the list" end check display "" // Find position store test_index as indexof of tasks and "Test code" display "Test code is at index: " with test_index display "" // Remove item store removed as pop from tasks display "Removed: " with removed display "After pop: " with tasks display "Final count: " with length of tasks display "" display "=== Demo Complete ===" ``` -------------------------------- ### Conventional Commit Message Examples Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/development/contributing-guide.md Examples of conventional commit messages for various types of changes. ```bash feat: Add new feature fix: Fix bug docs: Update documentation test: Add tests refactor: Refactor code perf: Performance improvement chore: Maintenance ``` ```bash feat: Add wflhash512 function Implements 512-bit variant of WFLHASH. Includes comprehensive tests and documentation. Closes #123 ``` -------------------------------- ### Install VS Code Extension (Windows) Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/02-getting-started/editor-setup.md Run this PowerShell script to install the VS Code extension on Windows. ```powershell # Windows PowerShell .\scripts\install_vscode_extension.ps1 ``` -------------------------------- ### Error Example Naming Convention Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Illustrates the naming convention for intentional error examples, using an error type. ```bash Use `_error.wfl` for intentional errors: - `type_mismatch_error.wfl` - `undefined_variable_error.wfl` - `runtime_error.wfl` ``` -------------------------------- ### Standalone Example Naming Convention Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Shows the naming convention for standalone code examples, using a feature name. ```bash Use `_example.wfl` for standalone demonstrations: - `email_validation_example.wfl` - `simple_server_example.wfl` - `file_operations_example.wfl` ``` -------------------------------- ### Module Loading Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/keywords-technical-reference.md Demonstrates the `load` keyword used to import and make available the functionality of a module within the current scope. ```WFL load module math ``` -------------------------------- ### Initialize Configuration (PowerShell) Source: https://github.com/webfirstlanguage/wfl/blob/main/scripts/README.md An interactive script to create `.wflcfg` configuration files. ```powershell .\scripts\init_config.ps1 ``` -------------------------------- ### Simple Web Server in WFL Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/guides/wfl-by-example.md Sets up a basic web server that listens on a specified port and responds to HTTP requests. It handles different paths, returning specific content or a 404 error. ```wfl listen on port 8080 as server display "Server at http://127.0.0.1:8080" wait for request comes in on server as req check if path is equal to "/": respond to req with "Hello from WFL!" otherwise: respond to req with "Not found" and status 404 end check ``` -------------------------------- ### Poor Commit Message Examples Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/06-best-practices/collaboration-guide.md Examples of commit messages that lack clarity and do not follow conventional commit standards. ```text update stuff fix changes ``` -------------------------------- ### Create directory and parent directories Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/05-standard-library/filesystem-module.md Creates a directory and any necessary parent directories, similar to `mkdir -p`. Ensures the full directory structure exists. ```wfl makedirs "output/reports/2026" display "Directory structure created" // Creates: // output/ // output/reports/ // output/reports/2026/ ``` ```wfl create directory at "output/reports/2026" display "Directory structure created" ``` -------------------------------- ### Poor Action Names (Examples) Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/03-language-basics/actions-functions.md Shows examples of cryptic or vague action names that do not clearly convey their functionality. ```wfl // Poor names: calc // Too cryptic process // Too vague do stuff // Meaningless temp // What does it do? ``` -------------------------------- ### Descriptive Action Names (Good Examples) Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/03-language-basics/actions-functions.md Provides examples of clear and descriptive action names that indicate their purpose. ```wfl // Good names: calculate total price validate email address format as currency is eligible for discount generate invoice send confirmation email ``` -------------------------------- ### Verify WFL Installation Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/02-getting-started/installation.md Run this command in a new command prompt or PowerShell window to confirm WFL is installed and accessible. ```powershell wfl --version ``` -------------------------------- ### Install VS Code Extension (Linux/macOS) Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/02-getting-started/editor-setup.md Run this shell script to install the VS Code extension on Linux or macOS. ```bash # Linux/macOS ./scripts/install_vscode_extension.sh ``` -------------------------------- ### Parse WFL Example Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Check the syntax of a WFL example file. This command helps identify basic parsing errors. ```bash wfl --parse example.wfl ``` -------------------------------- ### Initialize WFL Configuration Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/reference/configuration-reference.md Use the `--init` flag to interactively create a `.wflcfg` file. This wizard guides you through setting configuration options, validates input, and generates a commented file. ```bash wfl --init # Create in current directory ``` ```bash wfl --init /path/to/dir # Create in specific directory ``` -------------------------------- ### Validate WFL Documentation Examples Source: https://github.com/webfirstlanguage/wfl/blob/main/AGENTS.md Use this Python script to validate the code examples embedded within the WFL documentation. ```python python scripts/validate_docs_examples.py ``` -------------------------------- ### List Building in REPL Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/02-getting-started/repl-guide.md Illustrates creating and populating a list using the WFL REPL. Practice list manipulation and observe its contents. ```wfl > create list items > end list > push with items and "first" > push with items and "second" > push with items and "third" > items ``` -------------------------------- ### Basic HTTP GET Request in WFL Source: https://github.com/webfirstlanguage/wfl/blob/main/Dev diary/2026-07-03-http-client-and-standard-crypto-issue-558.md These are the existing forms for GET requests that continue to work unchanged and parse to `HttpGetStatement`. ```wfl open url at "https://example.com" and read content as response ``` ```wfl open url at "https://example.com" as response ``` -------------------------------- ### Example WFL AI Integration Workflows Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/README.md Illustrative prompts for interacting with WFL code using AI assistants via MCP. ```bash # Ask Claude to analyze your code > "Find all errors in my WFL project" # Get help understanding code > "What does this WFL program do?" # Get coding assistance > "Help me write a function that processes a list" ``` -------------------------------- ### Listen with HTTPS using Certificate and Key Paths Source: https://github.com/webfirstlanguage/wfl/blob/main/Dev diary/2026-07-04-https-tls-web-server.md Use this to configure the web server for HTTPS, specifying the certificate and key file paths directly in the code. Ensure the specified .pem files exist and are valid. ```wfl // HTTPS, paths in the code listen on port 8443 secured with certificate "cert.pem" and key "key.pem" as secure_server ``` -------------------------------- ### Analyze WFL Example Semantics Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Perform semantic analysis on a WFL example to catch logical errors. This is a crucial step before execution. ```bash wfl --analyze example.wfl ``` -------------------------------- ### Development Setup for WFL LSP Source: https://github.com/webfirstlanguage/wfl/blob/main/wfl-lsp/README.md Clone the WFL repository and build the WFL LSP package to set up your development environment. ```bash git clone https://github.com/WebFirstLanguage/wfl.git cd wfl cargo build --package wfl-lsp ``` -------------------------------- ### Interactive Prefix Example Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Describes the `_interactive_` prefix for examples requiring user input or manual testing, which are skipped in automated validation. ```bash For examples that require user interaction: - `_interactive_user_input.wfl` - `_interactive_web_server.wfl` - Manual testing required - **Execution skipped** in automated validation ``` -------------------------------- ### Loading Modules from Packages (Future) Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/04-advanced-features/modules.md Demonstrates how to load modules using a package system, specifying modules by package name. ```wfl load module from "package:http-client" load module from "package:json-parser" ``` -------------------------------- ### WFL Documentation Example Validation Source: https://github.com/webfirstlanguage/wfl/blob/main/AGENTS.md Validate all code examples using MCP tools and the provided Python script before adding them to the documentation. ```bash python scripts/validate_docs_examples.py ``` ```bash mcp__wfl-lsp__parse_wfl ``` ```bash mcp__wfl-lsp__analyze_wfl ``` ```bash mcp__wfl-lsp__typecheck_wfl ``` ```bash mcp__wfl-lsp__lint_wfl ``` -------------------------------- ### Get File Size Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/04-advanced-features/file-io.md Retrieve the size of a file in bytes. Ensure the file path is correct to get accurate size information. ```wfl store size as file size at "data.txt" display "File size: " with size with " bytes" ``` -------------------------------- ### Simple MCP Client (Rust) Source: https://github.com/webfirstlanguage/wfl/blob/main/wfl-lsp/examples/README.md Example Rust program demonstrating programmatic MCP client implementation. It shows how to spawn wfl-lsp in MCP mode, handle JSON-RPC, and use tools and resources. ```bash cd wfl-lsp cargo run --example simple_mcp_client ``` -------------------------------- ### Validate WFL Examples with Cross-Platform Wrappers Source: https://github.com/webfirstlanguage/wfl/blob/main/TestPrograms/docs_examples/README.md Execute WFL example validation using platform-specific scripts for Windows (.ps1) and Linux/macOS (.sh). ```bash # Windows .\scripts\validate_docs_examples.ps1 # Linux/macOS ./scripts/validate_docs_examples.sh ``` -------------------------------- ### Create and Use a Container (Class) Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/04-advanced-features/index.md This example demonstrates object-oriented programming by defining a 'Person' container with properties and an action. It then creates an instance of 'Person' and calls its action. This allows for code organization and reusability. ```wfl create container Person: property name as text property age as number action introduce: display "I'm " with name end action end container create new Person as alice with property name as "Alice" and property age as 28 call alice introduce ``` -------------------------------- ### Python Script for Validating Documentation Examples Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/Archive/DOCUMENTATION_COMPLETE.md This Python script is used to validate documentation examples. It is a substantial script with over 500 lines of code. ```python validate_docs_examples.py (500+ lines) ``` -------------------------------- ### WFL Beginner-Friendly Syntax: Hello World Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/01-introduction/natural-language-philosophy.md Illustrates the simplicity of WFL for beginners with a 'Hello, World!' program. It also shows basic variable assignment and conditional statements. ```wfl // First program (anyone can understand): display "Hello, World!" // Variables (natural): store name as "Alice" // Conditionals (readable): check if age is greater than 18: display "Adult" end check // No intimidating syntax to memorize ``` -------------------------------- ### Good Naming Example in WFL Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/06-best-practices/naming-conventions.md Demonstrates clear, self-documenting code using recommended naming conventions for variables, actions, and function calls. ```wfl // Clear, self-documenting code store customer_first_name as "Alice" store customer_last_name as "Johnson" store customer_age as 28 store is_premium_member as yes define action called calculate_loyalty_discount with parameters purchase_amount: check if is_premium_member is yes: return purchase_amount times 0.9 // 10% discount otherwise: return purchase_amount end check end action store discounted_total as calculate_loyalty_discount with 100.00 display "Total after discount: $" with discounted_total ``` -------------------------------- ### Start WFL Web Server and Handle Requests Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/01-introduction/key-features.md Use this to create a basic HTTP server. It listens on a specified port and handles requests based on the URL path, responding with different content or status codes. ```wfl // Start a server on port 8080 listen on port 8080 as web server display "Server running at http://127.0.0.1:8080" // Handle incoming requests wait for request comes in on web server as req check if path is equal to "/": respond to req with "Hello from WFL Web Server!" check if path is equal to "/about": respond to req with "WFL - Programming in Plain English" and content type "text/plain" otherwise: respond to req with "Page not found" and status 404 end check ``` -------------------------------- ### Good Commit Message Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/06-best-practices/collaboration-guide.md An example of a well-structured commit message following conventional commit standards, including a detailed description and issue tracking. ```text feat: Add email validation pattern Adds natural language email pattern with comprehensive tests. Includes examples in documentation. Closes #123 ``` -------------------------------- ### WFL Syntax Error Example Source: https://github.com/webfirstlanguage/wfl/blob/main/Docs/02-getting-started/hello-world.md Provides an example of a common syntax error (missing quote) and mentions that WFL provides helpful error messages. ```wfl display Hello, World!" ``` -------------------------------- ### Launch MSI Build with Default Options Source: https://github.com/webfirstlanguage/wfl/blob/main/Tools/README.md Launches an MSI build using the default version. This is the basic command to start the build process. ```bash python launch_msi_build.py ```