flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Scripting Language and Markup Language

Author
Thread Post new topic Reply to topic
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
I've been thinking of designing a command (script) language for my OS and a markup language for applications.
(NOTE: I posted my idea here, so I wouldn't forget about it. These are my concepts/abstractions of both languages. Please comment.)
Script Language
The script language will be used in CLI and GUI environment of the OS. It is different than the command language.

Concept (Goals)
The overall concept (goals) for the script language are:

    •Easily understood syntax (or something like that);
    •Mathematically based (e.i, can perform mathematical operations -- simple and complex);
    •Data manipulation;
    •Console (CLI) and GUI script based (e.i, can be ran to perform CLI environment tasks: deleting a file and GUI environment tasks: like making a message box);
    •Support macro recording (e.i, set macro commands);
    •Support function definition (e.i, set functions);
    •Support transput (e.i, input and output);
    •Support english-like commands (e.g: move file (to) destination);
    •Proficiency for both general and programmer users;
    •Support variables and variable interpolation;
    •Application program execution;
    •Support different datatypes: string, integer (sizes: 8,16,32), character, boolean, floating point (real values), array, pointer (address), constants;
    •Support control flow statements: if, while, for, loop, repeat, is; (please add more statements, if possible);
    •Provide functions for the user: length, maxlength, void, join, upcase, lowcase, find, equal, inequal, reverse, list, trim, chop, free, tmap, lookup, fetch, random


Variables
incomplete


    When a user declares a variable, a variety of information about the variable are saved. Information such a length, data type, scope, etc. These information are known as metadata. They give the properties of a allocated variable. The following are stored:

      •Identifier the name or label of the variable.
      •Data the value of the variable.
      •Datatype the datatype of the variable.
      •Length the length of the data stored. (Number of bytes). This is represented by an integer.
      •Maximum length allowed the maximum length allowed for data storage. The maxumun length is represented as an integer
      •Access right the privilage the user has to access the data and alter it. User access and system access are recognized by a 'U' or 'S', repectively.
      •scope whether data is Global or Local. These are denoted by a 'G' or 'L', respectively.
      •definition Whether the data was initialized or uninitialized. These are denoted by an 'I' or 'U', repectively.
      •status functionality unknown

    It is still known as to how variables are stored in memory.


Command Syntaxes

    1. Syntax for command. (Each command has it's own syntax).
    Code:
     Name -Parameter1 -Parameter2 Argument1, Argument2, Argument3,...
        

    2. Sytanx for control-flow statements
    Code:
     Name (Condition): { Commands )
        

    3. Syntax for functions
    Code:
    ;Function statement
     Name(Argument1, Argument2,...)
    ;Defining a function
     Func(Parameter1,Parameter2,...)
         {
          commands
         }
        



Commands
incomplete




Functions
Every function returns the result of the function into the system variable %RETURN%, if the return command isn't in a function.

    f(x) = ax+b

Here are some possible functions which are to be provided to the users:

    1. Length returns the length of a string in to the return variable.
    Code:
     Length(string)
         


      Example:

        set length = length("Hello World")
        print "Length of string %length%"

      Output:

        Length of string 11


    2. MaxLength specifies the number of bytes a variable can store.
    Code:
     MaxLength(variable,maximum_length)
         


      Example:

        set hello = "Hello World"
        maxlength(%hello%,5)
        print %hello%

      Output:

        Hello


    3. Void this function does not return any value to %RETURN%. Void() is used with other functions if no value is required to be returned. Even if a return command is used in it, there this is no return value.
    Code:
     Void(function)
         


      Example:

        set hello = "hello world"
        void(upcase(%hello%))
        print "%hello%. %return%"

      Output:

        HELLO WORLD

      The return variable is null, of the Void().

    4. Join concatenates two or more strings into one. It returns the result into %RETURN%.
    Code:
     Join(string1,string2,...)
         


      Example:

        set part2 = "world"
        join("Hello ",%part2%)
        print %return%

      Output:

        Hello world


    5. Upcase converts lowercased characters into uppercased characters. If a string is presented, then the result returns to %RETURN%. But if a variable is given, then it is converted directly, and the result is also placed in %RETURN%.
    Code:
     Upcase(string)
         


      Example:

        upcase("hello world")
        print %return%

      Output:

        HELLO WORLD


    6. Lowcase converts uppercased characters into lowercased characters. if a string is presented, then the result returns to %RETURN%. But if a variable is given, then it is converted directly, and the result is also placed in %RETURN%.
    Code:
     Lowcase(string)
         


      Example:

        lowcase("HeLLo WorlD")
        print %return%

      Output:

        hello world


    7. Find searches for a character, or sequence of characters in a string. It can be have a delimiter, as to where it where it can go, in the sequence. A token is specified; giving the number of characters that are the same, which their positions can be return. See, example [insert example number here]. When found, it returns the position(s) of the character(s) found. If it is a string, then it returns the range of the string, found in the array. If there are more than one positions found, then each position number is separated by ';' in %RETURN%. When no character is found, a '!' exclaimation mark is return, signifying that nothing was found.
    Code:
     Find(character,string,token,delimiter)
         


      Example:

        find("a","Armed with a a knife; we won!",*,";")
        print %return%

      Output:

        11;13

      The numbers show where each 'a' is located in the string. It doesn't identify the capital 'A' this function is case sensitive. A token specifies how many positions of the character are to be collected. The delimiter limits how far the function should scan for the character. A delimiter can either be a character or a an interger.

    8. Equal checks to see if the two strings are equal. If the two strings are equal, then it returns (interger) 1 else, it returns 0. (Redundant).
    Code:
     Equal(string = string)
         


      Example:

        equal("meshnix" == "meshnix")
        if %result%:
        {
        print "Strings are equal"
        else:
        print "Strings are not equal"
        }

      Output:

        Strings are equal


    9. Inequal checks to see if the two strings are negates, if so then it returns 1, else 0. (Redundant).
    Code:
     Inequal(string != string)
         


      Example:

        equal("meshnix" != "some other guy")
        if %result%:
        {
        print "Strings are equal"
        else:
        print "Strings are not equal"
        }

      Output:

        Strings are not equal


    10. Reverse reorders or overturns the sequence of a string.
    Code:
     Reverse(string)
         


      Example:

        reverse("Radar")
        print %return%

      Output:

        radaR


    11. List [functionality unknown]
    Code:
     List(string)
         


      Example:

        set fruits = "mango;orange;apple;grape;kiwi;cherry"
        list(%fruits%)
        print %return%

      Output:



        •mango
        •orange
        •apple
        •grape
        •kiwi
        •cherry


    12. Trim is used to remove whitespaces from the beginning an end of a string.
    Code:
     Trim(string)
         


      Example:

        trim(" spacious ")
        print %return%

      Output:

        spacious


    13. Chop removes the last character from a string but, it leaves a whitespace in its place.
    Code:
     Chop(string)
         


      Example:

        chop("Hello world!")

      Output:

        Hello world


    14. Free deallocates a variable that was allocated. It's status is set to 'I'(nactive) instead of 'A'(ctive). The metadata of the object are nullified. The object can be defined as a different datatype and new values can be set, with a different name (indentifier). Free() allows for the reuse of variables, since there is a limitation of 256 allocation areas for each datatype.
    Code:
     Free(variable)
         


      Example:

        set score = 125
        print %score%
        free(%score%)
        print %score%

      Output:

        125
        null

      Nothing is printed a null, because the score variable was deallocated, so it doesn't exist anymore.

    15. Tmap is a table structure that stores data. The data can be stored in a 8*2 (col*rows) table. Each table cell stores 16 bytes. Each name is unique to data. Tables are basically variables whose array is 16 bytes. There can only be 8 variables.
    Code:
     TMap(table_name,name,data)
         


      Example:

        tmap("score","level1",100)
        tmap("score","level2",99)
        print "%score[Level1]%"

      Output:

        100


    16. Fetch grabs an element from the table.
    Code:
     Fetch(table_name,name)
         


      Example:

        fetch(score,level1)
        print %return%

      Output:

        100


    17. Lookup looks up a byte in a linear array (directly from memory), and places it in %RETURN%.
    Code:
     Lookup(base_address, index)
         


      Example:

        set hello = "Hello World"
        point hello_addr = %hello%
        lookup(hello_addr,7)
        print %return%

      Output:

        W


    18. Random generates a random number and places it in the given variable. It also returns to %RETURN%.
    Code:
     Random(variable)
         


      Example:

        random()
        print %return%

      Output:

        472834




Arrays
If we want to select an element from the array 'greeting', it can be done two ways:

    1. Using interpolation and array splicing
    Code:
    start:
          string greeting = "HELLOWORLD"              # set an array called greeting
          print %greeting[5]%                     # print the element
        

    2. Finding the element using the address of the array
    Code:
    start:
          string greeting = "HELLOWORLD"         # set an array called greeting
          int index       = 5                     # set the column (index) position we want
          point base      = %greeting          # set greeting memory location
        
          set element     = %base + %index        # find element on array
          print %element%                        # print the element
        






Markup Language
The markup language would be used change the form of text on an application (only in GUI). It is codenamed: MetaMarkup

Concept (Goals)
The overall concept (goal) for the markup language are:

    •Colored text;
    •Text shadows;
    •Different text formats: bold, italic, underline, superscript, subscript,block, delete, glow /outline (not animated);
    •Text animation;
    •HyperLinks (e.i, text can be used to launch a dialog instead of buttons);
    •Text alignments: left, center, right (maybe justified);


Tags and Syntax
The application would have these scripts and reference from the string and format during initialization. Each string can be used by the application. A string is identified by using its ID number.

Here are some of the possible tags for MetaMarkup:

    Header

      <?mml version=mml version?> MML magic number (and version identifier).
      <doctype name=document name id=doc ID number type=document type(usually MML) description=doc description> document information and it's type.

    Body

      <body>markup tags</body> defines the area which contains the application strings and formats.
      <window name type=msgbox/window/dialog/control id=gadget id> defines the window which the text is located.
      <string id=string id>string</string> specifies the string which is to be formatted.

    Text Formats

      <font face=font name color=font color>text</font> speficies font to be used.
      <size>element</size> resizes text.
      <align>text</align> align text within a specified area.
      <b>text</b> bolds text.
      <i>text</i> italizes text.
      <u>text</u> underlines text.
      <sup>text</sup> superscrips text.
      <sub>text</sub> subscripts text.
      <block>text</block> highlights or creates a box aroung text.
      <delete>text</delete> stikes text, by placing a line through it.
      <outline color=outline color>text</outline> outlines text with a colour.
      <glow>text</glow> creates a glow effect around text. It can be animated.

    HyperLinks

      <a href=file path>link label</a> creates a link in the window to a file.
      <xa href=window idlink label</xa> creates a link in the window to another window of that thread.



Example
Example markup script:

    Code:
    <?mml version=1.0 ?>
    <doctype name=example1 id=100 type=mml description="an example markup script showing a typical document">
    
    <body>
         <Example1 type=msgbox id=1>
           <string id=1>
                  <font color=blue>Hello World<b>!</b></font>
        </string>
         </Example1>
    </body>
        




MeshNix wrote:
I just decided to post the ideas that I had about the languages. It will help me to have my ideas critiqued, so I can improved them. These just the concept of the language, not really the final draft. I am trying to get out the details of the syntax an semantics, and allowing them to work together (I would be 100%, but I think I can ge something close to that).




(Incomplete notes)

_________________
meshnix


Last edited by adroit on 20 Jun 2010, 06:53; edited 5 times in total
Post 18 Jun 2010, 17:41
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4215
Location: 2018
edfed
% is useless.
if human can understand something without %, then, computer can.

it is like offset keyword in MASM, or ptr[] combinaison.

[greeting+5] instead of greeting[5]
byte [greeting+6]

... the same script as fasm address syntax.
Post 18 Jun 2010, 18:03
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
edfed wrote:
% is useless.
if human can understand something without %, then, computer can.

It is not completely useless. It helps to differentiate between a word and a variable -- it helps to easily identify a variable.
Maybe it is because of the MS syntax. Maybe I'll change it to '$' instead.

What if we had something like this:
Code:
set age = 99
print "my age is age"    

Output: my 99 is 99
How would we know which is a variable?
When it could be:
Code:
print "my age is %age%"    

Output: my age is 99
It can be easily identified.
Unless,
Code:
print "my age is", age    

Output: my age is 99
But, this one would meet the proficiency of the general (non-programmers) users.
Post 18 Jun 2010, 19:01
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
It seems better as [greeting+5] instead of greeting[5]
Code:
start:
     set greeting = "Hello World"
     print $greeting[6:*]                        ;# echo 'world' only
;# what about (if I were to use it).
     print $[greeting+6]:[greeting+10]           ;# ?
    
Post 18 Jun 2010, 19:17
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.