mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-01 03:41:29 +00:00
moved string handling to SubLine
This commit is contained in:
parent
7d8c1641e9
commit
301b6c27c4
|
@ -86,6 +86,11 @@ public class ApplesoftBasicProgram extends BasicProgram implements ApplesoftCons
|
||||||
addNumberFloat (line.lineNumber, num, constantsFloat);
|
addNumberFloat (line.lineNumber, num, constantsFloat);
|
||||||
if (subline.callTarget != null)
|
if (subline.callTarget != null)
|
||||||
addString (line.lineNumber, subline.callTarget, callLines);
|
addString (line.lineNumber, subline.callTarget, callLines);
|
||||||
|
for (String s : subline.getStringsText ())
|
||||||
|
{
|
||||||
|
stringsText.add (s);
|
||||||
|
stringsLine.add (line.lineNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endPtr = ptr;
|
endPtr = ptr;
|
||||||
|
|
|
@ -31,7 +31,6 @@ public class SourceLine implements ApplesoftConstants
|
||||||
boolean inString = false; // can toggle
|
boolean inString = false; // can toggle
|
||||||
boolean inRemark = false; // can only go false -> true
|
boolean inRemark = false; // can only go false -> true
|
||||||
byte b;
|
byte b;
|
||||||
int stringPtr = 0;
|
|
||||||
|
|
||||||
while (ptr < buffer.length && (b = buffer[ptr++]) != 0)
|
while (ptr < buffer.length && (b = buffer[ptr++]) != 0)
|
||||||
{
|
{
|
||||||
|
@ -41,12 +40,7 @@ public class SourceLine implements ApplesoftConstants
|
||||||
if (inString)
|
if (inString)
|
||||||
{
|
{
|
||||||
if (b == Utility.ASCII_QUOTE) // terminate string
|
if (b == Utility.ASCII_QUOTE) // terminate string
|
||||||
{
|
|
||||||
inString = false;
|
inString = false;
|
||||||
String s = new String (buffer, stringPtr - 1, ptr - stringPtr + 1);
|
|
||||||
parent.stringsText.add (s);
|
|
||||||
parent.stringsLine.add (lineNumber);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +83,6 @@ public class SourceLine implements ApplesoftConstants
|
||||||
|
|
||||||
case Utility.ASCII_QUOTE:
|
case Utility.ASCII_QUOTE:
|
||||||
inString = true;
|
inString = true;
|
||||||
stringPtr = ptr;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,16 @@ public class SubLine implements ApplesoftConstants
|
||||||
|
|
||||||
private final List<Integer> gotoLines = new ArrayList<> ();
|
private final List<Integer> gotoLines = new ArrayList<> ();
|
||||||
private final List<Integer> gosubLines = new ArrayList<> ();
|
private final List<Integer> gosubLines = new ArrayList<> ();
|
||||||
|
|
||||||
private final List<String> symbols = new ArrayList<> ();
|
private final List<String> symbols = new ArrayList<> ();
|
||||||
private final List<String> functions = new ArrayList<> ();
|
private final List<String> functions = new ArrayList<> ();
|
||||||
private final List<String> arrays = new ArrayList<> ();
|
private final List<String> arrays = new ArrayList<> ();
|
||||||
|
|
||||||
private final List<Integer> constantsInt = new ArrayList<> ();
|
private final List<Integer> constantsInt = new ArrayList<> ();
|
||||||
private final List<Float> constantsFloat = new ArrayList<> ();
|
private final List<Float> constantsFloat = new ArrayList<> ();
|
||||||
|
|
||||||
|
private final List<String> stringsText = new ArrayList<> ();
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
SubLine (SourceLine parent, int startPtr, int length)
|
SubLine (SourceLine parent, int startPtr, int length)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -69,6 +73,7 @@ public class SubLine implements ApplesoftConstants
|
||||||
boolean inQuote = false;
|
boolean inQuote = false;
|
||||||
boolean inFunction = false;
|
boolean inFunction = false;
|
||||||
boolean inDefine = false;
|
boolean inDefine = false;
|
||||||
|
int stringPtr = 0;
|
||||||
|
|
||||||
int max = startPtr + length - 1;
|
int max = startPtr + length - 1;
|
||||||
if (buffer[max] == 0 || buffer[max] == Utility.ASCII_COLON)
|
if (buffer[max] == 0 || buffer[max] == Utility.ASCII_COLON)
|
||||||
|
@ -101,13 +106,18 @@ public class SubLine implements ApplesoftConstants
|
||||||
if (inQuote)
|
if (inQuote)
|
||||||
{
|
{
|
||||||
if (b == Utility.ASCII_QUOTE) // ignore strings
|
if (b == Utility.ASCII_QUOTE) // ignore strings
|
||||||
|
{
|
||||||
inQuote = false;
|
inQuote = false;
|
||||||
|
String s = new String (buffer, stringPtr - 1, ptr - stringPtr + 1);
|
||||||
|
stringsText.add (s);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b == Utility.ASCII_QUOTE)
|
if (b == Utility.ASCII_QUOTE)
|
||||||
{
|
{
|
||||||
inQuote = true;
|
inQuote = true;
|
||||||
|
stringPtr = ptr;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +240,13 @@ public class SubLine implements ApplesoftConstants
|
||||||
return constantsFloat;
|
return constantsFloat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
List<String> getStringsText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return stringsText;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private void doToken (byte b)
|
private void doToken (byte b)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -324,12 +341,9 @@ public class SubLine implements ApplesoftConstants
|
||||||
b = (byte) chunk.charAt (0);
|
b = (byte) chunk.charAt (0);
|
||||||
if (Utility.isDigit (b) || b == Utility.ASCII_MINUS || b == Utility.ASCII_DOT)
|
if (Utility.isDigit (b) || b == Utility.ASCII_MINUS || b == Utility.ASCII_DOT)
|
||||||
addNumber (chunk);
|
addNumber (chunk);
|
||||||
else if (Utility.isLetter (b)) // quoted strings are already handled
|
else if (Utility.isLetter (b) || b == Utility.ASCII_QUOTE)
|
||||||
{
|
stringsText.add (chunk);
|
||||||
parent.parent.stringsText.add (chunk);
|
else
|
||||||
parent.parent.stringsLine.add (parent.lineNumber);
|
|
||||||
}
|
|
||||||
else if (b != Utility.ASCII_QUOTE)
|
|
||||||
System.out.println ("Unknown data: " + chunk);
|
System.out.println ("Unknown data: " + chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,8 +97,8 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
private final List<TextPreferencesListener> textPreferencesListeners =
|
private final List<TextPreferencesListener> textPreferencesListeners =
|
||||||
new ArrayList<> ();
|
new ArrayList<> ();
|
||||||
|
|
||||||
private List<JCheckBoxMenuItem> applesoftFormatItems;
|
private List<JMenuItem> applesoftFormatItems;
|
||||||
private List<JCheckBoxMenuItem> applesoftXrefItems;
|
private List<JMenuItem> applesoftXrefItems;
|
||||||
|
|
||||||
JMenuBar menuBar = new JMenuBar ();
|
JMenuBar menuBar = new JMenuBar ();
|
||||||
JMenu fileMenu = new JMenu ("File");
|
JMenu fileMenu = new JMenu ("File");
|
||||||
|
@ -289,15 +289,13 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||||
|
|
||||||
prodosMenu.add (prodosSortDirectoriesItem);
|
prodosMenu.add (prodosSortDirectoriesItem);
|
||||||
|
|
||||||
applesoftFormatItems = new ArrayList (Arrays.asList (splitRemarkItem, splitDimItem,
|
applesoftFormatItems = new ArrayList<> (Arrays.asList (splitRemarkItem, splitDimItem,
|
||||||
alignAssignItem, showBasicTargetsItem, onlyShowTargetLinesItem, showCaretItem,
|
alignAssignItem, showBasicTargetsItem, onlyShowTargetLinesItem, showCaretItem,
|
||||||
showThenItem, blankAfterReturn, deleteExtraRemSpace, deleteExtraDataSpace));
|
showThenItem, blankAfterReturn, deleteExtraRemSpace, deleteExtraDataSpace));
|
||||||
|
|
||||||
applesoftXrefItems = new ArrayList (Arrays.asList (showXrefItem, showCallsItem,
|
applesoftXrefItems = new ArrayList<> (Arrays.asList (showXrefItem, showCallsItem,
|
||||||
showSymbolsItem, showFunctionsItem, showConstantsItem, showDuplicateSymbolsItem));
|
showSymbolsItem, showFunctionsItem, showConstantsItem, showDuplicateSymbolsItem));
|
||||||
|
|
||||||
List<Integer> anotherList = Arrays.asList (5, 12, 9, 3, 15, 88);
|
|
||||||
|
|
||||||
ActionListener basicPreferencesAction = new ActionListener ()
|
ActionListener basicPreferencesAction = new ActionListener ()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user