ScriptEdit Language Reference Manual Bhavesh Patira bp2214 columbia edu Bethany M Soule bms2126 columbia edu Deni Pejanovic dp2232 columbia edu MarC Vinyes mv2258 columbia edu May 8 2007 2 Chapter 1 Introduction 1 1 Description ScriptEdit is a language that allows you to automatically generate text from a limited set of instructions You can write new files with this text or insert it into an existing file The instructions may use the text of the edited file external files or text generated by other standard input output based applications as input ScriptEdit is similar to a macro processor in the sense that it replaces text with other text but it can also create new files from a single source Motivations and Goals The main goal of this language is to allow the user to edit files and the script operations that are needed to create their content all from within one single source file Often editing content text files HTML LATEX XML etc is a process that involves several different steps and programs like separate bash scripts a text editor and other console programs e g using ImageMagick to edit images or using Matlab to create graphs that will be linked ScriptEdit is a way to put all those different process calls together with the content text file Some advantages of scripting operations within the source content file Visualization Contents and related scripts are written in the same area so it s easy to check that they are coherent using standard editors Inline execution of associated scripts If a long set of programs have to be executed each time normally a shell script grouping them is created and then executed but then new users that edit the file should be aware that this file should be executed and will have to figure out if the script has to be run before 3 4 CHAPTER 1 INTRODUCTION or after editing some files Sometimes the process can be tedious and hard to reproduce like run program1 edit file1 run program2 edit file2 So ScriptEdit eases this task by running the scripts and outputting the text at the same time in the right order Moreover modifications of the format of the input file are also more easily synchronized with the script Templates and macros are easy Some languages like C already have a good preprocessor that allows using templates include ifdef etc but others like HTML or XML don t and users are asking for them Macros are normally placed in the editor but each editor uses different implementations of them so you have to learn multiple ways to do the same Other languages have already been built to solve this sort of problem In the particular case of processing HTML text files HTP http htp sourceforge net and HPP http citeseer ist psu edu douglis97hpp html are good examples but they are more specialized than what we have in mind Perhaps a more comparable existing language is M4 www gnu org software m4 Chapter 2 Language Tutorial 2 1 Getting Started This short tutorial can be used to quickly familiarize yourself with ScriptEdit The first step is to ensure that you have properly installed the environment needed to run ScriptEdit code Second we will look at the most basic examples of ScriptEdit code Finally we will walk through a more complex ScriptEdit example 1 Check Environment Ensure Java and ANTLR are properly installed To begin using ScriptEdit you will need to do the following 2 uncompress the source archive into an empty directory 3 ensure that you have a JDK version 1 4 or above 4 verify that ANTLR is available and can be run with the command antlr 5 make sure the current directory and antlr jar are in the CLASSPATH 6 compile the source code to create the Java code for the translator s scanner and parser from Simplexer g and compile the ANTLR generated files along with the rest of the ScriptEdit Java code into class files and a ScriptEdit jar file javac d scriptedit java 2 2 How to run ScriptEdit Check that ScriptEdit class and antlr jar are in your class path and type the following commands at the command prompt to create output from se input 5 6 CHAPTER 2 LANGUAGE TUTORIAL files java Main SOURCE SOURCE Is the ScriptEdit source file ScriptEdit will only allow one input file for a source If needed ScriptEdit allows for other files to be embedded within the SOURCE by using the file statement see LRM Source files should be a plain text format that ends with a se extention Upon successful compilation ScriptEdit will create or replace an output file with of the same name as the source file without the se extension myScriptEditCode html se myScriptEditCode html 2 3 Examples of simple ScriptEdit programs ScriptEdit code can be written using any text editor software The examples below will help familiarize you with some basic ScriptEdit syntax and allow you to quickly begin creating your own sciptEdit code The first example is the classic hello world A variable is created to hold a string hello world and then output using the write command 2 3 1 Example 1 using def command to run HelloWorld html se html simple hello world program def greeting hello world greeting html java Min HelloWorld html se OUTPUT FILE HelloWorld html html Simple hello world program Hello world html As demonstrated above ScriptEdit will take the initial ScriptEdit source code the ends in se and create a output file the in which the extension is omitted While the example above shows an HTML file ScriptEdit can be used for any language Keep the following points in mind 1 ScriptEdit instructions begin with a hash or a dollar sign 2 3 EXAMPLES OF SIMPLE SCRIPTEDIT PROGRAMS 7 2 Variable names are enclosed with parentheses and then assigned to whatever is contained within curly brackets immediately following it 3 All non script edit commands are ignored by the compiler and therefore the output is untouched 4 Comments should be native to the underlying language as ScriptEdit does not have its own commenting convention 5 Spaces tabs and all special characters are significant there should be no spacing between a statement and its corresponding opening parenthesis or curly bracket 6 Any special characters that you do not wish to be interpreted by as a ScriptEdit instruction should be preceded escaped by a backslash character The second example below demonstrates a program allowing you to do a loop a set number of time and concatenate a string to form the desired output 2 3 2 Example 2 My first ScriptEdit page Welcome to my first ScriptEdit page def yearborn 1985 def yourage 2006 yearborn You are write
View Full Document
Unlocking...