Windshield. Language Reference Manual. Columbia University COMS W4115 Programming Languages and Translators Spring Prof. Stephen A.

Similar documents
OPERATING SYSTEMS LAB LAB # 6. I/O Redirection and Shell Programming. Shell Programming( I/O Redirection and if-else Statement)

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Command Interpreters. command-line (e.g. Unix shell) On Unix/Linux, bash has become defacto standard shell.

Essential Linux Shell Commands

Conditional Control Structures. Dr.T.Logeswari

Unix Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : December, More documents are freely available at PythonDSP

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

DINO. Language Reference Manual. Author: Manu Jain

Part 1: Basic Commands/U3li3es

Chapter 4. Unix Tutorial. Unix Shell

Introduction to Supercomputing

Introduction to Linux Basics Part II. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Shell script/program. Basic shell scripting. Script execution. Resources. Simple example script. Quoting

UNIX shell scripting

Shell Programming Overview

Linux shell programming for Raspberry Pi Users - 2

LOG ON TO LINUX AND LOG OFF

Programming Languages & Translators. XML Document Manipulation Language (XDML) Language Reference Manual

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

Bash command shell language interpreter

COMS 6100 Class Notes 3

Basic Linux (Bash) Commands

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

Python for Astronomers. Week 1- Basic Python

Shell Programming Systems Skills in C and Unix

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

Shell Start-up and Configuration Files

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Shell Scripting. Winter 2019

Shell Programming (bash)

Title:[ Variables Comparison Operators If Else Statements ]

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

CS 25200: Systems Programming. Lecture 10: Shell Scripting in Bash

Useful Unix Commands Cheat Sheet

