Skip to content

Commit fd3e4de

Browse files
committed
Added GS and PQ cards to new grammar
1 parent 0f6e03a commit fd3e4de

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

antlr/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TEST_OUT = $(TEST_FILES:.nec=.antlr)
4949
- ./antlr_test -i $*.nec -o $@
5050

5151
test_clean:
52-
rm ${TEST_OUT}
52+
rm -f ${TEST_OUT}
5353

5454
test_all: ${TEST_OUT}
5555
echo "DONE"

antlr/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,25 @@ Also requires lapack libraries.
1818

1919
aptitude install math-atlas-dev
2020

21+
### Testing
22+
23+
Just build in the current directory
24+
25+
make
26+
make test_clean
27+
make test_all
28+
2129
## New parser for NEC cards
2230

23-
The grammar is in the file nec.g
31+
The grammar is in the file nec.g. This is an ANTLR grammar for the existing NEC2 card deck for describing
32+
antennas.
2433

2534

2635
## New Language
2736

2837
The new language for nec++ will be more explicit and easy to read. It will also allow comments anywhere
29-
inside the code.
38+
inside the code. In addition it will not depend on whitespace to skip over missing parameters, and therefore
39+
will be far more robust.
3040

3141
/* This is a comment */
3242
geometry {

antlr/nec.g

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ analysisLine
196196
| tlCard
197197
| xqCard
198198
| enCard
199+
| pqCard
200+
| gsCard
199201
;
200202

201203

@@ -378,6 +380,29 @@ enCard
378380
}
379381
;
380382

383+
pqCard
384+
{ int iptflq = 0;
385+
int iptaq, iptaqf, iptaqt;
386+
}
387+
: PQ (iptflq=intNum)?
388+
( { nec->pq_card(iptflq, 0, 0, 0);
389+
}
390+
| iptaq=intNum iptaqf=intNum iptaqt=intNum
391+
{ nec->pq_card(iptflq, iptaq, iptaqf, iptaqt);
392+
}
393+
) NEWLINE
394+
;
395+
396+
gsCard
397+
{ float f1 = 0.0; }
398+
: GS (f1=realNum)? NEWLINE
399+
{
400+
c_geometry* geo = nec->get_geometry();
401+
geo->scale(f1);
402+
}
403+
;
404+
405+
381406
protected
382407
realNum returns [double val]
383408
: r:REAL

0 commit comments

Comments
 (0)