Fixed quoting in parser

This commit is contained in:
Gideon le Grange 2014-04-14 20:16:55 +02:00
parent 11e9a5805e
commit 15c48def68
2 changed files with 6 additions and 4 deletions

View File

@ -18,7 +18,7 @@ public class Example6 extends Example {
private void test() throws MikrotikApiException, InterruptedException { private void test() throws MikrotikApiException, InterruptedException {
System.out.println("Creating interface gre1"); System.out.println("Creating interface gre1");
con.execute("/interface/gre/add remote-address=1.2.3.4 name=gre1 keepalive=10 comment=\"test comment\""); con.execute("/interface/gre/add remote-address=1.2.3.4 name=gre1 keepalive=10 comment='test comment'");
System.out.println("Adding firewall rule for interface gre1"); System.out.println("Adding firewall rule for interface gre1");
con.execute("/ip/firewall/filter/add action=drop chain=forward in-interface=gre1 protocol=udp dst-port=78,80");//,80,32"); con.execute("/ip/firewall/filter/add action=drop chain=forward in-interface=gre1 protocol=udp dst-port=78,80");//,80,32");
System.out.println("Waiting 10 seconds"); System.out.println("Waiting 10 seconds");

View File

@ -74,7 +74,9 @@ class Scanner {
nextChar(); nextChar();
return Token.EQUALS; return Token.EQUALS;
case '"' : case '"' :
return quotedText(); return quotedText('"');
case '\'' :
return quotedText('\'');
default : default :
return name(); return name();
} }
@ -109,10 +111,10 @@ class Scanner {
} }
/** process quoted text */ /** process quoted text */
private Token quotedText() throws ScanException { private Token quotedText(char quote) throws ScanException {
nextChar(); // eat the '"' nextChar(); // eat the '"'
text = new StringBuilder(); text = new StringBuilder();
while (c != '"') { while (c != quote) {
if (c == '\n') { if (c == '\n') {
throw new ScanException("Unclosed quoted text, reached end of line."); throw new ScanException("Unclosed quoted text, reached end of line.");
} }