EECS2301. Example. Testing 3/22/2017. Linux/Unix Part 3. for SCRIPT in /path/to/scripts/dir/* do if [ -f $SCRIPT -a -x $SCRIPT ] then $SCRIPT fi done

Sub-Topic 1: Quoting. Topic 2: More Shell Skills. Sub-Topic 2: Shell Variables. Referring to Shell Variables: More

Linux Bash Shell Scripting

Mirage. Language Reference Manual. Image drawn using Mirage 1.1. Columbia University COMS W4115 Programming Languages and Translators Fall 2006

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

CSE 15L Winter Midterm :) Review

Shell scripting Scripting and Computer Environment - Lecture 5

COMP 2718: Shell Scripts: Part 1. By: Dr. Andrew Vardy

Typescript on LLVM Language Reference Manual

BASH Programming Introduction

Shells & Shell Programming (Part B)

Topic 2: More Shell Skills

The Unix Shell. Pipes and Filters

Assignment clarifications

Shells and Shell Programming

Lab Working with Linux Command Line

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

Bash shell programming Part II Control statements

Shells and Shell Programming

Language Reference Manual

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Essentials for Scientific Computing: Bash Shell Scripting Day 3

DATA 301 Introduction to Data Analytics Command Line. Dr. Ramon Lawrence University of British Columbia Okanagan

Why learn the Command Line? The command line is the text interface to the computer. DATA 301 Introduction to Data Analytics Command Line

Computer Systems and Architecture

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Topic 2: More Shell Skills. Sub-Topic 1: Quoting. Sub-Topic 2: Shell Variables. Difference Between Single & Double Quotes

Scripting. More Shell Scripts. Adapted from Practical Unix and Programming Hunter College

CHIL CSS HTML Integrated Language

Linux environment. Graphical interface X-window + window manager. Text interface terminal + shell

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

Linux Shell Script. J. K. Mandal

A Brief Introduction to the Linux Shell for Data Science

Essential Skills for Bioinformatics: Unix/Linux

Language Design COMS W4115. Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science

Introduction: What is Unix?

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

Basics. proper programmers write commands

Understanding bash. Prof. Chris GauthierDickey COMP 2400, Fall 2008

Answers to Even-numbered Exercises

Scripting Languages Course 1. Diana Trandabăț

Lecture 5. Essential skills for bioinformatics: Unix/Linux

Std: XI CHAPTER-3 LINUX

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved

bash Execution Control COMP2101 Winter 2019

YOLOP Language Reference Manual

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Computer Systems and Architecture

Bash scripting Tutorial. Hello World Bash Shell Script. Super User Programming & Scripting 22 March 2013

Computer Systems and Architecture

CENG 334 Computer Networks. Laboratory I Linux Tutorial

CSE 490c Autumn 2004 Midterm 1

COMP 4/6262: Programming UNIX

UNIX System Programming Lecture 3: BASH Programming

The Shell. EOAS Software Carpentry Workshop. September 20th, 2016

QUark Language Reference Manual

EECS 470 Lab 5. Linux Shell Scripting. Friday, 1 st February, 2018

ASML Language Reference Manual

Automating Tasks Using bash

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

5/20/2007. Touring Essential Programs

Introduction to Linux. Fundamentals of Computer Science

bash, part 3 Chris GauthierDickey

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Transcription:

Windshield Language Reference Manual Columbia University COMS W4115 Programming Languages and Translators Spring 2007 Prof. Stephen A. Edwards Team members Wei-Yun Ma wm2174 wm2174@columbia.edu Tony Wang tw2174 tw2174@columbia.edu Tzu-Jung Liu tl2263 tl2263@columbia.edu

Windshield is a Windows Shell Script using the bash script as reference and implementing the fundamentals. Most of programming methods are similar with bash script. There are a few differences: some features in bash are simplified, and some new features are added in Windshield. 1. Lexical Conventions Tokens Windshield contains 5 types of tokens, namely identifiers, keywords, numbers, strings, and others. White spaces and comments are neglected, except when used to separate tokens. Whitespaces Whitespaces includes spaces( ), tabs( \t ), new lines( \n ), returns( \r ). Comments There are two ways to write comments in Windshield. Single-line comments start with the special character # and ends at the end of the line. Multi-line comments starts at /# and ends at the first #/ it sees. 1.1 Identifiers An identifier is a sequence of letters, digits and underscores. The first character must be a letter. Identifiers are case-sensitive. 1.2 Keywords Here s a table of reserved word. They may not be used as variable names when writing a program in Windshield. if then else elif fi case esac while do done for echo function return

1.3 Numbers Numbers in windshield are either an integer or a floating point number. 1.3.1 Integer A sequence of one or more digits, if there are more than 1 digit, the first digit must be non-zero. 1.3.2 Floating point number Contains an optional integer part, a., a decimal part. 1.4 String String literals are characters contained in a pair of double quotes or single quotes, but not in a mixture of the two, i.e. if a string literal starts with a double quote( ), it must end with a double quote. 1.5 Others [ ] ( ) == >= <= > <!=., ; && -d -e 2. Types Like shell scripts, variables in Windshield does not need to be declared a specific variable type upon creation. Instead it s type is automatically determined when that variable is assigned a value. The underlying types in Windshield are: string, integer, float. 3 Expressions WindShield has tree major expression forms: Define User Variables, Command Lines and Combination of Command Lines. Combination of command lines means programmers can use quoto, Redirection, or pipe skills to combine multiple command lines into one command line. Not like bash script, WindShield limits each code line to contain only one expression.

3.1 Define User Variables define user variables: variable name=value 'value' is assigned to given 'variable name' and Value must be on right side = sign. Ex: STR="Hello World!" 3.2 Command Lines Shell Script is series of command written in plain text file. Command lines contain two types, one is build-in commands which is defined in chap1, the other is own programs. Ex: echo "Hello World!" C:\myprogram.exe 3.2.1 Use Variables When a variable is defined, it lacks the '$' in front. But once a variable is used or referenced, it should be put the '$' in front. Ex: STR="Hello World!" echo $STR 3.2.2 Mathematics WindShield limits string values to be quoted by, so it is not ambiguous between string and operations. That is, 5+3 is a string, 5+3 is an operation. By this limitation, we can directly write mathematical operation without expr command in bash. v="5+3" # v is a string with content 5+3 v=5+3 # v is 8 3.3 Combination of command lines One of the important features of WindShield is its ability to glue multiple command lines into one command line by using skills of quoto, Redirection, or pipe

3.3.1 quoto There are three types of quotes Quotes Name Meaning " Double Quotes "Double Quotes" - Anything enclose in double quotes removed meaning of that characters. ' Single quotes 'Single quotes' - Enclosed in single quotes remains unchanged. ` Back quote `date` - To execute command. Ex: echo "Today is `date`" 3.3.2 pipe A pipe is a way to connect the output of one program to the input of another program without any temporary file. command1 command2 Ex: cat file1 sed s/hello/word/ myprogram.exe > file3 # replace any Hello with World in file1 and send the replaced content to # myprogram.exe, which output is recorded in file3 3.4. I/O Redirection There are three redirection symbols >,>>,< (1) > Redirector Symbol command > filename To output commands result to file. If file already exist, it will be overwritten else new file is created. Ex: To send output of ls command give $ ls > myfiles Now if 'myfiles' file exist in your current directory it will be overwritten without any type of warning.

(2) >> Redirector Symbol command >> filename To output commands result to END of file. If file exists, it will be opened and new information/data will be written to END of file, without losing previous information/data. And if file does not exist, then new file is created. Ex: send output of date command to already exist file give command $ date >> myfiles (3) < Redirector Symbol command < filename To take input to command from file. Ex: To take input for cat command from file. $ cat < myfiles 4. Control Flow There are several common control flow statements in Windshield, such as if, case, for and while. 4.1 Conditional We take an example to introduce if. if [condition_1] then statement_1 elif [condition_2] then statement_3 statement_4 else statement_5 statement_6 fi fi

'condition_numbers' is a conditional judgment. Operators in the conditional judgement are listed in the follows. A >= B : A is larger than or equals to B A <= B : A is less than or equals to B A > B : A is larger than B A < B : A is less than B A == B : A equals to B A!= B : A does not equal to B condition_1 && condition_2 : condition_1 and condition_2 condition_1 condition_2 : condition_1 or condition_2 -d dir : if this dir exists, return true -e file : if this file exists, return true. Note: The next line of if [condition_1] should be then, and the end line of the whole representation should be fi. The second condition control: 'case'. case variable in variable_1) statement_1 ;; variable_2) statement_11 2 ;; *) statement_111 22 ;; esac

4.2 Iteration There are two iterative controls: 'for' and 'while'. for variable in expr do statement_1 done for char in A B C D E F G do echo "$char" done for (( expr ; condition ; expr )) do statement_1 done while [condition] do statement_1 done 5. Functions (user-defined) Functions in Windshield are a series of statements and commands, that completes a specific task. The syntax to write a function is as follows:

function name (){ statement 1; statement 2;. statement n; return statement; } The arguments passed into a function are accessed in the function through $N, where N is the number of the argument. 6. Build-in commands The small part but basic Unix/Linux commands will be included in Windshield, such as echo, cp, mv, rm, mkdir, rmdir, cd, df, du, ls, cat, pwd, basename, expr and read. Two useful utilities-sed and grep are also included in Windshield. The two utilities allow regular expression representation for their inputs.