<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div>Hi all.<br></div><div><br></div><div>I am attempting to store the Wikimedia Lua Modules as Classes in my image. The idea being that when the Parser encounters a Module #invoke I can hand it off to the appropriate class and have it invoke Lua and return content to me.<br></div><div><br></div><div>I have extracted the Wikimedia Modules to a postgres table named 'modules'  and I am hitting that table and iterating over it to dynamically create the classes I need.<br></div><div>The code is a modified version of what I used to scrape the Squeak Wiki.<br></div><div><br></div><div><br></div><div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>scrapeModulesToNewClass<br></div><div>|rows |<br></div><div>      rows := ((WikitextParserConnectionPool default executeQuery: 'select page_id, page_title, old_text from modules limit 2') at:1) rows.<br></div><div><br></div><div>rows do: [:each | |pageid pagetitle oldtext lua  methodTemplatePageId methodTemplatePageTitle methodTemplateLua methodSourcePageId methodSourcePageTitle methodSourceLua newclassname|<br></div><div><br></div><div>pageid := each at:1.<br></div><div>pagetitle := each at:2.<br></div><div>oldtext := each at:3.<br></div><div>lua := oldtext .    "I have been attempting String shenanigans here in attempts to get this to work"<br></div><div>lua inspect.<br></div><div>methodTemplatePageId := 'pageId ^', $', '{1}' ,$'. <br></div><div>methodTemplatePageTitle := 'pageTitle ^', $', '{1}' ,$'. <br></div><div>methodTemplateLua := 'lua ^', $', '{1}' ,$'. <br></div><div>methodSourcePageId := methodTemplatePageId format:{pageid}.<br></div><div>methodSourcePageTitle := methodTemplatePageTitle format:{pagetitle}.<br></div><div>methodSourceLua := methodTemplateLua format:{lua}.<br></div><div><br></div><div>newclassname := ('WikitextModule', pageid asString) asSymbol.<br></div><div>WikitextParserModule subclass: newclassname<br></div><div>          instanceVariableNames: ''<br></div><div>          classVariableNames: ''<br></div><div>          poolDictionaries: ''<br></div><div>          category: 'WikitextParser-Modules'.<br></div><div><br></div><div>       (Smalltalk at: newclassname) compile: methodSourcePageId.<br></div><div>       (Smalltalk at: newclassname) compile: methodSourcePageTitle.<br></div><div>       (Smalltalk at: newclassname) compile: methodSourceLua.<br></div><div><br></div><div>       "Transcript show: newclassname; cr."<br></div><div>]<br></div></blockquote><div><br></div><div>Works fine until <br></div></div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>(Smalltalk at: newclassname) compile: methodSourceLua.<br></div></blockquote><meta content="text/html; charset=utf-8"><div><br></div><div>Here's why:<br></div><div><br></div><div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>lua ^'-- This module provides easy processing of arguments passed to Scribunto from<br></div><div>-- #invoke. It is intended for use by other Lua modules, and should not be<br></div><div>-- called from #invoke directly.<br></div><div><br></div><div>local libraryUtil = require('libraryUtil    <b>End of block expected -</b>><b>'</b>)<br></div><div>local checkType = libraryUtil.checkType<br></div><div><br></div><div>..........<br></div><div><br></div><div>end<br></div><div><br></div><div>return arguments'<br></div></blockquote><div><br></div></div><div>The Method compilation fails.</div><div><br></div><div>Should I even attempt to escape this thing? <br></div><div><br></div><div>Remember, I am going to have to do an OSProcess lua call to run this stuff.<br></div><div><br></div><div>I suppose I could just store the PGRow in the class, but that feels weird.<br></div><div><br></div><div>Thanks in advance.</div><div><br></div></div><br></body></html>