This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.
  • Index
  •  » Advanced Topics
  •  » Libraries needed for syntax highlighting, looking for good programmers

#1 2011-12-18 06:05:21

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Libraries needed for syntax highlighting, looking for good programmers

I need basic, simple libraries of the following:
• Comment tokens
• String tokens
• Syntax tokens (flow controllers like if)
• Properties, events, and methods
for as many languages as we can get. Specifically, I'm looking for:
• Squeak
• JavaScript
• Java
• PHP
• C
• Objective-C
• HTML (<> should be written as &lt and &rt)

Here's the syntax to share something:

Code:

if (lang == "language")
{
 commentTokens = [["openCommentToken", "closeCommentToken"], ["openCommentToken", "closeCommentToken"]];
 stringTokens = [["openStringToken", "closeStringToken"], ["openStringToken", "closeStringToken"]];
 syntaxTokens = ["token 1", "token 2", "token 3"];
 properties = ["token 1", "token 2", "token 3"];
}

Please contribute!
—Hardmath123

EDIT: Here's a starter for JS:

Code:

    if (lang=="JavaScript")
    {
        syntaxTokens = ["if", "else", "var", "function", "return", "this", "new", "true", "false", "while", "break", "case", "switch", "for", "document", "window", "String", "Array", "Object", "Window", "Math"];
        numericalTokens = ["1","2","3","4","5","6","7","8","9","0"];
        blockTokens = [["\"", "\""], ["\'", "\'"], ["@\"", "\""]];
        commentTokens = [["/*", "*/"], ["//", "\n"]];
        tempVars = prompt("Temporary variables?", "something, nothing, anything").split(", ");
        properties=["getElementById", "getContext", "prototype", "constructor", "alert", "confirm", "prompt", "sqrt", "pow", "PI", "value", "innerHTML", "height", "width", "cols", "rows", "style", "onload", "onclick", "ondblclick", "onmouseover", "onmouseout", "onmousemove", "onmousedown", "onmouseup", "onkeyup", "onkeydown", "onkeypress", "onbeforeunload"];
    }

Or highlighted:

if (lang=="JavaScript")
    {
        syntaxTokens = ["if", "else", "var", "function", "return", "this", "new", "true", "false", "while", "break", "case", "switch", "for", "document", "window", "String", "Array", "Object", "Window", "Math"];
        numericalTokens = ["1","2","3","4","5","6","7","8","9","0"];
        blockTokens = [["\"", "\""], ["\'", "\'"], ["@\"", "\""]];
        commentTokens = [["/*", "*/"], ["//", "\n"]];
        tempVars = prompt("Temporary variables?", "something, nothing, anything").split(", ");
        properties=["getElementById", "getContext", "prototype", "constructor", "alert", "confirm", "prompt", "sqrt", "pow", "PI", "value", "innerHTML", "height", "width", "cols", "rows", "style", "onload", "onclick", "ondblclick", "onmouseover", "onmouseout", "onmousemove", "onmousedown", "onmouseup", "onkeyup", "onkeydown", "onkeypress", "onbeforeunload"];
    }

Last edited by Hardmath123 (2011-12-19 08:14:51)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#2 2011-12-18 16:04:19

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: Libraries needed for syntax highlighting, looking for good programmers

What language are you doing this in? Php?


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#3 2011-12-19 05:38:11

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Libraries needed for syntax highlighting, looking for good programmers

Daffy22 wrote:

What language are you doing this in? Php?

JavaScript, actually. You should have been able to tell by the sample code!  tongue

Last edited by Hardmath123 (2011-12-19 08:15:34)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 
  • Index
  •  » Advanced Topics
  •  » Libraries needed for syntax highlighting, looking for good programmers

Board footer