Skip to content

Commit

Permalink
Added GS and PQ cards to new grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolteno committed Oct 22, 2014
1 parent 0f6e03a commit fd3e4de
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion antlr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TEST_OUT = $(TEST_FILES:.nec=.antlr)
- ./antlr_test -i $*.nec -o $@

test_clean:
rm ${TEST_OUT}
rm -f ${TEST_OUT}

test_all: ${TEST_OUT}
echo "DONE"
14 changes: 12 additions & 2 deletions antlr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,25 @@ Also requires lapack libraries.

aptitude install math-atlas-dev

### Testing

Just build in the current directory

make
make test_clean
make test_all

## New parser for NEC cards

The grammar is in the file nec.g
The grammar is in the file nec.g. This is an ANTLR grammar for the existing NEC2 card deck for describing
antennas.


## New Language

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

/* This is a comment */
geometry {
Expand Down
25 changes: 25 additions & 0 deletions antlr/nec.g
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ analysisLine
| tlCard
| xqCard
| enCard
| pqCard
| gsCard
;


Expand Down Expand Up @@ -378,6 +380,29 @@ enCard
}
;

pqCard
{ int iptflq = 0;
int iptaq, iptaqf, iptaqt;
}
: PQ (iptflq=intNum)?
( { nec->pq_card(iptflq, 0, 0, 0);
}
| iptaq=intNum iptaqf=intNum iptaqt=intNum
{ nec->pq_card(iptflq, iptaq, iptaqf, iptaqt);
}
) NEWLINE
;

gsCard
{ float f1 = 0.0; }
: GS (f1=realNum)? NEWLINE
{
c_geometry* geo = nec->get_geometry();
geo->scale(f1);
}
;


protected
realNum returns [double val]
: r:REAL
Expand Down

0 comments on commit fd3e4de

Please sign in to comment.