Skip to content

Commit 215cda7

Browse files
committed
restore v1.0.3
1 parent 5fe07e5 commit 215cda7

15 files changed

+81
-82
lines changed

examples/Factorial.nsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function fact($n)
1313
return $n * fact($n - 1);
1414
}
1515

16-
section Fib()
16+
section Factorial()
1717
{
1818
#define Factorial 4
1919
DetailPrint("fact(".Factorial.") = ".fact(Factorial));

examples/Install.nsl

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#define Version '1.0.2'
1+
#define Version '1.0.3'
22

33
Name("nsL Assembler ".Version." (Alpha)");
44
OutFile("nsL-Assembler-".Version.".exe");
@@ -18,8 +18,10 @@ function .onInit()
1818
$INSTDIR = ReadRegStr("HKLM", @"Software\NSIS", "");
1919
if (StrCmp($INSTDIR, ""))
2020
{
21-
MessageBox("MB_OK|MB_ICONEXCLAMATION", "NSIS is not installed on this machine. Setup will now exit.");
22-
Abort();
21+
if (MessageBox("MB_YESNO|MB_ICONEXCLAMATION", "NSIS is not installed on this machine. Would you like to continue anyway?") == "IDNO")
22+
Abort();
23+
24+
$INSTDIR = $PROGRAMFILES.@"\NSIS";
2325
}
2426
}
2527

@@ -31,8 +33,8 @@ section Install("nsL Assembler", true)
3133

3234
// Extract documents.
3335
SetOutPath($INSTDIR."\\Docs\\NSL");
34-
File(@"..\..\Reference.pdf");
35-
File(@"..\..\functions.txt");
36+
File(@"..\docs\Reference.pdf");
37+
File(@"..\docs\functions.txt");
3638

3739
// Add the right click "Compile nsL Script" option.
3840
WriteRegStr("HKCR", ".nsl", "", "nsL.Script");
@@ -77,7 +79,7 @@ section Source("Java Source Code", false, true)
7779
FileRecursive(@"..\test");
7880
File(@"..\build.xml");
7981
File(@"..\manifest.mf");
80-
File(@"..\..\Reference.docx");
82+
File(@"..\docs\Reference.docx");
8183
}
8284

8385
uninstall function .onInit()

examples/Plugins.nsl

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
OutFile("Test.exe");
2+
ShowInstDetails("show");
3+
XPStyle("on");
4+
RequestExecutionLevel("admin");
5+
6+
section Test()
7+
{
8+
$R0 = NSISdl::download("http://nsis.sourceforge.net/mediawiki/images/4/44/NSISArray.zip", $EXEDIR.@"\NSISArray.zip");
9+
DetailPrint($R0);
10+
}

examples/Test.nsl

+12
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,16 @@ RequestExecutionLevel("admin");
55

66
section Test()
77
{
8+
if (MessageBox("MB_YESNO", "Click Yes or No...") == "IDYES")
9+
DetailPrint("You clicked Yes!");
10+
switch (MessageBox("MB_YESNO", "Click Yes or No...") == "IDYES")
11+
{
12+
case true:
13+
DetailPrint("You clicked Yes!");
14+
break;
15+
case false:
16+
DetailPrint("You clicked No!");
17+
break;
18+
}
19+
820
}

nbproject/private/private.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1">
44
<file>
55
<url>src/nsl/expression/Expression.java</url>
6-
<line>464</line>
7-
<line>628</line>
8-
<line>1345</line>
6+
<line>468</line>
7+
<line>632</line>
8+
<line>1349</line>
99
</file>
1010
</editor-bookmarks>
1111
</project-private>

src/nsl/Tokenizer.java

+14-26
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public class Tokenizer extends StreamTokenizer
1717
private final Reader theReader;
1818
private final String source;
1919

20-
private int prevLineNo;
2120
private int lineNumberAdd;
2221
private boolean autoPop;
2322

@@ -52,7 +51,6 @@ public Tokenizer(Reader reader, String source)
5251
this.theReader = reader;
5352
this.source = source;
5453

55-
this.prevLineNo = 0;
5654
this.lineNumberAdd = 0;
5755
this.autoPop = true;
5856
}
@@ -75,15 +73,6 @@ public String getSource()
7573
return this.source;
7674
}
7775

