From fd3e4de14fe2230e8215c9a3ed6539b7e4b8a137 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Wed, 22 Oct 2014 14:35:18 +1300 Subject: [PATCH] Added GS and PQ cards to new grammar --- antlr/Makefile | 2 +- antlr/README.md | 14 ++++++++++++-- antlr/nec.g | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/antlr/Makefile b/antlr/Makefile index 2020a6b..9da1fb6 100644 --- a/antlr/Makefile +++ b/antlr/Makefile @@ -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" diff --git a/antlr/README.md b/antlr/README.md index 63e589d..b8a02f3 100644 --- a/antlr/README.md +++ b/antlr/README.md @@ -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 { diff --git a/antlr/nec.g b/antlr/nec.g index 4e4e70b..32e183d 100644 --- a/antlr/nec.g +++ b/antlr/nec.g @@ -196,6 +196,8 @@ analysisLine | tlCard | xqCard | enCard + | pqCard + | gsCard ; @@ -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