#+title: Grammar with semantics #+subtitle: Random-art generation #+date: 2025H1 * Overview :PROPERTIES: :CUSTOM_ID: overview :END: - Augmented a standard context-free BNF grammar with production rule weights (probabilities) to control expression generation density and visual aesthetics. - Optimized and left-factorized the extended grammar to ensure compatibility with deterministic parsing methods. - Implemented a custom C-based lexer and recursive descent parser to process rules, terminals, nonterminals, and probabilities. - Engineered a stochastic expansion algorithm with depth thresholding to synthesize complex GLSL fragment shaders driven by screen coordinates, mouse input, and time. - Configured distinct semantic weight profiles to generate varying aesthetic styles (smooth vs. noise-heavy procedural patterns). - Developed a custom GNU Emacs major mode (=bnf-mode.el=) for editing BNF grammars. * Documentation :PROPERTIES: :CUSTOM_ID: documentation :END: The exported report can be found at [[https://git.michalec.dev/files/uni/term-06/math-logic/lab-05/report.pdf][this link]]. * Showcase :PROPERTIES: :CUSTOM_ID: showcase :END: ** Example 1 :PROPERTIES: :CUSTOM_ID: example-1 :UNNUMBERED: toc :END: *Input:* #+begin_src bnf ::= | 0 "-" | 10 | | 0 "abs(" ")" | "sqrt(abs(" "))" ::= | 2 |