mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 23:45:17 -04:00
better test data parser to allow multi row repeats
This commit is contained in:
parent
d3110c699b
commit
3d6000abe6
@ -1470,7 +1470,7 @@ loop(n,16)
|
|||||||
bits(4,n) 0 1 0
|
bits(4,n) 0 1 0
|
||||||
bits(4,n) 1 1 1
|
bits(4,n) 1 1 1
|
||||||
bits(4,n) 0 1 1
|
bits(4,n) 0 1 1
|
||||||
endloop
|
end loop
|
||||||
|
|
||||||
# check all cells are one
|
# check all cells are one
|
||||||
repeat(16) bits(4,n) 0 x 1
|
repeat(16) bits(4,n) 0 x 1
|
||||||
@ -1480,7 +1480,7 @@ loop(n,16)
|
|||||||
bits(4,n) 0 0 1
|
bits(4,n) 0 0 1
|
||||||
bits(4,n) 1 0 0
|
bits(4,n) 1 0 0
|
||||||
bits(4,n) 0 0 0
|
bits(4,n) 0 0 0
|
||||||
endloop
|
end loop
|
||||||
|
|
||||||
# check all cells are zero
|
# check all cells are zero
|
||||||
repeat(16) bits(4,n) 0 x 0
|
repeat(16) bits(4,n) 0 x 0
|
||||||
|
@ -84,8 +84,11 @@ public class Parser {
|
|||||||
list.add(parseLine());
|
list.add(parseLine());
|
||||||
break;
|
break;
|
||||||
case IDENT:
|
case IDENT:
|
||||||
if (tok.getIdent().equals("endloop")) {
|
if (tok.getIdent().equals("end")) {
|
||||||
tok.consume();
|
tok.consume();
|
||||||
|
expect(Tokenizer.Token.IDENT);
|
||||||
|
if (!tok.getIdent().equals("loop"))
|
||||||
|
throw newUnexpectedToken(t);
|
||||||
if (!loop)
|
if (!loop)
|
||||||
throw newUnexpectedToken(t);
|
throw newUnexpectedToken(t);
|
||||||
return list.minimize();
|
return list.minimize();
|
||||||
|
@ -11,7 +11,7 @@ import java.io.IOException;
|
|||||||
public class ParserLoopTest extends TestCase {
|
public class ParserLoopTest extends TestCase {
|
||||||
|
|
||||||
public void testLoop() throws IOException, ParserException {
|
public void testLoop() throws IOException, ParserException {
|
||||||
Parser parser = new Parser("A B\nloop(n,10)\n C (n*2)\nendloop").parse();
|
Parser parser = new Parser("A B\nloop(n,10)\n C (n*2)\nend loop").parse();
|
||||||
LineCollector td = new LineCollector(parser);
|
LineCollector td = new LineCollector(parser);
|
||||||
|
|
||||||
assertEquals(2, td.getNames().size());
|
assertEquals(2, td.getNames().size());
|
||||||
@ -24,7 +24,7 @@ public class ParserLoopTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testLoopVar() throws IOException, ParserException {
|
public void testLoopVar() throws IOException, ParserException {
|
||||||
Parser parser = new Parser("A B\nloop(i,10)\n C (i*2)\nendloop").parse();
|
Parser parser = new Parser("A B\nloop(i,10)\n C (i*2)\nend loop").parse();
|
||||||
LineCollector td = new LineCollector(parser);
|
LineCollector td = new LineCollector(parser);
|
||||||
|
|
||||||
assertEquals(2, td.getNames().size());
|
assertEquals(2, td.getNames().size());
|
||||||
@ -37,7 +37,7 @@ public class ParserLoopTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testNested() throws IOException, ParserException {
|
public void testNested() throws IOException, ParserException {
|
||||||
Parser parser = new Parser("A B\nloop(i,10)\nloop(j,10)\n C ((i+j)*2)\nendloop\nendloop").parse();
|
Parser parser = new Parser("A B\nloop(i,10)\nloop(j,10)\n C ((i+j)*2)\nend loop\nend loop").parse();
|
||||||
LineCollector td = new LineCollector(parser);
|
LineCollector td = new LineCollector(parser);
|
||||||
|
|
||||||
assertEquals(2, td.getNames().size());
|
assertEquals(2, td.getNames().size());
|
||||||
@ -53,7 +53,7 @@ public class ParserLoopTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testLoopMultiLines() throws IOException, ParserException {
|
public void testLoopMultiLines() throws IOException, ParserException {
|
||||||
Parser parser = new Parser("A B\nloop(i,10)\n C (i*2)\n C (i*2+1)\nendloop").parse();
|
Parser parser = new Parser("A B\nloop(i,10)\n C (i*2)\n C (i*2+1)\nend loop").parse();
|
||||||
LineCollector td = new LineCollector(parser);
|
LineCollector td = new LineCollector(parser);
|
||||||
|
|
||||||
assertEquals(2, td.getNames().size());
|
assertEquals(2, td.getNames().size());
|
||||||
@ -77,7 +77,7 @@ public class ParserLoopTest extends TestCase {
|
|||||||
|
|
||||||
public void testUnexpectedEndloop() throws IOException, ParserException {
|
public void testUnexpectedEndloop() throws IOException, ParserException {
|
||||||
try {
|
try {
|
||||||
new Parser("A B\n C ((i+j)*2)\nendloop").parse();
|
new Parser("A B\n C ((i+j)*2)\nend loop").parse();
|
||||||
fail();
|
fail();
|
||||||
} catch (ParserException e) {
|
} catch (ParserException e) {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user