I was playing around with my parser generator and tried to come up with something other than a programming language.
I ended up trying to make a menu resource for making it easier to change the menus in MaxGUI.
It takes something like this:
And generates a file with this:
Does anyone find this sort of thing useful?
I ended up trying to make a menu resource for making it easier to change the menus in MaxGUI.
It takes something like this:
{
Import BRL.MaxGUI
}
MENU Edit {
"Cu&t" MENUCUT [CTRL+X] .
"&Copy" MENUCOPY [CTRL+C] .
"&Paste" MENUPASTE [CTRL+V] .
-
"Select &All" MENUSELECTALL [CTRL+A] .
}
MAINMENU main {
"&File" <file> {
"&New" MENUNEW [CTRL+N] .
"&Open" MENUOPEN [CTRL+O] .
"&Recent" <recentmenu> .
!"&Close" MENUCLOSE [CTRL+F4] .
-
!"&Save" MENUSAVE [CTRL+S] .
!"Save &As" MENUSAVEAS [SHIFT+CTRL+S] .
-
"E&xit" MENUEXIT .
}
@Edit "&Edit" <edit>
}
And generates a file with this:
SuperStrict Import BRL.MaxGUI Const MENUCUT:Int = 1 Const MENUCOPY:Int = 2 Const MENUPASTE:Int = 3 Const MENUSELECTALL:Int = 4 Const MENUNEW:Int = 5 Const MENUOPEN:Int = 6 Const MENUCLOSE:Int = 7 Const MENUSAVE:Int = 8 Const MENUSAVEAS:Int = 9 Const MENUEXIT:Int = 10 Function GetMenuActionName:String( id:int) Global names:String[] = [ "", .. "MENUCUT", "MENUCOPY", "MENUPASTE", "MENUSELECTALL", "MENUNEW", "MENUOPEN", .. "MENUCLOSE", "MENUSAVE", "MENUSAVEAS", "MENUEXIT" .. ] If (id >= 0) And (id < names.Length) Then Return names[id] Return "Unknown" EndFunction Type TMenus Field file:TGadget Field recentmenu:TGadget Field edit:TGadget Method CreateEditMenu:TGadget( parent:TGadget=Null, title:String=Null) If parent And title Then parent = CreateMenu( title, 0, parent) ElseIf Not parent Then parent = CreateMenu( title, 0, Null) EndIf CreateMenu( "Cu&t", MENUCUT, parent, KEY_X, MODIFIER_CONTROL) CreateMenu( "&Copy", MENUCOPY, parent, KEY_C, MODIFIER_CONTROL) CreateMenu( "&Paste", MENUPASTE, parent, KEY_V, MODIFIER_CONTROL) CreateMenu( "", 0, parent) CreateMenu( "Select &All", MENUSELECTALL, parent, KEY_A, MODIFIER_CONTROL) Return parent EndMethod Method CreateMainMenu( parent:TGadget) file = CreateMenu( "&File", 0, parent) CreateMenu( "&New", MENUNEW, file, KEY_N, MODIFIER_CONTROL) CreateMenu( "&Open", MENUOPEN, file, KEY_O, MODIFIER_CONTROL) recentmenu = CreateMenu( "&Recent", 0, file) DisableGadget CreateMenu( "&Close", MENUCLOSE, file, KEY_F4, MODIFIER_CONTROL) CreateMenu( "", 0, file) DisableGadget CreateMenu( "&Save", MENUSAVE, file, KEY_S, MODIFIER_CONTROL) DisableGadget CreateMenu( "Save &As", MENUSAVEAS, file, KEY_S, MODIFIER_SHIFT | MODIFIER_CONTROL) CreateMenu( "", 0, file) CreateMenu( "E&xit", MENUEXIT, file) edit = CreateEditMenu(parent, "&Edit") EndMethod EndType
Does anyone find this sort of thing useful?