|
Class: JavaScriptParser
Object
|
+--Scanner
|
+--JavaScriptScanner
|
+--JavaScriptParser
|
+--JavaScriptCompiler
|
+--JavaScriptCompletionParser
|
+--JavaScriptSyntaxHighlighter
- Package:
- stx:libjavascript
- Category:
- Languages-JavaScript-Compiling & Parsing
- Version:
- rev:
1.284
date: 2018/05/18 02:27:08
- user: cg
- file: JavaScriptParser.st directory: libjavascript
- module: stx stc-classLibrary: libjavascript
reads JavaScript-like syntax, builds up an AST similar to the ST-AST.
Used for expecco, so be careful when changing.
configuration
-
forInAllowed
-
^ false.
evaluation
-
evaluate: aStringOrStream
-
evaluate a javaScript expression.
A new environment is created, where variables are defined.
usage example(s):
self evaluate:'1 + 2 * 3 + 4'
|
usage example(s):
self evaluate:'
if (1 > 2) {
Transcript.showCR(1);
} else {
Transcript.showCR(2);
}
'
|
usage example(s):
self evaluate:'
if (1 > 2) {
Transcript.foo(1,2,3,4,5,6,7,8,9,10);
} else {
Transcript.bar(1,2,3,4,5,6,7,8,9,10);
}
'
|
usage example(s):
self evaluate:'
if (1 > 2) {
Transcript.show(hello);
} else {
Transcript.show(world);
}
Transcript.cr;
'
|
-
evaluate: aStringOrStream in: anEnvironment
-
like #evaluate, but take anEnvironment for variable/function declarations.
New vars/functions will be added to that one; lookup for vars/methods
is done there.
If a nil environment is given, a new one will be created for the
evaluation and discarded afterwards.
-
evaluate: aString in: anEnvironment receiver: someObject notifying: requestor logged: logged ifFail: failBlock
-
-
evaluate: aStringOrStream in: anEnvironment receiver: anObject notifying: requestor logged: logged ifFail: failBlock compile: compile
-
return the result of evaluating aStringOrStream, errors are reported to requestor.
Allow access to anObject as self and to its instVars (used in the inspector).
If logged is true, an entry is added to the change-file. If the failBlock argument
is non-nil, it is evaluated if an error occurs.
Finally, compile specifies if the string should be compiled down to
bytecode or instead be interpreted from the parseTree.
The first should be done for doIts etc, where a readable walkback is
required.
The latter is better done for constants, styleSheet and resource
reading and simple sends, where the overhead of compilation is bigger
than the interpretation overhead.
-
evaluate: aStringOrStream receiver: receiver in: anEnvironment
-
like #evaluate, but take anEnvironment for variable/function declarations.
New vars/functions will be added to that one; lookup for vars/methods
is done there.
If a nil environment is given, a new one will be created for the
evaluation and discarded afterwards.
-
evaluateDeclarationsFrom: aStringOrStream for: anEnvironment
-
-
evaluateFrom: aStringOrStream ifFail: exceptionValue
-
evaluate a javaScript expression.
A new environment is created, where variables are defined.
initialization
-
initialize
-
-
postAutoload
-
(comment from inherited method)
postAutoload is sent to a class after it has been autoloaded.
This gives it a chance to arrange for automatic unloading to be done
after a while ...
This is NOT sent to statically compiled in or explicitely filedIn
classes.
The default action here is to do nothing.
instance creation
-
for: aStringOrStream in: aClass
-
return a new parser, reading code for aClass from aStringOrStream
parsing
-
methodCommentFromSource: aStringOrStream
-
here, the methodComment is usually outside of the method's code,
so comments before the function are included in the search, but after it are not.
usage example(s):
JavaScriptParser methodCommentFromSource:'
// foo bar baz
function x() {
halt();
}
// bla bla
'
|
-
methodCommentsFromSource: aStringOrStream
-
returns all comments found in aStringOrStream.
Here, the methodComment is usually outside of the method's code,
so comments before the function are included, but after it are not.
usage example(s):
JavaScriptParser methodCommentsFromSource:'
// foo bar baz
function x() {
halt();
}
// bla bla
'
|
-
parseClassDefinition: aStringOrStream
-
-
parseClassFile: aStringOrStream
-
aStringOrStream
-
parseExpression: aStringOrStream
-
self
parseExpression:'1 + 2 * 3 + 4'
usage example(s):
self
parseExpression:'1.1 + 2.2'
|
-
parseFunction: aStringOrStream
-
self
parseFunction:'function foo(a, b, c) {}'
usage example(s):
self
parseFunction:'function foo(a, b, c) { return a+b; }'
|
-
parseFunction: aStringOrStream in: aClass
-
self
parseFunction:'function foo(a, b, c) {}'
usage example(s):
self
parseFunction:'function foo(a, b, c) { return a+b; }'
|
-
parseMethod: aStringOrStream in: aClass
-
parse a method in a given class. Return a parser (instance of myself).
The parser can be queried for selector, receiver, args, locals,
used selectors, modified instvars, referenced classvars etc.
-
parseMethod: aStringOrStream in: aClass ignoreErrors: ignoreErrors ignoreWarnings: ignoreWarnings
-
parse a method in a given class. Return a parser (instance of myself).
The parser can be queried for selector, receiver, args, locals,
used selectors, modified instvars, referenced classvars etc.
-
parseMethodArgAndVarSpecificationSilent: aStringOrStream
-
-
parseMethodSilent: aString
-
parse a method.
Return a parser (if ok), nil (empty) or #Error (syntax).
The parser can be queried for selector, receiver, args, locals,
used selectors etc.
Like #parseMethod:, but warning/error messages are suppressed.
-
parseMethodSilent: aStringOrStream in: aClass
-
-
parseMethodSpecificationSilent: aStringOrStream
-
-
parseStatementBlockBody: aStringOrStream
-
self
parseStatementBlockBody:'1+2'
usage example(s):
self
parseStatementBlockBody:'var a; a'
|
usage example(s):
Class nameSpaceQuerySignal
answer:JavaScriptEnvironment
do:[
self
parseStatementBlockBody:'Math.PI'
]
|
-
xx_parseMethodSpecification: aStringOrStream in: aClass ignoreErrors: ignoreErrors ignoreWarnings: ignoreWarnings
-
selector translation
-
commonTranslatedSelectorFor: jsSelector
-
common translation (both JS-in-ST and JS-in-HTML).
Given a javascript operator or function name,
translate it into a corresponding smalltalk selector for a message send
-
reverseCommonTranslatedSelectorFor: smalltalkSelector
-
reverse translation.
Given a smalltalk selector, return a corresponding JavaScript
operator or function name.
Used by the document generator only
-
reverseTranslatedJavaScriptSelectorFor: smalltalkSelector
-
translate javaScript selectors as req'd for compiled JTalk.
Given a javascript operator or function name,
translate it into a corresponding smalltalk selector for a message send
usage example(s):
self reverseTranslatedJavaScriptSelectorFor:#show:
self reverseTranslatedJavaScriptSelectorFor:#at:
self reverseTranslatedJavaScriptSelectorFor:#at:put:
self reverseTranslatedJavaScriptSelectorFor:#+
self reverseTranslatedJavaScriptSelectorFor:#-
|
-
selectorForFunctionName: name numArgs: n
-
given a javaScript function name,
return an appropriate valid smalltalk selector.
This is used when methods are compiled
temporary hacks for DWIM
-
parseMethod: aStringOrStream setup: setupBlock onError: onErrorBlock
-
accessing
-
currentNameSpace: aNameSpace
-
-
currentNamespace: aNameSpace
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
interactiveMode: something
-
support for stx-scripting service
-
methodCategory
-
-
methodCategory: something
-
-
moreSharedPools: aCollection
-
-
selector
-
-
targetClass
-
-
targetClass: aClass
-
-
tree
-
return the value of the instance variable 'tree' (automatically generated)
-
tree: something
-
set the value of the instance variable 'tree' (automatically generated)
debugging
-
inspector2TabParseTreeInspector
-
-
inspector2Tabs
-
(comment from inherited method)
Workaround for stc bug
dummy-syntax detection
-
markArgumentIdentifierFrom: pos1 to: pos2
-
intentionally left blank here
-
markFunctionNameFrom: pos1 to: pos2
-
intentionally left blank here
-
markGlobalIdentifierFrom: pos1 to: pos2
-
intentionally left blank here
-
markKeyword: kw from: pos1 to: pos2
-
intentionally left blank here
-
markLocalIdentifierFrom: pos1 to: pos2
-
intentionally left blank here
-
markSelector: id from: pos1 to: pos2 receiverNode: aReceiverNodeOrNil numArgs: numArgs
-
intentionally left blank here
-
markSelfFrom: pos1 to: pos2
-
intentionally left blank here
-
markSuperFrom: pos1 to: pos2
-
intentionally left blank here
-
markVariable: v
-
intentionally left blank here
-
markVariable: v from: pos to: endPos
-
intentionally left blank here
error handling
-
parseError: aMessage position: position to: endPos
-
-
undefError: varName
-
self parseError:'unknown global: ' , varName.
-
warning: msg
-
^ super warning:msg
evaluation
-
evaluate: aString in: anEnvironment receiver: someObject notifying: requestor logged: logged ifFail: failBlock
-
true -- assuming that subclasses can compile
-
evaluate: aStringOrStream in: anEnvironment receiver: anObject notifying: requestor logged: logged ifFail: failBlock compile: compile
-
return the result of evaluating aStringOrStream, errors are reported to requestor.
Allow access to anObject as self and to its instVars (used in the inspector).
If logged is true, an entry is added to the change-file. If the failBlock argument
is non-nil, it is evaluated if an error occurs.
Finally, compile specifies if the string should be compiled down to
bytecode or instead be interpreted from the parseTree.
The first should be done for doIts etc, where a readable walkback is
required.
The latter is better done for constants, styleSheet and resource
reading and simple sends, where the overhead of compilation is bigger
than the interpretation overhead.
-
evaluateDeclarationFor: anEnvironment
-
this is used with the scripting interpreter, where an existing environment
is used and manipulated (i.e. declared variables are persistent across evaluations).
Reads a single decl; for function decls, declare them;
for statements & expressions, evaluate them.
-
evaluateDeclarationsFor: anEnvironment
-
read; for function decls, declare them; for statements & expressions,
evaluate them.
Returns the value of the last expression
helpers
-
commonTranslatedSelectorFor: jsSelector
-
common translation (both JS-in-ST and JS-in-HTML).
Given a javascript operator or function name,
translate it into a corresponding smalltalk selector for a message send
-
currentNameSpace
-
-
expect: expected
-
-
expectKeyword: expected
-
-
findNameSpaceWith: aVariableName
-
"/ private names have already been searched for.
-
ifRequiredTranslateSelectorIn: aNode
-
we are compiling a javaScript-script in a browser.
-
isOpAssignSymbol: token
-
-
selectorForFunctionName: arg1 numArgs: arg2
-
-
topEnvironment
-
-
translatedJSSelectorFor: selector numArgs: numArgs
-
translate selectors as req'd for HTML-scripts.
All selectors get a js_ prepended, to avoid conflicts with corresponding
smalltalk selectors.
This is especially req'd, as at:/at:put: in JS are 0-based,
while being 1-based in ST.
Thus, the translation allows for indexOf: to remain unchanged, and js_indexOf: returns a 0-based index.
-
translatedSmalltalkSelectorFor: jsSelector numArgs: numArgs
-
translate javaScript selectors as req'd for compiled JTalk.
Given a javascript operator or function name,
translate it into a corresponding smalltalk selector for a message send
initialization
-
environment: anEnvironment
-
-
foldConstants: aBoolean
-
-
initialize
-
(comment from inherited method)
initialize the scanner
-
isDoIt
-
-
isDoIt: aBoolean
-
-
parseForCode
-
-
setClassToCompileFor: aClass
-
set the class to be used for parsing/evaluating
-
setSelf: anObject
-
(classToCompileFor ~~ PrevClass) ifTrue:[
-
smalltalkCompatibilityMode
-
in smalltalk mode, array indexing is 1-based,
and conditions must be booleans.
in non-smalltalk (i.e. javaScript) mode, indexing is 0 based
and conditions can also be integers (treating 0 as false).
The default is true (and MUST remain so for expecco)
-
smalltalkCompatibilityMode: aBoolean
-
in smalltalk mode, array indexing is 1-based,
and conditions must be booleans.
in non-smalltalk (i.e. javaScript) mode, indexing is 0 based
and conditions can also be integers (treating 0 as false).
The default is true (and MUST remain so for expecco)
-
untranslatedJavaScriptSelectors1
-
-
untranslatedJavaScriptSelectors1: something
-
-
untranslatedJavaScriptSelectors2
-
-
untranslatedJavaScriptSelectors2: something
-
parsing
-
argList
-
arg | argList , arg
-
classDefinition
-
public class <name> extends <superName> {
<varDecls>
}
-
classNameIdentifier
-
-
constDeclaration
-
'const' name [ '=' constExpression ]';'
-
constDeclarationFor: anEnvironment
-
[ 'static' ] 'const' name ['=' initExpr] ';'
-
constOrVarDeclarationFor: anEnvironment isConst: isConstIn
-
[ 'static' ] ('const'|'var') name ['=' initExpr] ';'
| 'let' name ['=' initExpr] ';'
-
declareConstant: varName inEnvironment: anEnvironment
-
-
declareStaticConstant: varName
-
name (not eaten)
-
declareStaticVariable: varName
-
name (not eaten)
-
declareStaticVariable: varName isConstant: isConstant
-
name (not eaten)
-
declareVariable: varName inEnvironment: anEnvironment
-
-
declareVariable: varName inEnvironment: anEnvironment isConstant: isConstant
-
caveat: isConstant is currently ignored
-
function
-
function(args) stats ;
-
function: readOverClosingBrace
-
function(args) stats ;
-
functionBodyFor: functionNameOrNil asInnerFunction: asInnerFunction
-
(args) stats ;
-
functionBodyFor: functionNameOrNil asInnerFunction: asInnerFunction withStatements: withStatements
-
(args) stats ;
-
functionName
-
function name(args) stats ;
| function className.name(args) stats ;
| function className.class.name(args) stats ;
-
functionOrStaticFunction: readFinalBrace
-
]static] function(args) stats ;
-
lambdaFunctionBodyWithArguments: argList
-
{ stats } ;
-
needSemi
-
;
-
parseDeclarationsFor: anEnvironment
-
read; for function decls, declare them; for statements & expressions,
parse (but do not evaluate) them.
-
parseExpressionWithSelf: anObject notifying: someOne ignoreErrors: ignoreErrors ignoreWarnings: ignoreWarnings inNameSpace: aNameSpaceOrNil
-
parse aString as an expression with self set to anObject;
Return the parseTree (if ok), nil (for an empty string
or comment only ) or #Error (syntactic error).
Errors and warnings are forwarded to someOne (usually some
codeView) which can highlight it and show a popup box,
iff ignoreErrors/ignoreWarnings is true respectively.
-
parseMethod
-
-
parseMethod: theCode in: aClass ignoreErrors: ignoreErrorsArg ignoreWarnings: ignoreWarningsArg
-
-
rememberAssignmentTo: var
-
type == #PoolVariable ifTrue:[
-
rememberReadOf: var
-
type == #PoolVariable ifTrue:[
-
varDeclaration
-
[ 'static' ] 'var' name ['=' initExpr] ';'
[ 'static' ] 'const' name ['=' initExpr] ';'
| 'let' name ['=' initExpr] ';'
-
varDeclarationFor: anEnvironment
-
[ 'static' ] 'var' name ['=' initExpr] ';'
[ 'static' ] 'const' name ['=' initExpr] ';'
| 'let' name ['=' initExpr] ';'
parsing-expressions
-
addExpression
-
addExpr -> mulExpr addOp mulExpr
-
arrayConstant
-
arrayConstant -> Integer-constant
| Float-constant
| String-constant
| true
| false
| null
| arrayLiteral
| objectLiteral
-
arrayIndexing: expr
-
arrayIndexing -> [...]
-
arrayIndexingExpression: recIn
-
arrayIndexingExpression -> variableOrFunctionExpression
| variableOrFunctionExpression[ indexExpr ]
-
arrayIndexingExpressionList: exprIn
-
arrayIndexingExpressionList ->
.identifier(...)
| [ array-expr ]
-
arrayLiteral
-
arrayLiteral -> [ literalConstant { , literalConstant } ] ']'
initial opening bracket has NOT been read.
-
bitAndExpression
-
bitAndExpression -> equalityExpr & equalityExpr
-
bitOrExpression
-
bitOrExpression -> bitXorExpr | bitXorExpr
-
bitShiftExpression
-
conditionalExpr -> addExpr shiftOp addExpr
-
bitXorExpression
-
bitXorExpression -> bitAndExpr ^ bitAndExpr
-
booleanAndExpression
-
booleanAndExpression -> bitOrExpr && bitOrExpr
-
booleanOrExpression
-
booleanAndExpression -> bitOrExpr || bitOrExpr
-
commaExpression
-
commaExpression -> conditionalExpression [, commaExpression ]
-
compareExpr
-
compareExpr -> bitShiftExpr relOp bitShiftExpr
-
compoundExpression
-
-
conditionalExpression
-
conditionalExpr -> boolOrExpr ? boolOrExpr
-
constantExpression
-
-
equalityExpression
-
equalityExpression -> compareExpr relOp compareExpr
-
expression
-
expression -> commaExpression
-
expressionList
-
expression | expressionList , expression
-
functionCallExpression
-
OOPS: almost same as primaryExpression - please refactor
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
functionCallExpression: recIn
-
functionCallExpression -> var
| var(argList)
-
functionCallNodeForReceiver: rec selector: id args: argList fold: fold
-
block evaluation - generate a value-send
-
implicitFunctionCallNodeForReceiver: rec selector: id args: argList fold: fold
-
-
mulExpression
-
mulExpr -> unaryExpr mulOp unaryExpr
-
newExpression
-
-
nonCommaExpression
-
-
objectLiteral
-
objectLiteral -> '{' [ slotName ':' literal { , slotName ':' literal } ] '}'
opening brace has already been read
-
primaryExpression
-
primaryExpr ->
'(' expr ')'
'(' id1,...idN ')' '=>' '{' function-body '}'
| constant
| 'this'
| 'super'
| variable
| 'new' class
| 'new' funcOrClass '(' dim ')'
| 'function' '(' argList ')' '{' statements '}'
-
realFunctionCallNodeForReceiver: rec selector: id args: argList fold: fold
-
block evaluation - generate a value-send
-
typeofExpression
-
-
unaryExpression
-
unaryExpr -> ! unaryExpression
| ~ unaryExpression
| - unaryExpression
| ++unaryExpression
| --unaryExpression
| typeof(primaryExpression)
| primaryExpression
| primaryExpression--
| primaryExpression++
-
varDeclaringExpression
-
-
variable: idAlreadyScanned
-
-
variable: idAlreadyScanned ignoreErrors: ignoreErrors
-
if there is one in the current evaluationContext,
parsing-obsolete
-
assignmentExpression
-
assExpr -> var = condExpr
** This is an obsolete interface - do not use it (it may vanish in future versions) **
parsing-statements
-
breakStatement
-
breakStatement -> break ';'
-
catchPartFor: tryBlockNode
-
tryCatchStatement -> try {
...
statements
...
}
catch(Error [exVar] ) {
...
statements
...
}
[ finally {
...
statements
...
}
Notice: try { ... } has already been parsed.
-
continueStatement
-
continueStatement -> continue ';'
-
doWhileStatement
-
doWhileStatement -> do stat while (expression)
-
finallyPart
-
finallyPart -> finally {
...
statements
...
}
-
forStatement
-
forStatement -> for (initexpr ; condexpr ; increxpression) stat
| for (variable in array) stat
-
functionDefinition
-
ok without semi
-
ifStatement
-
ifStatement -> if (expression) stat [ else stat ]
-
returnStatement
-
returnStatement -> return [ expression ] ['from' outerFunctionName ] ';'
-
statement
-
statement -> expression ;
-
statementBlock
-
statementBlock -> { statList } | statement
-
statementBlock: readClosingBraceBoolean
-
statementBlock -> { statList } | statement
-
statementBlockBody
-
statementBlock -> [ var decl ] statList
-
statementBlockBodyFor: anEnvironment
-
statementBlock -> [ var decl ] statList
-
statementWithSemi: needSemi
-
statement ->
var varName ....
let varName ....
const varName ....
static var varName ....
function ....
ifStatement
whileStatement
doStatement
returnStatement
forStatement
switchStatement
breakStatement
continueStatement
tryStatement
throwStatement
{ statementBlock }
expression ;
-
statements
-
statement -> expression ;
usage example(s):
this is encountered, when reading a javaScript, in which statements
|
-
switchStatement
-
switchStatement -> switch (expression) {
case constant-expression1:
...
stat
...
break ;
case constant-expression2:
...
default:
...
}
-
throwStatement
-
throwStatement -> throw expression ';'
-
tryStatement
-
tryStatement -> try {
...
statements
...
}
( catchPart | finallyPart ]
-
whileStatement
-
whileStatement -> while (expression) stat
private
-
handleCategoryDirective: categoryString
-
callback from the scanner, whenever it encountered a category comment-directive
-
isSyntaxHighlighter
-
-
nameSpaceSelectorFor: aSymbol
-
Caring for the current namespace, return the real selector used for a send.
queries
-
isEmptyMethod
-
return true (after a parse) if this is an empty (documentation) method
-
methodArgs
-
-
methodVars
-
-
wasParsedForCode
-
a kludge for compatibility
queries-statistic
-
messagesPossiblySent
-
return a collection with possible message selectors (valid after parsing).
Includes things known or possibly used with #perform or in specs.
Not yet implemented here.
usage example(s):
^ (messagesPossiblySent ? #()) collect:[:each | each asSymbol]
|
-
messagesSent
-
return a collection with sent message selectors (valid after parsing).
Includes all sent messages (i.e. also sent super messages)
-
messagesSentToSelf
-
that is not true - for now, to make the browser happy
-
messagesSentToSuper
-
that is not true - for now, to make the browser happy
-
modifiedClassVars
-
-
modifiedGlobals
-
-
modifiedInstVars
-
-
usedClassVars
-
-
usedGlobals
-
-
usedInstVars
-
-
usedVars
-
-
usesSuper
-
return true if the parsed method uses super (valid after parsing)
statistic
-
rememberClassVarModified: name
-
-
rememberClassVarRead: name
-
-
rememberClassVarUsed: name
-
-
rememberGlobalModified: name
-
-
rememberGlobalRead: name
-
-
rememberGlobalUsed: name
-
-
rememberInstVarModified: name
-
-
rememberInstVarRead: name
-
-
rememberInstVarUsed: name
-
-
rememberLocalModified: name
-
modifiedLocalVars isNil ifTrue:[
-
rememberLocalRead: name
-
readLocalVars isNil ifTrue:[
-
rememberLocalUsed: name
-
usedLocalVars isNil ifTrue:[
-
rememberVariableUsed: name
-
temporary hacks for DWIM
-
nodeGenerationCallback: nodeGenerationHook
-
-
rememberNodes: aBoolean
-
-
rememberTokens: aBoolean
-
utilities
-
ensureBooleanExpression: expr
-
relops are guaranteed to return booleans...
AndExpressionNode
ArrayAccessNode
ArrayStoreNode
BreakStatementNode
CommaExpression
ConditionalNode
ContinueStatementNode
DoWhileStatementNode
ForStatementNode
FunctionCallNode
IfStatementNode
ImplicitFunctionCallNode
IncDecNode
InnerJavaBlockNode
JavaScriptAssignmentNode
JavaScriptBinaryNode
JavaScriptReturnNode
JavaScriptStatementNode
JavaScriptUnaryNode
NewNode
OrExpressionNode
PostIncDecNode
PreIncDecNode
StatementBlockNode
SwitchStatementNode
ThisNode
ThrowStatementNode
TryCatchStatementNode
TypeOfNode
WhileStatementNode
JavaScriptParser parseExpression:'3 != 4'
| JavaScriptParser parseExpression:'0b11 + 0b100'
(JavaScriptParser parseExpression:'3 + 4 * 5') evaluate
|
JavaScriptParser parseExpression:'(3 != 4) && (5 == 5)'
|
(JavaScriptParser parseExpression:'(3 == 4) || (5 == 5)') evaluate
|
JavaScriptParser parseExpression:'!(3 != 4)'
|
(JavaScriptParser parseExpression:'(3 != 4)') evaluate
|
(JavaScriptParser parseExpression:'!(3 != 4)') evaluate
|
#(
'1 + 2 * 3 + 4'
'1 * 2 * 3 * 4'
'1 + 2 / 3'
'10 / 3'
'11 & 3'
'0x8000'
'0377'
'3 == 3'
'3 != 3'
'3 == 4'
'3 != 4'
'3 > 3'
'3 >= 3'
'3 < 3'
'3 <= 3'
'3 > 4'
'3 >= 4'
'3 < 4'
'3 <= 4'
'4 > 3'
'4 >= 3'
'4 < 3'
'4 <= 3'
'0x8>>2'
'8 << 2'
'8 >>> 2'
) do:[:s |
Transcript
show:'''';
show:s;
show:'''';
show:' -> ';
showCR:(JavaScriptParser parseExpression:s) evaluate.
]
|
JavaScriptParser
parseFunction:'function foo(a, b, c) {}'
|
JavaScriptParser
parseFunction:'function foo(a, b, c) {
if (a > 1) {
return a;
} else {
return b;
}
}'
|
JavaScriptParser
parseFunction:'
function bar(a, b, c) {
var sum;
while (a > 1) {
sum += a;
a--;
}
return sum;
}'
|
JavaScriptParser
parseFunction:'
function bar(a, b, c) {
var sum;
var j;
if ( foo(a,b) ) {
for (j=0; j<=a.length; j++) {
if (c[j] <= c[j+1])
break;
}
}
return sum;
}'
|
JavaScriptParser
parseFunction:'
function bar(a, b, c) {
var sum;
if ( foo(a,b) ) {
for (var j=0; j<=a.length; j++) {
if (c[j] <= c[j+1])
break;
}
}
return sum;
}'
|
JavaScriptParser
parseFunction:'
function switch_time(value) {
if (value < 0.5) sw = 0;
else sw=-1;
}
'
|
JavaScriptParser
parseFunction:'
function f(a) {
return ( function (b) { return (a + b); } );
}
'
|
|