Skip to content

Commit 96ff1a7

Browse files
committed
restore v1.0.1
1 parent 34d85d6 commit 96ff1a7

File tree

7 files changed

+114
-33
lines changed

7 files changed

+114
-33
lines changed

Reference.docx

40.6 KB
Binary file not shown.

docs/Reference.pdf

1.3 KB
Binary file not shown.

examples/Install.nsl

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Name("nsL Assembler");
2-
OutFile("nsL-Assembler-1.0.0.exe");
1+
#define Version '1.0.1'
2+
3+
Name("nsL Assembler ".Version." (Alpha)");
4+
OutFile("nsL-Assembler-".Version.".exe");
35
XPStyle("on");
46
SetCompressor("lzma", true);
57
RequestExecutionLevel("admin");
@@ -13,7 +15,7 @@ uninstall page InstFiles();
1315

1416
function .onInit()
1517
{
16-
$INSTDIR = ReadRegStr("HKLM", "Software\\NSIS", "");
18+
$INSTDIR = ReadRegStr("HKLM", @"Software\NSIS", "");
1719
if (StrCmp($INSTDIR, ""))
1820
{
1921
MessageBox("MB_OK|MB_ICONEXCLAMATION", "NSIS is not installed on this machine. Setup will now exit.");
@@ -25,35 +27,35 @@ section Install("nsL Assembler", true)
2527
{
2628
// Extract the main JAR file.
2729
SetOutPath($INSTDIR."\\NSL");
28-
File("..\\dist\\nsL.jar");
30+
File(@"..\dist\nsL.jar");
2931

3032
// Extract documents.
3133
SetOutPath($INSTDIR."\\Docs\\NSL");
32-
File("..\\..\\Reference.pdf");
33-
File("..\\..\\functions.txt");
34+
File(@"..\..\Reference.pdf");
35+
File(@"..\..\functions.txt");
3436

3537
// Add the right click "Compile nsL Script" option.
3638
WriteRegStr("HKCR", ".nsl", "", "nsL.Script");
3739
WriteRegStr("HKCR", "nsL.Script", "", "nsL Script File");
38-
WriteRegStr("HKCR", "nsL.Script\\DefaultIcon", "", $INSTDIR."\\makensisw.exe,1");
39-
WriteRegStr("HKCR", "nsL.Script\\shell", "", "open");
40-
WriteRegStr("HKCR", "nsL.Script\\shell\\open\\command", "", 'notepad.exe "%1"');
41-
WriteRegStr("HKCR", "nsL.Script\\shell\\compile", "", "Compile nsL Script");
42-
WriteRegStr("HKCR", "nsL.Script\\shell\\compile\\command", "", '"'.$INSTDIR.'\\NSL\\nsL.bat" "%1"');
40+
WriteRegStr("HKCR", @"nsL.Script\DefaultIcon", "", $INSTDIR.@"\makensisw.exe,1");
41+
WriteRegStr("HKCR", @"nsL.Script\shell", "", "open");
42+
WriteRegStr("HKCR", @"nsL.Script\shell\open\command", "", 'notepad.exe "%1"');
43+
WriteRegStr("HKCR", @"nsL.Script\shell\compile", "", "Compile nsL Script");
44+
WriteRegStr("HKCR", @"nsL.Script\shell\compile\command", "", '"'.$INSTDIR.@'\NSL\nsL.bat" "%1"');
4345

4446
// Write our batch file that runs scripts.
4547
ClearErrors();
46-
$R0 = FileOpen($INSTDIR."\\NSL\\nsL.bat", "w");
48+
$R0 = FileOpen($INSTDIR.@"\NSL\nsL.bat", "w");
4749
if (!Errors())
4850
{
4951
FileWrite($R0, "cd %~dp0\r\n");
5052
FileWrite($R0, "java.exe -jar nsL.jar %1\r\n");
5153
FileClose($R0);
5254
}
53-
DetailPrint("Wrote: ".$INSTDIR."\\NSL\\nsL.bat");
55+
DetailPrint("Wrote: ".$INSTDIR.@"\NSL\nsL.bat");
5456

5557
// Output the uninstall executable.
56-
WriteUninstaller($INSTDIR."\\NSL\\Uninstall.exe");
58+
WriteUninstaller($INSTDIR.@"\NSL\Uninstall.exe");
5759

5860
// Refresh Windows Explorer.
5961
#define SHCNE_ASSOCCHANGED 0x8000000
@@ -64,18 +66,18 @@ section Install("nsL Assembler", true)
6466
section Examples("Example Scripts")
6567
{
6668
SetOutPath($INSTDIR."\\Examples\\NSL");
67-
FileRecursive("..\\examples\\*.nsl");
69+
FileRecursive(@"..\examples\*.nsl");
6870
}
6971

7072
section Source("Java Source Code", false, true)
7173
{
72-
SetOutPath($INSTDIR."\\NSL\\src");
73-
FileRecursive("..\\nbproject");
74-
FileRecursive("..\\src");
75-
FileRecursive("..\\test");
76-
File("..\\build.xml");
77-
File("..\\manifest.mf");
78-
File("..\\..\\Reference.docx");
74+
SetOutPath($INSTDIR.@"\NSL\src");
75+
FileRecursive(@"..\nbproject");
76+
FileRecursive(@"..\src");
77+
FileRecursive(@"..\test");
78+
File(@"..\build.xml");
79+
File(@"..\manifest.mf");
80+
File(@"..\..\Reference.docx");
7981
}
8082

8183
uninstall function .onInit()
@@ -91,7 +93,7 @@ uninstall function .onInit()
9193
uninstall section Uninstall()
9294
{
9395
// Remove our files.
94-
RMDirRecursive($INSTDIR."\\..\\Docs\\NSL");
96+
RMDirRecursive($INSTDIR.@"\..\Docs\NSL");
9597
RMDirRecursive($INSTDIR);
9698

9799
// Delete our Windows registry entries.

examples/ModernUI.nsl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
OutFile("ModernUI.exe");
2+
3+
#nsis
4+
5+
!include MUI2.nsh
6+
7+
!insertmacro MUI_PAGE_WELCOME
8+
!insertmacro MUI_PAGE_COMPONENTS
9+
!insertmacro MUI_PAGE_DIRECTORY
10+
!insertmacro MUI_PAGE_INSTFILES
11+
!insertmacro MUI_PAGE_FINISH
12+
13+
!insertmacro MUI_LANGUAGE English
14+
15+
#nsisend
16+
17+
section Section1("Section 1")
18+
{
19+
20+
}
21+
22+
section Section2("Section 2")
23+
{
24+
25+
}
26+
27+
section Section3("Section 3")
28+
{
29+
30+
}
31+
32+
#nsis
33+
34+
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
35+
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} "This is section 1; it does nothing really"
36+
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} "This is section 2; this is empty too"
37+
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} "This is section 3; so is this"
38+
!insertmacro MUI_FUNCTION_DESCRIPTION_END
39+
40+
#nsisend

src/nsl/Tokenizer.java

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,17 @@ public String readUntil(String match)
172172
String text = "";
173173
try
174174
{
175-
int b, c = 0;
176-
while ((b = this.theReader.read()) != -1)
175+
int c = 0;
176+
while (true)
177177
{
178+
int b = this.theReader.read();
179+
180+
if (b == -1)
181+
{
182+
this.ttype = TT_EOF;
183+
throw new NslExpectedException(match);
184+
}
185+
178186
if (b == '\r')
179187
{
180188
this.lineNumberAdd++;
@@ -183,6 +191,7 @@ public String readUntil(String match)
183191
b = this.theReader.read();
184192
continue;
185193
}
194+
186195
if (b == '\n')
187196
{
188197
this.lineNumberAdd++;
@@ -196,7 +205,7 @@ public String readUntil(String match)
196205
c++;
197206
if (c == matchChars.length)
198207
{
199-
text = text.substring(0, text.length() - matchChars.length);
208+
text = text.substring(0, text.length() - matchChars.length + 1);
200209
break;
201210
}
202211
}
@@ -205,8 +214,6 @@ public String readUntil(String match)
205214

206215
text += (char)b;
207216
}
208-
209-
ScriptParser.tokenizer.tokenNext();
210217
}
211218
catch (IOException ex)
212219
{
@@ -252,17 +259,45 @@ public boolean tokenNext(String expected) throws NslExpectedException, NslExcept
252259
{
253260
this.ttype = TT_NUMBER;
254261

255-
if (this.sval.length() > 1 && this.sval.charAt(1) == 'x')
262+
try
256263
{
257-
this.nval = Integer.parseInt(this.sval.substring(2), 16);
264+
if (this.sval.length() > 1 && this.sval.startsWith("0x"))
265+
{
266+
this.nval = Integer.parseInt(this.sval.substring(2), 16);
267+
}
268+
else
269+
{
270+
this.nval = Integer.parseInt(this.sval);
271+
}
258272
}
259-
else
273+
catch (NumberFormatException ex)
260274
{
261-
this.nval = Integer.parseInt(this.sval);
275+
throw new NslException(ex.getMessage(), true);
262276
}
263277
}
264278
}
265279

280+
// String with no escape sequences.
281+
if (this.ttype == '@')
282+
{
283+
int b = this.theReader.read();
284+
285+
if (b == -1)
286+
{
287+
this.ttype = TT_EOF;
288+
throw new NslExpectedException("a string");
289+
}
290+
291+
this.ttype = (char)b;
292+
293+
if (b != '"' && b != '\'' && b != '`')
294+
{
295+
throw new NslExpectedException("a string");
296+
}
297+
298+
this.sval = readUntil(String.valueOf((char)b));
299+
}
300+
266301
return result;
267302
}
268303
catch (IOException ex)

src/nsl/preprocessor/MacroDirective.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ public MacroDirective()
4444
ScriptParser.tokenizer.matchOrDie(',');
4545
}
4646
}
47+
48+
String contents = ScriptParser.tokenizer.readUntil("#macroend");
49+
ScriptParser.tokenizer.tokenNext();
4750

48-
if (!MacroList.getCurrent().add(new Macro(name, paramsList.toArray(new String[0]), macroLine, ScriptParser.tokenizer.readUntil("#macroend"))))
51+
if (!MacroList.getCurrent().add(new Macro(name, paramsList.toArray(new String[0]), macroLine, contents)))
4952
throw new NslException("Macro \"" + name + "\" already defined with " + paramsList.size() + " parameters", macroLine);
5053
}
5154

src/nsl/preprocessor/NSISDirective.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class NSISDirective extends Statement
2525
public NSISDirective()
2626
{
2727
this.nsis = ScriptParser.tokenizer.readUntil("#nsisend");
28+
ScriptParser.tokenizer.tokenNext();
2829

2930
this.macroEvaluated = MacroEvaluated.getCurrent();
3031
if (this.macroEvaluated != null)

0 commit comments

Comments
 (0)