View Design Doc - Sharla Colvin

colonteeSoftware and s/w Development

Nov 4, 2013 (3 years and 9 months ago)

72 views

Sharla Colvin

Runescript
Programming Language Design Document

Abstract Concept

Rune
script

is a scripting language with a subset of standard features using primarily c
-
style syntax. The
language is type
-
independent and simplified, meaning
neither
variables
nor functions

require types

and

va
riables do not need declaration
.

Numeric values are stored as floats, and most operators work solely
with numeric values.

Na
tiv
e Functions:


print1(val1), print2(val1, val2), and the three, four and five variants

print the arguments to the screen
and to file.

rand(low, high) produces a random number between low and high

inclusive
.

debug(), provided a breakpoint exists in the native function, allows for flexibility during debugging.

Features



Functions

with argument
s, return values, and local variables



Type
-
independent variables supporting indexing and assignment



Literals for strings, numbers, and vector literals



Standard control statements (if, else, and while)



Standard
binary operators

(+
-

/ * == != < > && || ) an
d unary operators (!
-

( bracketing ) )

Syntax Specification

prog = [ fdef … ]
‘main’

blck

if =
‘if’

‘(‘

expr
‘)’

stmt [
‘else’

stmt

]

blck =
‘{‘

[
stmt

… ]

‘}’

whle =

‘while’ ‘(‘

expr
‘)’

stmt

rtrn =

‘return’

expr

‘;’


fdef =
<
func
name>
‘(‘
[

<var
name
>

‘,’

]

‘)’
blck

stmt =
if | whle | rtrn
| blck

| expr
‘;’

expr

=
boolexpr

[
‘=’

expr ]


boolexpr = compexpr [ (
‘&&
’ |
‘||’

) boolexpr ]

compexpr = plusexpr [ (
‘==’

|
‘!=’
|
‘<’

|
‘>’

) plusexpr ]

plusexpr = multexpr [ (
‘+’

|

-


) plusexpr ]

multexpr = fctr [ (
‘*’

| ‘
/’

) multexpr ]

fctr =
‘(‘

expr

‘)’

|
<
var
name>

|
<
var
name>

‘[‘

expr
‘]’

|


<string> | <number> | <vector> |



-


fctr

|
‘!’

fctr

|
<
func
name>
‘(‘

[ expr …
‘,’
]
‘)’




Literal / Name

Specification


<
func
name> / <var
name
>


=

alpha

| ‘_

[ alphanumeric … ]

<string>



=
‘”’

[ alphanumeric
/punctuation …
]
‘”’

<number>



=
numeric [ numeric … ] [
‘.’
numeric [ numeric … ] ]

<vector>



=
‘[‘

[
expr

… ]
‘]’