78-
/**
79-
* Gets the line number that a token was read from previously.
80-
* @return the line number that a token was read from previously
81-
*/
82-
public int linenoprev()
83-
{
84-
return this.prevLineNo;
85-
}
86-
8776
/**
8877
* Returns the current line number.
8978
* @return the current line number
@@ -226,7 +215,7 @@ public String readUntil(String match)
226215
* Gets the next token.
227216
* @return <code>true</code> if there was another token
228217
*/
229-
public boolean tokenNext() throws NslExpectedException, NslException
218+
public boolean tokenNext()
230219
{
231220
return this.tokenNext(null);
232221
}
@@ -236,9 +225,8 @@ public boolean tokenNext() throws NslExpectedException, NslException
236225
* @param expected the message of the exception to throw if no token exists
237226
* @return <code>true</code> if there was another token
238227
*/
239-
public boolean tokenNext(String expected) throws NslExpectedException, NslException
228+
public boolean tokenNext(String expected)
240229
{
241-
this.prevLineNo = lineno();
242230
try
243231
{
244232
boolean result = this.nextToken() != TT_EOF;
@@ -310,7 +298,7 @@ public boolean tokenNext(String expected) throws NslExpectedException, NslExcept
310298
* Returns the current token as a string.
311299
* @return the current token as a string
312300
*/
313-
public String tokenToString()
301+
/*public String tokenToString()
314302
{
315303
if (this.tokenIsWord())
316304
return this.sval;
@@ -319,13 +307,13 @@ public String tokenToString()
319307
if (this.tokenIsString())
320308
return '"' + this.sval + '"';
321309
return Character.toString((char)this.ttype);
322-
}
310+
}*/
323311

324312
/**
325313
* Matches the given character and prints an error otherwise.
326314
* @param c the character to match
327315
*/
328-
public void matchOrDie(char c) throws NslExpectedException, NslException
316+
public void matchOrDie(char c)
329317
{
330318
if (!this.tokenIs(c))
331319
throw new NslExpectedException("\"" + c + "\"");
@@ -336,7 +324,7 @@ public void matchOrDie(char c) throws NslExpectedException, NslException
336324
* Matches the given word and prints an error otherwise.
337325
* @param word the word to match
338326
*/
339-
public void matchOrDie(String word) throws NslExpectedException, NslException
327+
public void matchOrDie(String word)
340328
{
341329
if (!this.tokenIs(word))
342330
throw new NslExpectedException("\"" + word + "\"");
@@ -348,7 +336,7 @@ public void matchOrDie(String word) throws NslExpectedException, NslException
348336
* @param c the character to match
349337
* @return <code>true</code> on success
350338
*/
351-
public boolean match(char c) throws NslException
339+
public boolean match(char c)
352340
{
353341
if (this.tokenIs(c))
354342
{
@@ -363,7 +351,7 @@ public boolean match(char c) throws NslException
363351
* @param word the word to match
364352
* @return <code>true</code> on success
365353
*/
366-
public boolean match(String word) throws NslException
354+
public boolean match(String word)
367355
{
368356
if (this.tokenIs(word))
369357
{
@@ -377,9 +365,9 @@ public boolean match(String word) throws NslException
377365
* Matches a semicolon on the end of the current line or prints an error
378366
* otherwise.
379367
*/
380-
public void matchEolOrDie() throws NslExpectedException, NslException
368+
public void matchEolOrDie()
381369
{
382-
if (!this.tokenIs(';') || this.lineno() != this.prevLineNo)
370+
if (!this.tokenIs(';'))
383371
throw new NslExpectedException("\";\"");
384372
this.tokenNext();
385373
}
@@ -389,7 +377,7 @@ public void matchEolOrDie() throws NslExpectedException, NslException
389377
* @return the word if the current token was a word, or <code>null</code>
390378
* otherwise
391379
*/
392-
public String matchAWord() throws NslException
380+
public String matchAWord()
393381
{
394382
return this.matchAWord(null);
395383
}
@@ -400,7 +388,7 @@ public String matchAWord() throws NslException
400388
* @return the word if the current token was a word, or <code>null</code>
401389
* otherwise
402390
*/
403-
public String matchAWord(String expected) throws NslException
391+
public String matchAWord(String expected)
404392
{
405393
if (this.tokenIsWord())
406394
{
@@ -418,7 +406,7 @@ public String matchAWord(String expected) throws NslException
418406
* @return the string if the current token was a string, or <code>null</code>
419407
* otherwise
420408
*/
421-
public String matchAString() throws NslException
409+
public String matchAString()
422410
{
423411
return this.matchAString(null);
424412
}
@@ -429,7 +417,7 @@ public String matchAString() throws NslException
429417
* @return the string if the current token was a string, or <code>null</code>
430418
* otherwise
431419
*/
432-
public String matchAString(String expected) throws NslException
420+
public String matchAString(String expected)
433421
{
434422
if (this.tokenIsString())
435423
{

src/nsl/expression/BooleanExpression.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected BooleanExpression()
2929
*/
3030
public BooleanExpression(Expression leftOperand, String operator, Expression rightOperand)
3131
{
32-
super(leftOperand, new Operator(operator, OperatorType.Mathematical), rightOperand);
32+
super(leftOperand, operator, rightOperand);
3333

3434
if (!isBooleanExpression(leftOperand))
3535
throw new NslException("The left operand must be an equality or relational expression", true);
@@ -106,7 +106,7 @@ public void assemble(Label gotoA, Label gotoB) throws IOException
106106

107107
if (this.leftOperand instanceof ComparisonExpression && this.rightOperand instanceof ComparisonExpression)
108108
{
109-
if (this.operator.getOperator().equals("&&"))
109+
if (this.operator.equals("&&"))
110110
{
111111
((ConditionalExpression)this.leftOperand).assemble(RelativeJump.Zero, gotoB);
112112
((ConditionalExpression)this.rightOperand).assemble(gotoA, gotoB);
@@ -119,7 +119,7 @@ public void assemble(Label gotoA, Label gotoB) throws IOException
119119
}
120120
else if (this.leftOperand instanceof ComparisonExpression)
121121
{
122-
if (this.operator.getOperator().equals("&&"))
122+
if (this.operator.equals("&&"))
123123
{
124124
((ConditionalExpression)this.leftOperand).assemble(RelativeJump.Zero, gotoB);
125125
assemble(this.rightOperand, gotoA, gotoB);
@@ -132,7 +132,7 @@ else if (this.leftOperand instanceof ComparisonExpression)
132132
}
133133
else if (this.rightOperand instanceof ComparisonExpression)
134134
{
135-
if (this.operator.getOperator().equals("&&"))
135+
if (this.operator.equals("&&"))
136136
{
137137
Label gotoC = LabelList.getCurrent().getNext();
138138
assemble(this.leftOperand, gotoC, gotoB);
@@ -149,7 +149,7 @@ else if (this.rightOperand instanceof ComparisonExpression)
149149
}
150150
else
151151
{
152-
if (this.operator.getOperator().equals("&&"))
152+
if (this.operator.equals("&&"))
153153
{
154154
Label gotoC = LabelList.getCurrent().getNext();
155155
assemble(this.leftOperand, gotoC, gotoB);

src/nsl/expression/ComparisonExpression.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ComparisonExpression extends ConditionalExpression
2424
*/
2525
public ComparisonExpression(Expression leftOperand, String operator, Expression rightOperand, ComparisonType comparisonType)
2626
{
27-
super(leftOperand, new Operator(operator, OperatorType.Mathematical), rightOperand);
27+
super(leftOperand, operator, rightOperand);
2828
this.comparisonType = comparisonType;
2929
}
3030

@@ -142,27 +142,27 @@ public void assemble(Label gotoA, Label gotoB) throws IOException
142142
Register varRight = RegisterList.getCurrent().getNext();
143143
((AssembleExpression)this.leftOperand).assemble(varLeft);
144144
((AssembleExpression)this.rightOperand).assemble(varRight);
145-
assembleCmp(varLeft.toString(), this.operator.getOperator(), varRight.toString(), gotoA, gotoB, this.comparisonType);
145+
assembleCmp(varLeft.toString(), this.operator, varRight.toString(), gotoA, gotoB, this.comparisonType);
146146
varRight.setInUse(false);
147147
varLeft.setInUse(false);
148148
}
149149
else if (this.leftOperand instanceof AssembleExpression)
150150
{
151151
Register varLeft = RegisterList.getCurrent().getNext();
152152
((AssembleExpression)this.leftOperand).assemble(varLeft);
153-
assembleCmp(varLeft.toString(), this.operator.getOperator(), this.rightOperand.toString(), gotoA, gotoB, this.comparisonType);
153+
assembleCmp(varLeft.toString(), this.operator, this.rightOperand.toString(), gotoA, gotoB, this.comparisonType);
154154
varLeft.setInUse(false);
155155
}
156156
else if (this.rightOperand instanceof AssembleExpression)
157157
{
158158
Register varRight = RegisterList.getCurrent().getNext();
159159
((AssembleExpression)this.rightOperand).assemble(varRight);
160-
assembleCmp(this.leftOperand.toString(), this.operator.getOperator(), varRight.toString(), gotoA, gotoB, this.comparisonType);
160+
assembleCmp(this.leftOperand.toString(), this.operator, varRight.toString(), gotoA, gotoB, this.comparisonType);
161161
varRight.setInUse(false);
162162
}
163163
else
164164
{
165-
assembleCmp(this.leftOperand.toString(), this.operator.getOperator(), this.rightOperand.toString(), gotoA, gotoB, this.comparisonType);
165+
assembleCmp(this.leftOperand.toString(), this.operator, this.rightOperand.toString(), gotoA, gotoB, this.comparisonType);
166166
}
167167
}
168168
}

src/nsl/expression/ConcatenationExpression.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected ConcatenationExpression()
2828
*/
2929
public ConcatenationExpression(Expression leftOperand, Expression rightOperand)
3030
{
31-
super(leftOperand, new Operator(".", OperatorType.Mathematical), rightOperand);
31+
super(leftOperand, ".", rightOperand);
3232

3333
if (leftOperand.type.equals(ExpressionType.StringSpecial) || rightOperand.type.equals(ExpressionType.StringSpecial))
3434
this.type = ExpressionType.StringSpecial;

src/nsl/expression/ConditionalExpression.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class ConditionalExpression extends LogicalExpression
1919
* @param operator the operator
2020
* @param rightOperand the right operand
2121
*/
22-
public ConditionalExpression(Expression leftOperand, Operator operator, Expression rightOperand)
22+
public ConditionalExpression(Expression leftOperand, String operator, Expression rightOperand)
2323
{
2424
super(leftOperand, operator, rightOperand);
2525
this.type = ExpressionType.Boolean;

src/nsl/expression/Expression.java

+15-11
Original file line numberDiff line numberDiff line change
@@ -406,29 +406,33 @@ else if (ExpressionType.isString(left) && ExpressionType.isString(right))
406406
}
407407
else if (ExpressionType.isBoolean(left))
408408
{
409-
if (operator.equals("==") && left.booleanValue == false && right.type == ExpressionType.Boolean)
409+
if (operator.equals("==") && right.type == ExpressionType.Boolean)
410410
{
411-
right.booleanValue = !right.booleanValue;
412-
return left;
411+
if (left.booleanValue == false)
412+
right.booleanValue = !right.booleanValue;
413+
return right;
413414
}
414-
if (operator.equals("!=") && left.booleanValue == true && right.type == ExpressionType.Boolean)
415+
if (operator.equals("!=") && right.type == ExpressionType.Boolean)
415416
{
416-
right.booleanValue = !right.booleanValue;
417-
return left;
417+
if (left.booleanValue == true)
418+
right.booleanValue = !right.booleanValue;
419+
return right;
418420
}
419421
comparisonType = ComparisonType.String;
420422
}
421423
else if (ExpressionType.isBoolean(right))
422424
{
423-
if (operator.equals("==") && right.booleanValue == false && left.type == ExpressionType.Boolean)
425+
if (operator.equals("==") && left.type == ExpressionType.Boolean)
424426
{
425-
left.booleanValue = !left.booleanValue;
427+
if (right.booleanValue == false)
428+
left.booleanValue = !left.booleanValue;
426429
return left;
427430
}
428-
if (operator.equals("!=") && right.booleanValue == true && left.type == ExpressionType.Boolean)
431+
if (operator.equals("!=") && left.type == ExpressionType.Boolean)
429432
{
430-
left.booleanValue = !left.booleanValue;
431-
return right;
433+
if (right.booleanValue == true)
434+
left.booleanValue = !left.booleanValue;
435+
return left;
432436
}
433437
comparisonType = ComparisonType.String;
434438
}

0 commit comments

Comments
 (0)