Profiling a new programming language

Top Page
Attachments:
Message as email
+ (text/plain)
+ macrotemplate.mcro (text/x-objcsrc)
+ signature.asc (application/pgp-signature)
+ (text/plain)
Delete this message
Reply to this message
Author: Ryan Rix
Date:  
To: Main PLUG discussion list
Subject: Profiling a new programming language
Hello list,

To stave off my boredom I've decided to take up creating a programming
language specifically for creating long repetitive text documents (like
repetitive resource definitions) where simple ctrl-c ctrl-v won't work, like
incrementing ID's, filenames within definitions, etc.

Basically, I have created, what I believe will be the sample script input file
(which I have attached) so that I have a goal to aim for.

What would be the best way to start by developing this tool? I have never done
any programming real down to the core, nothing with a lot of text parsing
before... How would I best attack creating an interpreter?
I plan on making it in C so that it is fairly portable sourcewise, unless I am
presented a better option of course :)

Thank you for your time,
Ryan

--
Thanks and best regards,
Ryan Rix
TamsPalm - The PalmOS Blog

Ditch MP3! Screw AAC! Banish WMA! OGG for life!



#!/usr/bin/macro
#First macro script.
# <-- comments :)

.define                 #this is where the macro definitions go, here
    1:file.variable         #Will represent a file in the cwd.
    >pattern "*.bmp"        #Not sure if this will be wildcard or regex...
    2:repeat            #These are for repetitive motions.
    >text "\t\t\t\"${1}\" \\"    #This is the text which will be repeated. Macros are expanded, see footnote 1.
    >opts:resetvars            #each time this is expanded, the macros in the text portion will be reset to their first expansion.
    3:repeat
    >text "ICON ${4}\nBEGIN\n\tBITMAP \"${1,noinc}\" BPP 16 DENSITY 2 TRANSPARENT 255 0 255\n\tBITMAP \"${1,stripext}_s\" BPP 16 TRANSPARENT 255 0 255\nEND" #See footnote 2 for info on options.
    4:variable            #These are any interger variable....
    >initval:10000            #This is the value assigned at script load, or when a repeat is called with resetvars option.
    >computation:${4}+10->${4}    #This is the computation made BEFORE the variable is expanded. Only other variables are expanded within
define.


#This is just a standard PalmOS resource definition in PilRC format.
# pilrc.sf.net for info on pilrc incl. docs, and see
# http://web.archive.org/web/20070816142916/www.estvo.com/developers/?specification for info on the skin specific format.
.text
VERSION "1.0"
    
// Author
STRING ID 100 "My Name"

// Text info
STRING ID 200 "My first iconpack"

// Creator mapping table
// 'addr - 'Address Book, icon resource ID - 10000, 10001
// 'calc' - Calculator, icon resource ID - 10010, 10011
// 'memo' - MemoPad, icon resource ID - 10020, 10021
HEX "crtb" ID 1000    "${1}" \
${2,1.NULL}


${3,1.NULL}
text.

#footnote 1: repeat texts
#basically, everytime a repeat is called, it will expand the macros. Everytime
#a file.variable macro is expanded it will get the next file found by find(1)
#and print it, with the options[2].

#footnote 2: options
#definitions can be passed various options either via the opts command in the
#definition, or from the source using the form ${def,option1,option2,option3,...}
# I have only defined a few options in this file: resetvars,noinc,stripext. resetvars
#is explained in comments, noinc says that the file should not be incremented
#(the index in the stored list returned by find(1)) or the variable's computation should
#not be called before expanding, or that the repeat should expand the last repeat that was
#done. For ease of use, this option would inherit to subsequent expansions. stripext tells
#file.variable that the file should be returned with the trailing . and all text after it to
# be dropped. "hello_world.bmp" become "hello_world".---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss