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