head	8.7;
access;
symbols;
locks; strict;
comment	@ * @;


8.7
date	2026.05.11.12.01.10;	author mcalabre;	state Exp;
branches;
next	8.6;

8.6
date	2026.03.29.13.53.56;	author mcalabre;	state Exp;
branches
	8.6.1.1;
next	8.5;

8.5
date	2025.12.06.13.47.41;	author mcalabre;	state Exp;
branches
	8.5.1.1;
next	8.4;

8.4
date	2024.10.28.13.56.16;	author mcalabre;	state Exp;
branches
	8.4.1.1;
next	8.3;

8.3
date	2024.05.13.16.33.00;	author mcalabre;	state Exp;
branches
	8.3.1.1;
next	8.2;

8.2
date	2023.11.16.10.00.29;	author mcalabre;	state Exp;
branches
	8.2.1.1;
next	8.1;

8.1
date	2023.07.05.17.12.07;	author mcalabre;	state Exp;
branches
	8.1.1.1;
next	8.0;

8.0
date	2023.07.01.06.15.04;	author mcalabre;	state Exp;
branches
	8.0.1.1;
next	7.13;

7.13
date	2022.10.07.03.43.35;	author mcalabre;	state Exp;
branches
	7.13.1.1;
next	7.12;

7.12
date	2022.09.09.04.57.58;	author mcalabre;	state Exp;
branches
	7.12.1.1;
next	7.11;

7.11
date	2022.04.26.06.13.52;	author mcalabre;	state Exp;
branches
	7.11.1.1;
next	7.10;

7.10
date	2022.04.23.14.25.15;	author mcalabre;	state Exp;
branches
	7.10.1.1;
next	7.9;

7.9
date	2022.03.25.15.14.48;	author mcalabre;	state Exp;
branches
	7.9.1.1;
next	7.8;

7.8
date	2022.03.25.06.11.49;	author mcalabre;	state Exp;
branches
	7.8.1.1;
next	7.7;

7.7
date	2021.07.12.06.36.49;	author mcalabre;	state Exp;
branches
	7.7.1.1;
next	7.6;

7.6
date	2021.04.13.12.57.01;	author mcalabre;	state Exp;
branches
	7.6.1.1;
next	7.5;

7.5
date	2021.03.20.05.54.58;	author mcalabre;	state Exp;
branches
	7.5.1.1;
next	7.4;

7.4
date	2021.01.31.02.24.51;	author mcalabre;	state Exp;
branches
	7.4.1.1;
next	7.3;

7.3
date	2020.06.03.03.37.02;	author mcalabre;	state Exp;
branches
	7.3.1.1;
next	7.2;

7.2
date	2020.03.09.07.31.23;	author mcalabre;	state Exp;
branches
	7.2.1.1;
next	7.1;

7.1
date	2019.12.31.13.25.19;	author mcalabre;	state Exp;
branches
	7.1.1.1;
next	6.4;

6.4
date	2019.08.15.09.30.18;	author mcalabre;	state Exp;
branches
	6.4.1.1;
next	6.3;

6.3
date	2019.07.12.07.33.39;	author mcalabre;	state Exp;
branches
	6.3.1.1;
next	6.2;

6.2
date	2018.10.20.10.03.13;	author mcalabre;	state Exp;
branches
	6.2.1.1;
next	6.1;

6.1
date	2018.10.19.08.35.17;	author mcalabre;	state Exp;
branches
	6.1.1.1;
next	5.20;

5.20
date	2018.10.05.05.32.41;	author mcalabre;	state Exp;
branches
	5.20.1.1;
next	5.19;

5.19
date	2018.07.26.15.37.04;	author mcalabre;	state Exp;
branches
	5.19.1.1;
next	5.18;

5.18
date	2018.01.10.08.32.14;	author mcalabre;	state Exp;
branches
	5.18.1.1;
next	5.17;

5.17
date	2017.09.18.08.44.23;	author mcalabre;	state Exp;
branches
	5.17.1.1;
next	5.16;

5.16
date	2017.01.15.04.25.01;	author mcalabre;	state Exp;
branches
	5.16.1.1;
next	5.15;

5.15
date	2016.04.05.12.55.10;	author mcalabre;	state Exp;
branches
	5.15.1.1;
next	5.14;

5.14
date	2016.02.07.10.49.31;	author mcalabre;	state Exp;
branches
	5.14.1.1;
next	5.13;

5.13
date	2016.01.26.08.51.13;	author mcalabre;	state Exp;
branches
	5.13.1.1;
next	5.12;

5.12
date	2015.11.15.02.13.00;	author mcalabre;	state Exp;
branches
	5.12.1.1;
next	5.11;

5.11
date	2015.10.18.09.13.05;	author mcalabre;	state Exp;
branches
	5.11.1.1;
next	5.10;

5.10
date	2015.10.09.08.19.15;	author mcalabre;	state Exp;
branches
	5.10.1.1;
next	5.9;

5.9
date	2015.07.21.09.20.01;	author mcalabre;	state Exp;
branches
	5.9.1.1;
next	5.8;

5.8
date	2015.07.08.11.03.59;	author mcalabre;	state Exp;
branches
	5.8.1.1;
next	5.7;

5.7
date	2015.06.29.02.44.16;	author mcalabre;	state Exp;
branches
	5.7.1.1;
next	5.6;

5.6
date	2015.06.14.07.11.24;	author mcalabre;	state Exp;
branches
	5.6.1.1;
next	5.5;

5.5
date	2015.05.05.13.16.31;	author mcalabre;	state Exp;
branches
	5.5.1.1;
next	5.4;

5.4
date	2015.04.21.14.41.05;	author mcalabre;	state Exp;
branches
	5.4.1.1;
next	5.3;

5.3
date	2015.04.21.02.50.51;	author mcalabre;	state Exp;
branches
	5.3.1.1;
next	5.2;

5.2
date	2015.04.15.12.35.07;	author mcalabre;	state Exp;
branches
	5.2.1.1;
next	5.1;

5.1
date	2015.04.07.10.56.36;	author mcalabre;	state Exp;
branches
	5.1.1.1;
next	5.0;

5.0
date	2015.04.05.12.24.59;	author mcalabre;	state Exp;
branches
	5.0.1.1;
next	4.25;

4.25
date	2014.12.14.14.29.36;	author mcalabre;	state Exp;
branches
	4.25.1.1;
next	4.24;

4.24
date	2014.09.18.15.25.00;	author mcalabre;	state Exp;
branches
	4.24.1.1;
next	4.23;

4.23
date	2014.05.13.05.50.51;	author mcalabre;	state Exp;
branches
	4.23.1.1;
next	4.22;

4.22
date	2014.04.12.15.03.52;	author mcalabre;	state Exp;
branches
	4.22.1.1;
next	4.21;

4.21
date	2014.03.24.05.12.27;	author mcalabre;	state Exp;
branches
	4.21.1.1;
next	4.20;

4.20
date	2013.12.18.05.42.49;	author mcalabre;	state Exp;
branches
	4.20.1.1;
next	4.19;

4.19
date	2013.09.29.14.17.51;	author mcalabre;	state Exp;
branches
	4.19.1.1;
next	4.18;

4.18
date	2013.07.13.10.00.04;	author mcalabre;	state Exp;
branches
	4.18.1.1;
next	4.17;

4.17
date	2013.01.29.05.29.20;	author cal103;	state Exp;
branches
	4.17.1.1;
next	4.16;

4.16
date	2012.11.07.04.42.44;	author cal103;	state Exp;
branches
	4.16.1.1;
next	4.15;

4.15
date	2012.09.26.14.26.05;	author cal103;	state Exp;
branches
	4.15.1.1;
next	4.14;

4.14
date	2012.07.13.10.02.27;	author cal103;	state Exp;
branches
	4.14.1.1;
next	4.13;

4.13
date	2012.03.14.07.39.30;	author cal103;	state Exp;
branches
	4.13.1.1;
next	4.12;

4.12
date	2012.02.29.07.57.56;	author cal103;	state Exp;
branches
	4.12.1.1;
next	4.11;

4.11
date	2012.02.20.23.30.02;	author cal103;	state Exp;
branches
	4.11.1.1;
next	4.10;

4.10
date	2012.02.05.23.41.44;	author cal103;	state Exp;
branches
	4.10.1.1;
next	4.9;

4.9
date	2012.01.24.05.40.29;	author cal103;	state Exp;
branches
	4.9.1.1;
next	4.8;

4.8
date	2011.08.15.08.05.53;	author cal103;	state Exp;
branches
	4.8.1.1;
next	4.7;

4.7
date	2011.02.07.07.03.42;	author cal103;	state Exp;
branches
	4.7.1.1;
next	4.6;

4.6
date	2010.11.16.06.15.31;	author cal103;	state Exp;
branches
	4.6.1.1;
next	4.5;

4.5
date	2010.07.16.07.01.25;	author cal103;	state Exp;
branches
	4.5.1.1;
next	4.4;

4.4
date	2009.08.06.07.41.33;	author cal103;	state Exp;
branches
	4.4.1.1;
next	4.3;

4.3
date	2007.12.27.05.41.36;	author cal103;	state Exp;
branches
	4.3.1.1;
next	4.2;

4.2
date	2005.09.22.08.59.02;	author cal103;	state Exp;
branches
	4.2.1.1;
next	4.1;

4.1
date	2005.08.25.07.26.29;	author cal103;	state Exp;
branches;
next	0.0;

0.0
date	2005.08.25.07.06.15;	author cal103;	state Exp;
branches;
next	;

4.2.1.1
date	2005.12.05.02.39.43;	author cal103;	state Exp;
branches;
next	4.2.1.2;

4.2.1.2
date	2007.12.03.05.02.17;	author cal103;	state Exp;
branches;
next	4.2.1.3;

4.2.1.3
date	2007.12.27.05.09.41;	author cal103;	state Exp;
branches;
next	;

4.3.1.1
date	2007.12.27.13.23.47;	author cal103;	state Exp;
branches;
next	4.3.1.2;

4.3.1.2
date	2008.04.02.03.51.53;	author cal103;	state Exp;
branches;
next	4.3.1.3;

4.3.1.3
date	2009.07.22.04.53.58;	author cal103;	state Exp;
branches;
next	;

4.4.1.1
date	2009.08.10.08.52.49;	author cal103;	state Exp;
branches;
next	4.4.1.2;

4.4.1.2
date	2009.09.03.02.42.20;	author cal103;	state Exp;
branches;
next	4.4.1.3;

4.4.1.3
date	2009.09.03.04.51.55;	author cal103;	state Exp;
branches;
next	4.4.1.4;

4.4.1.4
date	2010.01.19.03.42.50;	author cal103;	state Exp;
branches;
next	;

4.5.1.1
date	2010.07.16.07.05.31;	author cal103;	state Exp;
branches;
next	4.5.1.2;

4.5.1.2
date	2010.11.15.01.10.45;	author cal103;	state Exp;
branches;
next	;

4.6.1.1
date	2010.11.16.06.16.19;	author cal103;	state Exp;
branches;
next	4.6.1.2;

4.6.1.2
date	2011.01.14.06.33.16;	author cal103;	state Exp;
branches;
next	4.6.1.3;

4.6.1.3
date	2011.01.25.00.26.16;	author cal103;	state Exp;
branches;
next	;

4.7.1.1
date	2011.02.07.07.04.22;	author cal103;	state Exp;
branches;
next	4.7.1.2;

4.7.1.2
date	2011.07.21.03.48.09;	author cal103;	state Exp;
branches;
next	4.7.1.3;

4.7.1.3
date	2011.08.09.02.43.50;	author cal103;	state Exp;
branches;
next	;

4.8.1.1
date	2011.08.15.08.07.06;	author cal103;	state Exp;
branches;
next	4.8.1.2;

4.8.1.2
date	2012.01.24.05.23.06;	author cal103;	state Exp;
branches;
next	;

4.9.1.1
date	2012.01.24.05.41.45;	author cal103;	state Exp;
branches;
next	;

4.10.1.1
date	2012.02.05.23.42.46;	author cal103;	state Exp;
branches;
next	;

4.11.1.1
date	2012.02.20.23.31.13;	author cal103;	state Exp;
branches;
next	;

4.12.1.1
date	2012.02.29.07.59.10;	author cal103;	state Exp;
branches;
next	;

4.13.1.1
date	2012.03.14.07.40.37;	author cal103;	state Exp;
branches;
next	4.13.1.2;

4.13.1.2
date	2012.07.12.15.24.27;	author cal103;	state Exp;
branches;
next	4.13.1.3;

4.13.1.3
date	2012.07.13.03.34.20;	author cal103;	state Exp;
branches;
next	;

4.14.1.1
date	2012.07.13.10.04.44;	author cal103;	state Exp;
branches;
next	4.14.1.2;

4.14.1.2
date	2012.09.26.07.53.12;	author cal103;	state Exp;
branches;
next	;

4.15.1.1
date	2012.09.26.14.27.51;	author cal103;	state Exp;
branches;
next	;

4.16.1.1
date	2012.11.07.04.45.56;	author cal103;	state Exp;
branches;
next	4.16.1.2;

4.16.1.2
date	2012.11.28.13.04.03;	author cal103;	state Exp;
branches;
next	4.16.1.3;

4.16.1.3
date	2013.01.29.03.43.47;	author cal103;	state Exp;
branches;
next	;

4.17.1.1
date	2013.01.29.05.32.32;	author cal103;	state Exp;
branches;
next	;

4.18.1.1
date	2013.07.13.10.02.37;	author mcalabre;	state Exp;
branches;
next	;

4.19.1.1
date	2013.09.29.14.20.38;	author mcalabre;	state Exp;
branches;
next	;

4.20.1.1
date	2013.12.18.05.46.55;	author mcalabre;	state Exp;
branches;
next	4.20.1.2;

4.20.1.2
date	2014.03.21.06.32.19;	author mcalabre;	state Exp;
branches;
next	;

4.21.1.1
date	2014.03.24.05.15.28;	author mcalabre;	state Exp;
branches;
next	;

4.22.1.1
date	2014.04.12.15.06.32;	author mcalabre;	state Exp;
branches;
next	;

4.23.1.1
date	2014.05.13.05.53.49;	author mcalabre;	state Exp;
branches;
next	;

4.24.1.1
date	2014.09.18.15.28.09;	author mcalabre;	state Exp;
branches;
next	;

4.25.1.1
date	2014.12.14.14.32.45;	author mcalabre;	state Exp;
branches;
next	4.25.1.2;

4.25.1.2
date	2015.01.06.01.01.06;	author mcalabre;	state Exp;
branches;
next	;

5.0.1.1
date	2015.04.05.12.28.00;	author mcalabre;	state Exp;
branches;
next	;

5.1.1.1
date	2015.04.07.11.01.10;	author mcalabre;	state Exp;
branches;
next	;

5.2.1.1
date	2015.04.15.12.39.14;	author mcalabre;	state Exp;
branches;
next	;

5.3.1.1
date	2015.04.21.02.54.02;	author mcalabre;	state Exp;
branches;
next	;

5.4.1.1
date	2015.04.21.14.44.28;	author mcalabre;	state Exp;
branches;
next	;

5.5.1.1
date	2015.05.05.13.21.00;	author mcalabre;	state Exp;
branches;
next	;

5.6.1.1
date	2015.06.14.07.14.44;	author mcalabre;	state Exp;
branches;
next	;

5.7.1.1
date	2015.06.29.02.47.24;	author mcalabre;	state Exp;
branches;
next	;

5.8.1.1
date	2015.07.08.11.07.18;	author mcalabre;	state Exp;
branches;
next	;

5.9.1.1
date	2015.07.21.09.28.07;	author mcalabre;	state Exp;
branches;
next	;

5.10.1.1
date	2015.10.09.08.22.35;	author mcalabre;	state Exp;
branches;
next	;

5.11.1.1
date	2015.10.18.09.16.27;	author mcalabre;	state Exp;
branches;
next	;

5.12.1.1
date	2015.11.15.02.16.14;	author mcalabre;	state Exp;
branches;
next	5.12.1.2;

5.12.1.2
date	2016.01.25.05.17.04;	author mcalabre;	state Exp;
branches;
next	;

5.13.1.1
date	2016.01.26.08.54.32;	author mcalabre;	state Exp;
branches;
next	5.13.1.2;

5.13.1.2
date	2016.02.07.08.35.55;	author mcalabre;	state Exp;
branches;
next	5.13.1.3;

5.13.1.3
date	2016.02.07.10.35.39;	author mcalabre;	state Exp;
branches;
next	;

5.14.1.1
date	2016.02.07.10.52.44;	author mcalabre;	state Exp;
branches;
next	5.14.1.2;

5.14.1.2
date	2016.04.05.12.40.52;	author mcalabre;	state Exp;
branches;
next	;

5.15.1.1
date	2016.04.05.12.58.35;	author mcalabre;	state Exp;
branches;
next	5.15.1.2;

5.15.1.2
date	2017.01.15.04.14.00;	author mcalabre;	state Exp;
branches;
next	;

5.16.1.1
date	2017.01.15.04.28.59;	author mcalabre;	state Exp;
branches;
next	5.16.1.2;

5.16.1.2
date	2017.09.12.13.30.44;	author mcalabre;	state Exp;
branches;
next	;

5.17.1.1
date	2017.09.18.08.45.59;	author mcalabre;	state Exp;
branches;
next	5.17.1.2;

5.17.1.2
date	2017.12.05.01.38.46;	author mcalabre;	state Exp;
branches;
next	5.17.1.3;

5.17.1.3
date	2018.01.10.08.25.34;	author mcalabre;	state Exp;
branches;
next	;

5.18.1.1
date	2018.01.10.08.33.04;	author mcalabre;	state Exp;
branches;
next	;

5.19.1.1
date	2018.07.26.15.41.40;	author mcalabre;	state Exp;
branches;
next	;

5.20.1.1
date	2018.10.05.05.33.33;	author mcalabre;	state Exp;
branches;
next	5.20.1.2;

5.20.1.2
date	2018.10.19.07.34.25;	author mcalabre;	state Exp;
branches;
next	;

6.1.1.1
date	2018.10.19.08.36.15;	author mcalabre;	state Exp;
branches;
next	;

6.2.1.1
date	2018.10.20.10.04.15;	author mcalabre;	state Exp;
branches;
next	6.2.1.2;

6.2.1.2
date	2019.05.10.01.56.50;	author mcalabre;	state Exp;
branches;
next	6.2.1.3;

6.2.1.3
date	2019.07.08.08.02.29;	author mcalabre;	state Exp;
branches;
next	;

6.3.1.1
date	2019.07.12.07.34.37;	author mcalabre;	state Exp;
branches;
next	;

6.4.1.1
date	2019.08.15.09.31.29;	author mcalabre;	state Exp;
branches;
next	6.4.1.2;

6.4.1.2
date	2019.12.16.03.34.03;	author mcalabre;	state Exp;
branches;
next	6.4.1.3;

6.4.1.3
date	2019.12.31.03.28.03;	author mcalabre;	state Exp;
branches;
next	;

7.1.1.1
date	2019.12.31.13.28.19;	author mcalabre;	state Exp;
branches;
next	;

7.2.1.1
date	2020.03.09.07.34.50;	author mcalabre;	state Exp;
branches;
next	;

7.3.1.1
date	2020.06.03.03.38.10;	author mcalabre;	state Exp;
branches;
next	7.3.1.2;

7.3.1.2
date	2020.08.17.11.19.09;	author mcalabre;	state Exp;
branches;
next	7.3.1.3;

7.3.1.3
date	2021.01.19.14.09.10;	author mcalabre;	state Exp;
branches;
next	7.3.1.4;

7.3.1.4
date	2021.01.28.12.29.30;	author mcalabre;	state Exp;
branches;
next	;

7.4.1.1
date	2021.01.31.02.26.24;	author mcalabre;	state Exp;
branches;
next	7.4.1.2;

7.4.1.2
date	2021.02.25.13.45.25;	author mcalabre;	state Exp;
branches;
next	7.4.1.3;

7.4.1.3
date	2021.02.25.13.58.40;	author mcalabre;	state Exp;
branches;
next	;

7.5.1.1
date	2021.03.20.05.56.42;	author mcalabre;	state Exp;
branches;
next	;

7.6.1.1
date	2021.04.13.13.00.35;	author mcalabre;	state Exp;
branches;
next	7.6.1.2;

7.6.1.2
date	2021.07.01.08.43.02;	author mcalabre;	state Exp;
branches;
next	;

7.7.1.1
date	2021.07.12.06.38.27;	author mcalabre;	state Exp;
branches;
next	7.7.1.2;

7.7.1.2
date	2022.03.25.06.05.59;	author mcalabre;	state Exp;
branches;
next	;

7.8.1.1
date	2022.03.25.06.14.14;	author mcalabre;	state Exp;
branches;
next	;

7.9.1.1
date	2022.03.25.15.16.40;	author mcalabre;	state Exp;
branches;
next	;

7.10.1.1
date	2022.04.23.14.26.54;	author mcalabre;	state Exp;
branches;
next	;

7.11.1.1
date	2022.04.26.06.15.32;	author mcalabre;	state Exp;
branches;
next	;

7.12.1.1
date	2022.09.09.05.00.36;	author mcalabre;	state Exp;
branches;
next	;

7.13.1.1
date	2022.10.07.03.45.47;	author mcalabre;	state Exp;
branches;
next	7.13.1.2;

7.13.1.2
date	2023.06.15.04.17.20;	author mcalabre;	state Exp;
branches;
next	;

8.0.1.1
date	2023.07.01.06.22.44;	author mcalabre;	state Exp;
branches;
next	;

8.1.1.1
date	2023.07.05.17.15.00;	author mcalabre;	state Exp;
branches;
next	;

8.2.1.1
date	2023.11.16.10.05.57;	author mcalabre;	state Exp;
branches;
next	8.2.1.2;

8.2.1.2
date	2024.04.02.14.01.58;	author mcalabre;	state Exp;
branches;
next	;

8.3.1.1
date	2024.05.13.16.35.39;	author mcalabre;	state Exp;
branches;
next	;

8.4.1.1
date	2024.10.28.13.58.41;	author mcalabre;	state Exp;
branches;
next	8.4.1.2;

8.4.1.2
date	2025.12.06.13.37.16;	author mcalabre;	state Exp;
branches;
next	;

8.5.1.1
date	2025.12.06.14.05.15;	author mcalabre;	state Exp;
branches;
next	8.5.1.2;

8.5.1.2
date	2026.03.29.13.36.16;	author mcalabre;	state Exp;
branches;
next	;

8.6.1.1
date	2026.03.29.14.19.26;	author mcalabre;	state Exp;
branches;
next	;


desc
@Flex description file containing the definition of a recursive, multi-
buffered lexical scanner that parses FITS units specifications.
@


8.7
log
@WCSLIB 8.7
@
text
@/*============================================================================
  WCSLIB 8.7 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2026, Mark Calabretta

  This file is part of WCSLIB.

  WCSLIB is free software: you can redistribute it and/or modify it under the
  terms of the GNU Lesser General Public License as published by the Free
  Software Foundation, either version 3 of the License, or (at your option)
  any later version.

  WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
  more details.

  You should have received a copy of the GNU Lesser General Public License
  along with WCSLIB.  If not, see http://www.gnu.org/licenses.

  Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
  http://www.atnf.csiro.au/computing/software/wcs
  $Id: wcsulex.l,v 8.6.1.1 2026/03/29 14:19:26 mcalabre Exp mcalabre $
*=============================================================================
*
* wcsulex.l is a Flex description file containing the definition of a
* recursive, multi-buffered lexical scanner and parser for FITS units
* specifications.
*
* It requires Flex v2.5.4 or later.
*
* Refer to wcsunits.h for a description of the user interface and operating
* notes.
*
*===========================================================================*/

/* Options. */
%option full
%option never-interactive
%option noinput
%option noyywrap
%option outfile="wcsulex.c"
%option prefix="wcsulex"
%option reentrant
%option extra-type="struct wcsulex_extra *"

/* Exponents. */
INTEGER	  [+-]?[1-9][0-9]*
FRAC	  {INTEGER}"/"[1-9][0-9]*
FLOAT	  [+-]?([0-9]+\.?[0-9]*|\.[0-9]+)

/* Metric prefixes. */
SUB3	  [munpfazy]
SUBPREFIX [dc]|{SUB3}
SUP3	  [kMGTPEZY]
SUPPREFIX da|h|{SUP3}
PREFIX	  {SUBPREFIX}|{SUPPREFIX}

/* Basic and derived SI units. */
BASIC	  m|s|g|rad|sr|K|A|mol|cd
DERIVED	  Hz|J|W|V|N|Pa|C|[Oo]hm|S|F|Wb|T|H|lm|lx
SI_UNIT	  {BASIC}|{DERIVED}

/* Additional recognized units: all metric prefixes allowed. */
ADD_ALL	  eV|Jy|R|G|barn

/* Additional recognized units: only super-metric prefixes allowed. */
ADD_SUP	  a|yr|pc|bit|[bB]yte

/* Additional recognized units: only sub-metric prefixes allowed. */
ADD_SUB	  mag

/* Additional recognized units for which NO metric prefixes are allowed. */
GENERAL	  deg|arcmin|arcsec|mas|turn|min|h|d|cy|erg|Ry|u|D
ASTRO	  [Aa]ngstrom|AU|lyr|beam|solRad|solMass|solLum|Sun
DEVICE	  adu|bin|chan|count|ct|photon|ph|pixel|pix|voxel
ADD_NONE  {GENERAL}|{ASTRO}|{DEVICE}

/* All additional recognized units. */
ADD_UNIT  {ADD_ALL}|{ADD_SUP}|{ADD_SUB}|{ADD_NONE}

/* Exclusive start states. */
%x PAREN PREFIX UNITS EXPON FLUSH

%{
#include <math.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>

#include "wcserr.h"
#include "wcsmath.h"
#include "wcsunits.h"
#include "wcsutil.h"

// User data associated with yyscanner.
struct wcsulex_extra {
  // Used in preempting the call to exit() by yy_fatal_error().
  jmp_buf abort_jmp_env;
};

#define YY_DECL int wcsulexe_scanner(const char unitstr[], int *func, \
 double *scale, double units[WCSUNITS_NTYPE], struct wcserr **err, \
 yyscan_t yyscanner)

// Dummy definition to circumvent compiler warnings.
#define YY_INPUT(inbuff, count, bufsize) { count = YY_NULL; }

// Preempt the call to exit() by yy_fatal_error().
#define exit(status) longjmp(yyextra->abort_jmp_env, status);

// Internal helper functions.
static YY_DECL;

%}

%%
	static const char *function = "wcsulexe_scanner";
	
	void add(double *factor, double types[], double *expon, double *scale,
	    double units[]);
	
	// Initialise returned values.
	*func  = 0;
	*scale = 1.0;
	
	for (int i = 0; i < WCSUNITS_NTYPE; i++) {
	  units[i] = 0.0;
	}
	
	if (err) *err = 0x0;
	
	double types[WCSUNITS_NTYPE];
	for (int i = 0; i < WCSUNITS_NTYPE; i++) {
	  types[i] = 0.0;
	}
	double expon  = 1.0;
	double factor = 1.0;
	
	int bracket  = 0;
	int operator = 0;
	int paren    = 0;
	int status   = 0;
	
	// Avert a flex-induced memory leak.
	if (YY_CURRENT_BUFFER && YY_CURRENT_BUFFER->yy_input_file == stdin) {
	  yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
	}
	
	yy_scan_string(unitstr, yyscanner);
	
	// Return here via longjmp() invoked by yy_fatal_error().
	if (setjmp(yyextra->abort_jmp_env)) {
	  return wcserr_set(WCSERR_SET(UNITSERR_PARSER_ERROR),
	    "Internal units parser error parsing '%s'", unitstr);
	}
	
	BEGIN(INITIAL);
	
	#ifdef DEBUG
	fprintf(stderr, "\n%s ->\n", unitstr);
	#endif

^" "+	{
	  // Pretend initial whitespace doesn't exist.
	  yy_set_bol(1);
	}

^"["	{
	  if (bracket++) {
	    BEGIN(FLUSH);
	  } else {
	    yy_set_bol(1);
	  }
	}

^10[0-9] {
	  status = wcserr_set(WCSERR_SET(UNITSERR_BAD_NUM_MULTIPLIER),
	    "Invalid exponent in '%s'", unitstr);
	  BEGIN(FLUSH);
	}

^10	{
	  factor = 10.0;
	  BEGIN(EXPON);
	}

^log" "*"(" {
	  *func = 1;
	  unput('(');
	  BEGIN(PAREN);
	}

^ln" "*"(" {
	  *func = 2;
	  unput('(');
	  BEGIN(PAREN);
	}

^exp" "*"(" {
	  *func = 3;
	  unput('(');
	  BEGIN(PAREN);
	}

^[*.]	{
	  // Leading binary multiply.
	  status = wcserr_set(WCSERR_SET(UNITSERR_DANGLING_BINOP),
	    "Dangling binary operator in '%s'", unitstr);
	  BEGIN(FLUSH);
	}

" "+	  // Discard whitespace in INITIAL context.

sqrt" "*"(" {
	  expon /= 2.0;
	  unput('(');
	  BEGIN(PAREN);
	}

"("	{
	  // Gather terms in parentheses.
	  yyless(0);
	  BEGIN(PAREN);
	}

[*.]	{
	  if (operator++) {
	    BEGIN(FLUSH);
	  }
	}

^1"/" |
"/"	{
	  if (operator++) {
	    BEGIN(FLUSH);
	  } else {
	    expon *= -1.0;
	  }
	}

{SI_UNIT}|{ADD_UNIT} {
	  operator = 0;
	  yyless(0);
	  BEGIN(UNITS);
	}

{PREFIX}({SI_UNIT}|{ADD_ALL}) |
{SUPPREFIX}{ADD_SUP} |
{SUBPREFIX}{ADD_SUB} {
	  operator = 0;
	  yyless(0);
	  BEGIN(PREFIX);
	}

"]"	{
	  bracket = !bracket;
	  BEGIN(FLUSH);
	}

.	{
	  status = wcserr_set(WCSERR_SET(UNITSERR_BAD_INITIAL_SYMBOL),
	    "Invalid symbol in INITIAL context in '%s'", unitstr);
	  BEGIN(FLUSH);
	}

<PAREN>"(" {
	  paren++;
	  operator = 0;
	  yymore();
	}

<PAREN>")" {
	  paren--;
	  if (paren) {
	    // Not balanced yet.
	    yymore();
	
	  } else {
	    // Balanced; strip off the outer parentheses and recurse.
	    yytext[yyleng-1] = '\0';
	
	    int func_r;
	    double factor_r;
	    status = wcsulexe(yytext+1, &func_r, &factor_r, types, err);
	
	    YY_BUFFER_STATE buf = YY_CURRENT_BUFFER;
	    yy_switch_to_buffer(buf, yyscanner);
	
	    if (func_r) {
	      status = wcserr_set(WCSERR_SET(UNITSERR_FUNCTION_CONTEXT),
	        "Function in invalid context in '%s'", unitstr);
	    }
	
	    if (status) {
	      BEGIN(FLUSH);
	    } else {
	      factor *= factor_r;
	      BEGIN(EXPON);
	    }
	  }
	}

<PAREN>[^()]+ {
	  yymore();
	}

<PREFIX>d {
	  factor = 1e-1;
	  BEGIN(UNITS);
	}

<PREFIX>c {
	  factor = 1e-2;
	  BEGIN(UNITS);
	}

<PREFIX>m {
	  factor = 1e-3;
	  BEGIN(UNITS);
	}

<PREFIX>u {
	  factor = 1e-6;
	  BEGIN(UNITS);
	}

<PREFIX>n {
	  factor = 1e-9;
	  BEGIN(UNITS);
	}

<PREFIX>p {
	  factor = 1e-12;
	  BEGIN(UNITS);
	}

<PREFIX>f {
	  factor = 1e-15;
	  BEGIN(UNITS);
	}

<PREFIX>a {
	  factor = 1e-18;
	  BEGIN(UNITS);
	}

<PREFIX>z {
	  factor = 1e-21;
	  BEGIN(UNITS);
	}

<PREFIX>y {
	  factor = 1e-24;
	  BEGIN(UNITS);
	}

<PREFIX>da {
	  factor = 1e+1;
	  BEGIN(UNITS);
	}

<PREFIX>h {
	  factor = 1e+2;
	  BEGIN(UNITS);
	}

<PREFIX>k {
	  factor = 1e+3;
	  BEGIN(UNITS);
	}

<PREFIX>M {
	  factor = 1e+6;
	  BEGIN(UNITS);
	}

<PREFIX>G {
	  factor = 1e+9;
	  BEGIN(UNITS);
	}

<PREFIX>T {
	  factor = 1e+12;
	  BEGIN(UNITS);
	}

<PREFIX>P {
	  factor = 1e+15;
	  BEGIN(UNITS);
	}

<PREFIX>E {
	  factor = 1e+18;
	  BEGIN(UNITS);
	}

<PREFIX>Z {
	  factor = 1e+21;
	  BEGIN(UNITS);
	}

<PREFIX>Y {
	  factor = 1e+24;
	  BEGIN(UNITS);
	}

<PREFIX>. {
	  // Internal parser error.
	  status = wcserr_set(WCSERR_SET(UNITSERR_PARSER_ERROR),
	    "Internal units parser error parsing '%s'", unitstr);
	  BEGIN(FLUSH);
	}

<UNITS>A {
	  // Ampere.
	  types[WCSUNITS_CHARGE] += 1.0;
	  types[WCSUNITS_TIME]   -= 1.0;
	  BEGIN(EXPON);
	}

<UNITS>a|yr {
	  // Julian year (annum).
	  factor *= 31557600.0;
	  types[WCSUNITS_TIME] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>adu {
	  // Analogue-to-digital converter units.
	  types[WCSUNITS_COUNT] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>[Aa]ngstrom {
	  // Angstrom.
	  factor *= 1e-10;
	  types[WCSUNITS_LENGTH] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>arcmin {
	  // Minute of arc.
	  factor /= 60.0;
	  types[WCSUNITS_PLANE_ANGLE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>arcsec {
	  // Second of arc.
	  factor /= 3600.0;
	  types[WCSUNITS_PLANE_ANGLE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>AU {
	  // Astronomical unit.
	  factor *= 1.49598e+11;
	  types[WCSUNITS_LENGTH] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>barn {
	  // Barn.
	  factor *= 1e-28;
	  types[WCSUNITS_LENGTH] += 2.0;
	  BEGIN(EXPON);
	}

<UNITS>beam {
	  // Beam, as in Jy/beam.
	  types[WCSUNITS_BEAM] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>bin {
	  // Bin (e.g. histogram).
	  types[WCSUNITS_BIN] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>bit {
	  // Bit.
	  types[WCSUNITS_BIT] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>[bB]yte {
	  // Byte.
	  factor *= 8.0;
	  types[WCSUNITS_BIT] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>C {
	  // Coulomb.
	  types[WCSUNITS_CHARGE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>cd {
	  // Candela.
	  types[WCSUNITS_LUMINTEN] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>chan {
	  // Channel.
	  types[WCSUNITS_BIN] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>count|ct {
	  // Count.
	  types[WCSUNITS_COUNT] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>cy {
	  // Julian century.
	  factor *= 3155760000.0;
	  types[WCSUNITS_TIME] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>D {
	  // Debye.
	  factor *= 1e-29 / 3.0;
	  types[WCSUNITS_CHARGE] += 1.0;
	  types[WCSUNITS_LENGTH] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>d {
	  // Day.
	  factor *= 86400.0;
	  types[WCSUNITS_TIME] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>deg {
	  // Degree.
	  types[WCSUNITS_PLANE_ANGLE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>erg {
	  // Erg.
	  factor *= 1e-7;
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 2.0;
	  types[WCSUNITS_TIME]   -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>eV {
	  // Electron volt.
	  factor *= 1.6021765e-19;
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 2.0;
	  types[WCSUNITS_TIME]   -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>F {
	  // Farad.
	  types[WCSUNITS_MASS]   -= 1.0;
	  types[WCSUNITS_LENGTH] -= 2.0;
	  types[WCSUNITS_TIME]   += 3.0;
	  types[WCSUNITS_CHARGE] += 2.0;
	  BEGIN(EXPON);
	}

<UNITS>G {
	  // Gauss.
	  factor *= 1e-4;
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_TIME]   += 1.0;
	  types[WCSUNITS_CHARGE] -= 1.0;
	  BEGIN(EXPON);
	}

<UNITS>g {
	  // Gram.
	  factor *= 1e-3;
	  types[WCSUNITS_MASS] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>H {
	  // Henry.
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 2.0;
	  types[WCSUNITS_TIME]   += 2.0;
	  types[WCSUNITS_CHARGE] -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>h {
	  // Hour.
	  factor *= 3600.0;
	  types[WCSUNITS_TIME] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>Hz {
	  // Hertz.
	  types[WCSUNITS_TIME] -= 1.0;
	  BEGIN(EXPON);
	}

<UNITS>J {
	  // Joule.
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 2.0;
	  types[WCSUNITS_TIME]   -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>Jy {
	  // Jansky.
	  factor *= 1e-26;
	  types[WCSUNITS_MASS] += 1.0;
	  types[WCSUNITS_TIME] -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>K {
	  // Kelvin.
	  types[WCSUNITS_TEMPERATURE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>lm {
	  // Lumen.
	  types[WCSUNITS_LUMINTEN]    += 1.0;
	  types[WCSUNITS_SOLID_ANGLE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>lx {
	  // Lux.
	  types[WCSUNITS_LUMINTEN]    += 1.0;
	  types[WCSUNITS_SOLID_ANGLE] += 1.0;
	  types[WCSUNITS_LENGTH]      -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>lyr {
	  // Light year.
	  factor *= 2.99792458e8 * 31557600.0;
	  types[WCSUNITS_LENGTH] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>m {
	  // Metre.
	  types[WCSUNITS_LENGTH] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>mag {
	  // Stellar magnitude.
	  types[WCSUNITS_MAGNITUDE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>mas {
	  // Milli-arcsec.
	  factor /= 3600e+3;
	  types[WCSUNITS_PLANE_ANGLE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>min {
	  // Minute.
	  factor *= 60.0;
	  types[WCSUNITS_TIME] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>mol {
	  // Mole.
	  types[WCSUNITS_MOLE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>N {
	  // Newton.
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 1.0;
	  types[WCSUNITS_TIME]   -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>[Oo]hm {
	  // Ohm.
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 2.0;
	  types[WCSUNITS_TIME]   -= 1.0;
	  types[WCSUNITS_CHARGE] -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>Pa {
	  // Pascal.
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] -= 1.0;
	  types[WCSUNITS_TIME]   -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>pc {
	  // Parsec.
	  factor *= 3.0857e16;
	  types[WCSUNITS_LENGTH] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>photon|ph {
	  // Photon.
	  types[WCSUNITS_COUNT] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>pixel|pix {
	  // Pixel.
	  types[WCSUNITS_PIXEL] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>R {
	  // Rayleigh.
	  factor *= 1e10 / (4.0 * PI);
	  types[WCSUNITS_LENGTH]      -= 2.0;
	  types[WCSUNITS_TIME]        -= 1.0;
	  types[WCSUNITS_SOLID_ANGLE] -= 1.0;
	  BEGIN(EXPON);
	}

<UNITS>rad {
	  // Radian.
	  factor *= 180.0 / PI;
	  types[WCSUNITS_PLANE_ANGLE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>Ry {
	  // Rydberg.
	  factor *= 13.605692 * 1.6021765e-19;
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 2.0;
	  types[WCSUNITS_TIME]   -= 2.0;
	  BEGIN(EXPON);
	}

<UNITS>S {
	  // Siemen.
	  types[WCSUNITS_MASS]   -= 1.0;
	  types[WCSUNITS_LENGTH] -= 2.0;
	  types[WCSUNITS_TIME]   += 1.0;
	  types[WCSUNITS_CHARGE] += 2.0;
	  BEGIN(EXPON);
	}

<UNITS>s {
	  // Second.
	  types[WCSUNITS_TIME] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>solLum {
	  // Solar luminosity.
	  factor *= 3.8268e26;
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 2.0;
	  types[WCSUNITS_TIME]   -= 3.0;
	  BEGIN(EXPON);
	}

<UNITS>solMass {
	  // Solar mass.
	  factor *= 1.9891e30;
	  types[WCSUNITS_MASS] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>solRad {
	  // Solar radius.
	  factor *= 6.9599e8;
	  types[WCSUNITS_LENGTH] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>sr {
	  // Steradian.
	  types[WCSUNITS_SOLID_ANGLE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>Sun {
	  // Sun (with respect to).
	  types[WCSUNITS_SOLRATIO] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>T {
	  // Tesla.
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_TIME]   += 1.0;
	  types[WCSUNITS_CHARGE] -= 1.0;
	  BEGIN(EXPON);
	}

<UNITS>turn {
	  // Turn.
	  factor *= 360.0;
	  types[WCSUNITS_PLANE_ANGLE] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>u {
	  // Unified atomic mass unit.
	  factor *= 1.6605387e-27;
	  types[WCSUNITS_MASS] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>V {
	  // Volt.
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 1.0;
	  types[WCSUNITS_TIME]   -= 2.0;
	  types[WCSUNITS_CHARGE] -= 1.0;
	  BEGIN(EXPON);
	}

<UNITS>voxel {
	  // Voxel.
	  types[WCSUNITS_VOXEL] += 1.0;
	  BEGIN(EXPON);
	}

<UNITS>W {
	  // Watt.
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 2.0;
	  types[WCSUNITS_TIME]   -= 3.0;
	  BEGIN(EXPON);
	}

<UNITS>Wb {
	  // Weber.
	  types[WCSUNITS_MASS]   += 1.0;
	  types[WCSUNITS_LENGTH] += 2.0;
	  types[WCSUNITS_TIME]   += 1.0;
	  types[WCSUNITS_CHARGE] -= 1.0;
	  BEGIN(EXPON);
	}

<UNITS>. {
	  // Internal parser error.
	  status = wcserr_set(WCSERR_SET(UNITSERR_PARSER_ERROR),
	    "Internal units parser error parsing '%s'", unitstr);
	  BEGIN(FLUSH);
	}

<EXPON>" "*("**"|^) {
	  // Exponentiation.
	  if (operator++) {
	    BEGIN(FLUSH);
	  }
	}

<EXPON>" "*{INTEGER} {
	  int i;
	  sscanf(yytext, " %d", &i);
	  expon *= (double)i;
	  add(&factor, types, &expon, scale, units);
	  operator = 0;
	  BEGIN(INITIAL);
	}

<EXPON>" "*"("" "*{INTEGER}" "*")" {
	  int i;
	  sscanf(yytext, " (%d)", &i);
	  expon *= (double)i;
	  add(&factor, types, &expon, scale, units);
	  operator = 0;
	  BEGIN(INITIAL);
	}

<EXPON>" "*"("" "*{FRAC}" "*")" {
	  int i, j;
	  sscanf(yytext, " (%d/%d)", &i, &j);
	  expon *= (double)i / (double)j;
	  add(&factor, types, &expon, scale, units);
	  operator = 0;
	  BEGIN(INITIAL);
	}

<EXPON>" "*"("" "*{FLOAT}" "*")" {
	  char ctmp[72];
	  sscanf(yytext, " (%s)", ctmp);
	  double dexp;
	  wcsutil_str2double(ctmp, &dexp);
	  expon *= dexp;
	  add(&factor, types, &expon, scale, units);
	  operator = 0;
	  BEGIN(INITIAL);
	}

<EXPON>" "*[.*]" "* {
	  // Multiply.
	  if (operator++) {
	    BEGIN(FLUSH);
	  } else {
	    add(&factor, types, &expon, scale, units);
	    BEGIN(INITIAL);
	  }
	}

<EXPON>" "*"(" {
	  // Multiply.
	  if (operator) {
	    BEGIN(FLUSH);
	  } else {
	    add(&factor, types, &expon, scale, units);
	    unput('(');
	    BEGIN(INITIAL);
	  }
	}

<EXPON>" "+ {
	  // Multiply.
	  if (operator) {
	    BEGIN(FLUSH);
	  } else {
	    add(&factor, types, &expon, scale, units);
	    BEGIN(INITIAL);
	  }
	}

<EXPON>" "*"/"" "* {
	  // Divide.
	  if (operator++) {
	    BEGIN(FLUSH);
	  } else {
	    add(&factor, types, &expon, scale, units);
	    expon = -1.0;
	    BEGIN(INITIAL);
	  }
	}

<EXPON>" "*"]" {
	  add(&factor, types, &expon, scale, units);
	  bracket = !bracket;
	  BEGIN(FLUSH);
	}

<EXPON>. {
	  status = wcserr_set(WCSERR_SET(UNITSERR_BAD_EXPON_SYMBOL),
	    "Invalid symbol in EXPON context in '%s'", unitstr);
	  BEGIN(FLUSH);
	}

<FLUSH>.* {
	  // Discard any remaining input.
	}

<<EOF>>	{
	  // End-of-string.
	  if (YY_START == EXPON) {
	    add(&factor, types, &expon, scale, units);
	  }
	
	  if (bracket) {
	    status = wcserr_set(WCSERR_SET(UNITSERR_UNBAL_BRACKET),
	      "Unbalanced bracket in '%s'", unitstr);
	  } else if (paren) {
	    status = wcserr_set(WCSERR_SET(UNITSERR_UNBAL_PAREN),
	      "Unbalanced parenthesis in '%s'", unitstr);
	  } else if (operator == 1) {
	    status = wcserr_set(WCSERR_SET(UNITSERR_DANGLING_BINOP),
	      "Dangling binary operator in '%s'", unitstr);
	  } else if (operator) {
	    status = wcserr_set(WCSERR_SET(UNITSERR_CONSEC_BINOPS),
	      "Consecutive binary operators in '%s'", unitstr);
	  #ifdef DEBUG
	  } else {
	    fprintf(stderr, "EOS\n");
	  #endif
	  }
	
	  if (status) {
	    for (int i = 0; i < WCSUNITS_NTYPE; i++) {
	      units[i] = 0.0;
	      *scale = 0.0;
	    }
	  }
	
	  return status;
	}

%%

/*----------------------------------------------------------------------------
* External interface to the scanner.
*---------------------------------------------------------------------------*/

int wcsulexe(
  const char unitstr[],
  int *func,
  double *scale,
  double units[WCSUNITS_NTYPE],
  struct wcserr **err)

{
  // Function prototypes.
  int yylex_init_extra(YY_EXTRA_TYPE extra, yyscan_t *yyscanner);
  int yylex_destroy(yyscan_t yyscanner);

  struct wcsulex_extra extra;
  yyscan_t yyscanner;
  yylex_init_extra(&extra, &yyscanner);
  int status = wcsulexe_scanner(unitstr, func, scale, units, err, yyscanner);
  yylex_destroy(yyscanner);

  return status;
}


/*----------------------------------------------------------------------------
* Accumulate a term in a units specification and reset work variables.
*---------------------------------------------------------------------------*/

void add(
  double *factor,
  double types[],
  double *expon,
  double *scale,
  double units[])

{
  *scale *= pow(*factor, *expon);

  for (int i = 0; i < WCSUNITS_NTYPE; i++) {
    units[i] += *expon * types[i];
    types[i] = 0.0;
  }

  *expon  = 1.0;
  *factor = 1.0;

  return;
}
@


8.6
log
@WCSLIB 8.6
@
text
@d2 1
a2 1
  WCSLIB 8.6 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 8.5.1.2 2026/03/29 13:36:16 mcalabre Exp mcalabre $
@


8.6.1.1
log
@WCSLIB 8.6 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 8.6 2026/03/29 13:53:56 mcalabre Exp $
@


8.5
log
@WCSLIB 8.5
@
text
@d2 2
a3 2
  WCSLIB 8.5 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2025, Mark Calabretta
d21 2
a22 2
  http://www.atnf.csiro.au/people/Mark.Calabretta
  $Id: wcsulex.l,v 8.4.1.2 2025/12/06 13:37:16 mcalabre Exp mcalabre $
@


8.5.1.1
log
@WCSLIB 8.5 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 8.5 2025/12/06 13:47:41 mcalabre Exp $
@


8.5.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2026, Mark Calabretta
d21 2
a22 2
  http://www.atnf.csiro.au/computing/software/wcs
  $Id: wcsulex.l,v 8.5.1.1 2025/12/06 14:05:15 mcalabre Exp mcalabre $
@


8.4
log
@WCSLIB 8.4
@
text
@d2 2
a3 2
  WCSLIB 8.4 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2024, Mark Calabretta
d22 1
a22 1
  $Id: wcsulex.l,v 8.3.1.1 2024/05/13 16:35:39 mcalabre Exp mcalabre $
@


8.4.1.1
log
@WCSLIB 8.4 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 8.4 2024/10/28 13:56:16 mcalabre Exp $
@


8.4.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2025, Mark Calabretta
d22 1
a22 1
  $Id: wcsulex.l,v 8.4.1.1 2024/10/28 13:58:41 mcalabre Exp mcalabre $
@


8.3
log
@WCSLIB 8.3
@
text
@d2 1
a2 1
  WCSLIB 8.3 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 8.2.1.2 2024/04/02 14:01:58 mcalabre Exp mcalabre $
@


8.3.1.1
log
@WCSLIB 8.3 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 8.3 2024/05/13 16:33:00 mcalabre Exp $
@


8.2
log
@WCSLIB 8.2
@
text
@d2 2
a3 2
  WCSLIB 8.2 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2023, Mark Calabretta
d22 1
a22 1
  $Id: wcsulex.l,v 8.1.1.1 2023/07/05 17:15:00 mcalabre Exp mcalabre $
@


8.2.1.1
log
@WCSLIB 8.2 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 8.2 2023/11/16 10:00:29 mcalabre Exp $
@


8.2.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2024, Mark Calabretta
d22 1
a22 1
  $Id: wcsulex.l,v 8.2.1.1 2023/11/16 10:05:57 mcalabre Exp mcalabre $
@


8.1
log
@WCSLIB 8.1
@
text
@d2 1
a2 1
  WCSLIB 8.1 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 8.0.1.1 2023/07/01 06:22:44 mcalabre Exp mcalabre $
@


8.1.1.1
log
@WCSLIB 8.1 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 8.1 2023/07/05 17:12:07 mcalabre Exp $
@


8.0
log
@WCSLIB 8.0
@
text
@d2 1
a2 1
  WCSLIB 8.0 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 7.13.1.2 2023/06/15 04:17:20 mcalabre Exp mcalabre $
@


8.0.1.1
log
@WCSLIB 8.0 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 8.0 2023/07/01 06:15:04 mcalabre Exp $
@


7.13
log
@WCSLIB 7.13
@
text
@d2 2
a3 2
  WCSLIB 7.13 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2022, Mark Calabretta
d22 1
a22 1
  $Id: wcsulex.l,v 7.12.1.1 2022/09/09 05:00:36 mcalabre Exp mcalabre $
@


7.13.1.1
log
@WCSLIB 7.13 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.13 2022/10/07 03:43:35 mcalabre Exp $
@


7.13.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2023, Mark Calabretta
d22 1
a22 1
  $Id: wcsulex.l,v 7.13.1.1 2022/10/07 03:45:47 mcalabre Exp mcalabre $
@


7.12
log
@WCSLIB 7.12
@
text
@d2 1
a2 1
  WCSLIB 7.12 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 7.11.1.1 2022/04/26 06:15:32 mcalabre Exp mcalabre $
@


7.12.1.1
log
@WCSLIB 7.12 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.12 2022/09/09 04:57:58 mcalabre Exp $
@


7.11
log
@WCSLIB 7.11
@
text
@d2 1
a2 1
  WCSLIB 7.11 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 7.10.1.1 2022/04/23 14:26:54 mcalabre Exp mcalabre $
@


7.11.1.1
log
@WCSLIB 7.11 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.11 2022/04/26 06:13:52 mcalabre Exp $
@


7.10
log
@WCSLIB 7.10
@
text
@d2 1
a2 1
  WCSLIB 7.10 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 7.9.1.1 2022/03/25 15:16:40 mcalabre Exp mcalabre $
@


7.10.1.1
log
@WCSLIB 7.10 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.10 2022/04/23 14:25:15 mcalabre Exp $
@


7.9
log
@WCSLIB 7.9
@
text
@d2 1
a2 1
  WCSLIB 7.9 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 7.8.1.1 2022/03/25 06:14:14 mcalabre Exp mcalabre $
@


7.9.1.1
log
@WCSLIB 7.9 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.9 2022/03/25 15:14:48 mcalabre Exp $
@


7.8
log
@WCSLIB 7.8
@
text
@d2 1
a2 1
  WCSLIB 7.8 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 7.7.1.2 2022/03/25 06:05:59 mcalabre Exp mcalabre $
@


7.8.1.1
log
@WCSLIB 7.8 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.8 2022/03/25 06:11:49 mcalabre Exp $
@


7.7
log
@WCSLIB 7.7
@
text
@d2 2
a3 2
  WCSLIB 7.7 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2021, Mark Calabretta
d22 1
a22 1
  $Id: wcsulex.l,v 7.6.1.2 2021/07/01 08:43:02 mcalabre Exp mcalabre $
@


7.7.1.1
log
@WCSLIB 7.7 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.7 2021/07/12 06:36:49 mcalabre Exp $
@


7.7.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2022, Mark Calabretta
d22 1
a22 1
  $Id: wcsulex.l,v 7.7.1.1 2021/07/12 06:38:27 mcalabre Exp mcalabre $
@


7.6
log
@WCSLIB 7.6
@
text
@d2 1
a2 1
  WCSLIB 7.6 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 7.5.1.1 2021/03/20 05:56:42 mcalabre Exp mcalabre $
a1017 2
  static const char *function = "wcsulexe";

@


7.6.1.1
log
@WCSLIB 7.6 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.6 2021/04/13 12:57:01 mcalabre Exp $
@


7.6.1.2
log
@In wcsulexe(), quelled a warning from gcc 11.1.0: "unused variable
‘function’ [-Wunused-variable]".
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.6.1.1 2021/04/13 13:00:35 mcalabre Exp mcalabre $
d1018 2
@


7.5
log
@WCSLIB 7.5
@
text
@d2 1
a2 1
  WCSLIB 7.5 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 7.4.1.3 2021/02/25 13:58:40 mcalabre Exp mcalabre $
@


7.5.1.1
log
@WCSLIB 7.5 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.5 2021/03/20 05:54:58 mcalabre Exp $
@


7.4
log
@WCSLIB 7.4
@
text
@d2 1
a2 1
  WCSLIB 7.4 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: wcsulex.l,v 7.3.1.4 2021/01/28 12:29:30 mcalabre Exp mcalabre $
d44 1
d95 5
a99 3
static int wcsulex_scanner(const char unitstr[], int *func, double *scale,
                           double units[WCSUNITS_NTYPE], struct wcserr **err,
                           yyscan_t yyscanner);
d101 1
a101 25
//----------------------------------------------------------------------------

int wcsulexe(
  const char unitstr[],
  int *func,
  double *scale,
  double units[WCSUNITS_NTYPE],
  struct wcserr **err)

{
  int status;
  yyscan_t yyscanner;
  int yylex_init(yyscan_t *yyscanner);
  int yylex_destroy(yyscan_t yyscanner);

  yylex_init(&yyscanner);
  status = wcsulex_scanner(unitstr, func, scale, units, err, yyscanner);
  yylex_destroy(yyscanner);

  return status;
}

//----------------------------------------------------------------------------

#define YY_DECL int wcsulex_scanner(const char unitstr[], int *func, \
d108 5
a112 3
// Used in preempting the call to exit() by yy_fatal_error().
jmp_buf wcsulex_abort_jmp_env;
#define exit(status) longjmp(wcsulex_abort_jmp_env, status)
d117 1
a117 1
	static const char *function = "wcsulexe";
a118 8
	char ctmp[72];
	int bracket  = 0;
	int operator = 0;
	int paren    = 0;
	int status   = 0;
	int func_r, i, j;
	double dexp, expon, factor, factor_r, types[WCSUNITS_NTYPE];
	YY_BUFFER_STATE buf;
d122 8
d132 2
a133 3
	*func = 0;
	for (i = 0; i < WCSUNITS_NTYPE; i++) {
	  units[i] = 0.0;
d136 7
a142 3
	expon  = 1.0;
	factor = 1.0;
	*scale = 1.0;
d152 1
a152 1
	if (setjmp(wcsulex_abort_jmp_env)) {
d282 2
a283 1
	    buf = YY_CURRENT_BUFFER;
d285 2
d875 1
d884 1
d893 1
d902 1
d904 1
d995 1
a995 1
	    for (i = 0; i < WCSUNITS_NTYPE; i++) {
d1007 28
a1045 2
  int i;

d1048 1
a1048 1
  for (i = 0; i < WCSUNITS_NTYPE; i++) {
@


7.4.1.1
log
@WCSLIB 7.4 development branch.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.4 2021/01/31 02:24:51 mcalabre Exp $
@


7.4.1.2
log
@Use of global variable wcsulex_abort_jmp_env potentially made the code
thread-unsafe.  Modified to use the yyextra mechanism instead.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.4.1.1 2021/01/31 02:26:24 mcalabre Exp mcalabre $
a43 1
%option extra-type="struct wcsulex_extra *"
d94 3
a96 5
// User data associated with yyscanner.
struct wcsulex_extra {
  // Used in preempting the call to exit() by yy_fatal_error().
  jmp_buf abort_jmp_env;
};
d98 25
a122 1
#define YY_DECL int wcsulexe_scanner(const char unitstr[], int *func, \
d129 3
a131 5
// Preempt the call to exit() by yy_fatal_error().
#define exit(status) longjmp(yyextra->abort_jmp_env, status);

// Internal helper functions.
static YY_DECL;
d136 1
a136 1
	static const char *function = "wcsulexe_scanner";
d168 1
a168 1
	if (setjmp(yyextra->abort_jmp_env)) {
a1012 28

/*----------------------------------------------------------------------------
* External interface to the scanner.
*---------------------------------------------------------------------------*/

int wcsulexe(
  const char unitstr[],
  int *func,
  double *scale,
  double units[WCSUNITS_NTYPE],
  struct wcserr **err)

{
  static const char *function = "wcsulexe";

  // Function prototypes.
  int yylex_init_extra(YY_EXTRA_TYPE extra, yyscan_t *yyscanner);
  int yylex_destroy(yyscan_t yyscanner);

  struct wcsulex_extra extra;
  yyscan_t yyscanner;
  yylex_init_extra(&extra, &yyscanner);
  int status = wcsulexe_scanner(unitstr, func, scale, units, err, yyscanner);
  yylex_destroy(yyscanner);

  return status;
}

@


7.4.1.3
log
@Converted to C99-style intermingled variable declarations.
@
text
@d22 1
a22 1
  $Id: wcsulex.l,v 7.4.1.2 2021/02/25 13:45:25 mcalabre Exp mcalabre $
d119 8
d130 1
a130 3
	// Initialise returned values.
	*func  = 0;
	*scale = 1.0;
d132 2
a133 1
	for (int i = 0; i < WCSUNITS_NTYPE; i++) {
a134 6
	}
	
	if (err) *err = 0x0;
	
	double types[WCSUNITS_NTYPE];
	for (int i = 0; i < WCSUNITS_NTYPE; i++) {
d137 3
a139 7
	double expon  = 1.0;
	double factor = 1.0;
	
	int bracket  = 0;
	int operator = 0;
	int paren    = 0;
	int status   = 0;
d279 1
a279 2
	    int func_r;
	    double factor_r;
a280 2
	
	    YY_BUFFER_STATE buf = YY_CURRENT_BUFFER;
a868 1
	  int i;
a876 1
	  int i;
a884 1
	  int i, j;
a892 1
	  char ctmp[72];
a893 1
	  double dexp;
d984 1
a984 1
	    for (int i = 0; i < WCSUNITS_NTYPE; i++) {
d1035 2
d1039 1
a1039 1
  for (int i = 0; i < WCSUNITS_NTYPE; i++) {
@


7.3
log
@WCSLIB 7.3
@
text
@d2 2
a3 3

  WCSLIB 7.3 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2020, Mark Calabretta
a19 2
  Direct correspondence concerning WCSLIB to mark@@calabretta.id.au

d22 1
a22 1
  $Id: wcsulex.l,v 7.2.1.1 2020/03/09 07:34:50 mcalabre Exp mcalabre $
d98 1
a98 1
/*--------------------------------------------------------------------------*/
d120 1
a120 1
/*--------------------------------------------------------------------------*/
d126 1
a126 1
/* Dummy definition to circumvent compiler warnings. */
d129 1
a129 1
/* Used in preempting the call to exit() by yy_fatal_error(). */
d160 1
a160 1
	/* Avert a flex-induced memory leak. */
d167 1
a167 1
	/* Return here via longjmp() invoked by yy_fatal_error(). */
d180 1
a180 1
	  /* Pretend initial whitespace doesn't exist. */
d222 1
a222 1
	  /* Leading binary multiply. */
d228 1
a228 1
" "+	  /* Discard whitespace in INITIAL context. */
d237 1
a237 1
	  /* Gather terms in parentheses. */
d291 1
a291 1
	    /* Not balanced yet. */
d295 1
a295 1
	    /* Balanced; strip off the outer parentheses and recurse. */
d421 1
a421 1
	  /* Internal parser error. */
d428 1
a428 1
	  /* Ampere. */
d435 1
a435 1
	  /* Julian year (annum). */
d442 1
a442 1
	  /* Analogue-to-digital converter units. */
d448 1
a448 1
	  /* Angstrom. */
d455 1
a455 1
	  /* Minute of arc. */
d462 1
a462 1
	  /* Second of arc. */
d469 1
a469 1
	  /* Astronomical unit. */
d476 1
a476 1
	  /* Barn. */
d483 1
a483 1
	  /* Beam, as in Jy/beam. */
d489 1
a489 1
	  /* Bin (e.g. histogram). */
d495 1
a495 1
	  /* Bit. */
d501 1
a501 1
	  /* Byte. */
d508 1
a508 1
	  /* Coulomb. */
d514 1
a514 1
	  /* Candela. */
d520 1
a520 1
	  /* Channel. */
d526 1
a526 1
	  /* Count. */
d532 1
a532 1
	  /* Julian century. */
d539 1
a539 1
	  /* Debye. */
d547 1
a547 1
	  /* Day. */
d554 1
a554 1
	  /* Degree. */
d560 1
a560 1
	  /* Erg. */
d569 1
a569 1
	  /* Electron volt. */
d578 1
a578 1
	  /* Farad. */
d587 1
a587 1
	  /* Gauss. */
d596 1
a596 1
	  /* Gram. */
d603 1
a603 1
	  /* Henry. */
d612 1
a612 1
	  /* Hour. */
d619 1
a619 1
	  /* Hertz. */
d625 1
a625 1
	  /* Joule. */
d633 1
a633 1
	  /* Jansky. */
d641 1
a641 1
	  /* Kelvin. */
d647 1
a647 1
	  /* Lumen. */
d654 1
a654 1
	  /* Lux. */
d662 1
a662 1
	  /* Light year. */
d669 1
a669 1
	  /* Metre. */
d675 1
a675 1
	  /* Stellar magnitude. */
d681 1
a681 1
	  /* Milli-arcsec. */
d688 1
a688 1
	  /* Minute. */
d695 1
a695 1
	  /* Mole. */
d701 1
a701 1
	  /* Newton. */
d709 1
a709 1
	  /* Ohm. */
d718 1
a718 1
	  /* Pascal. */
d726 1
a726 1
	  /* Parsec. */
d733 1
a733 1
	  /* Photon. */
d739 1
a739 1
	  /* Pixel. */
d745 1
a745 1
	  /* Rayleigh. */
d754 1
a754 1
	  /* Radian. */
d761 1
a761 1
	  /* Rydberg. */
d770 1
a770 1
	  /* Siemen. */
d779 1
a779 1
	  /* Second. */
d785 1
a785 1
	  /* Solar luminosity. */
d794 1
a794 1
	  /* Solar mass. */
d801 1
a801 1
	  /* Solar radius. */
d808 1
a808 1
	  /* Steradian. */
d814 1
a814 1
	  /* Sun (with respect to). */
d820 1
a820 1
	  /* Tesla. */
d828 1
a828 1
	  /* Turn. */
d835 1
a835 1
	  /* Unified atomic mass unit. */
d842 1
a842 1
	  /* Volt. */
d851 1
a851 1
	  /* Voxel. */
d857 1
a857 1
	  /* Watt. */
d865 1
a865 1
	  /* Weber. */
d874 1
a874 1
	  /* Internal parser error. */
d881 1
a881 1
	  /* Exponentiation. */
d921 1
a921 1
	  /* Multiply. */
d931 1
a931 1
	  /* Multiply. */
d942 1
a942 1
	  /* Multiply. */
d952 1
a952 1
	  /* Divide. */
d975 1
a975 1
	  /* Discard any remaining input. */
d979 1
a979 1
	  /* End-of-string. */
@


7.3.1.1
log
@WCSLIB 7.3 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 7.3 2020/06/03 03:37:02 mcalabre Exp $
@


7.3.1.2
log
@Switched to C99 style commenting (i.e. using //) within the code.
@
text
@d2 1
d25 1
a25 1
  $Id: wcsulex.l,v 7.3.1.1 2020/06/03 03:38:10 mcalabre Exp mcalabre $
d101 1
a101 1
//----------------------------------------------------------------------------
d123 1
a123 1
//----------------------------------------------------------------------------
d129 1
a129 1
// Dummy definition to circumvent compiler warnings.
d132 1
a132 1
// Used in preempting the call to exit() by yy_fatal_error().
d163 1
a163 1
	// Avert a flex-induced memory leak.
d170 1
a170 1
	// Return here via longjmp() invoked by yy_fatal_error().
d183 1
a183 1
	  // Pretend initial whitespace doesn't exist.
d225 1
a225 1
	  // Leading binary multiply.
d231 1
a231 1
" "+	  // Discard whitespace in INITIAL context.
d240 1
a240 1
	  // Gather terms in parentheses.
d294 1
a294 1
	    // Not balanced yet.
d298 1
a298 1
	    // Balanced; strip off the outer parentheses and recurse.
d424 1
a424 1
	  // Internal parser error.
d431 1
a431 1
	  // Ampere.
d438 1
a438 1
	  // Julian year (annum).
d445 1
a445 1
	  // Analogue-to-digital converter units.
d451 1
a451 1
	  // Angstrom.
d458 1
a458 1
	  // Minute of arc.
d465 1
a465 1
	  // Second of arc.
d472 1
a472 1
	  // Astronomical unit.
d479 1
a479 1
	  // Barn.
d486 1
a486 1
	  // Beam, as in Jy/beam.
d492 1
a492 1
	  // Bin (e.g. histogram).
d498 1
a498 1
	  // Bit.
d504 1
a504 1
	  // Byte.
d511 1
a511 1
	  // Coulomb.
d517 1
a517 1
	  // Candela.
d523 1
a523 1
	  // Channel.
d529 1
a529 1
	  // Count.
d535 1
a535 1
	  // Julian century.
d542 1
a542 1
	  // Debye.
d550 1
a550 1
	  // Day.
d557 1
a557 1
	  // Degree.
d563 1
a563 1
	  // Erg.
d572 1
a572 1
	  // Electron volt.
d581 1
a581 1
	  // Farad.
d590 1
a590 1
	  // Gauss.
d599 1
a599 1
	  // Gram.
d606 1
a606 1
	  // Henry.
d615 1
a615 1
	  // Hour.
d622 1
a622 1
	  // Hertz.
d628 1
a628 1
	  // Joule.
d636 1
a636 1
	  // Jansky.
d644 1
a644 1
	  // Kelvin.
d650 1
a650 1
	  // Lumen.
d657 1
a657 1
	  // Lux.
d665 1
a665 1
	  // Light year.
d672 1
a672 1
	  // Metre.
d678 1
a678 1
	  // Stellar magnitude.
d684 1
a684 1
	  // Milli-arcsec.
d691 1
a691 1
	  // Minute.
d698 1
a698 1
	  // Mole.
d704 1
a704 1
	  // Newton.
d712 1
a712 1
	  // Ohm.
d721 1
a721 1
	  // Pascal.
d729 1
a729 1
	  // Parsec.
d736 1
a736 1
	  // Photon.
d742 1
a742 1
	  // Pixel.
d748 1
a748 1
	  // Rayleigh.
d757 1
a757 1
	  // Radian.
d764 1
a764 1
	  // Rydberg.
d773 1
a773 1
	  // Siemen.
d782 1
a782 1
	  // Second.
d788 1
a788 1
	  // Solar luminosity.
d797 1
a797 1
	  // Solar mass.
d804 1
a804 1
	  // Solar radius.
d811 1
a811 1
	  // Steradian.
d817 1
a817 1
	  // Sun (with respect to).
d823 1
a823 1
	  // Tesla.
d831 1
a831 1
	  // Turn.
d838 1
a838 1
	  // Unified atomic mass unit.
d845 1
a845 1
	  // Volt.
d854 1
a854 1
	  // Voxel.
d860 1
a860 1
	  // Watt.
d868 1
a868 1
	  // Weber.
d877 1
a877 1
	  // Internal parser error.
d884 1
a884 1
	  // Exponentiation.
d924 1
a924 1
	  // Multiply.
d934 1
a934 1
	  // Multiply.
d945 1
a945 1
	  // Multiply.
d955 1
a955 1
	  // Divide.
d978 1
a978 1
	  // Discard any remaining input.
d982 1
a982 1
	  // End-of-string.
@


7.3.1.3
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2021, Mark Calabretta
d24 1
a24 1
  $Id: wcsulex.l,v 7.3.1.2 2020/08/17 11:19:09 mcalabre Exp mcalabre $
@


7.3.1.4
log
@Removed my email address from the copyright notice.
@
text
@d20 2
d24 1
a24 1
  $Id: wcsulex.l,v 7.3.1.3 2021/01/19 14:09:10 mcalabre Exp mcalabre $
@


7.2
log
@WCSLIB 7.2
@
text
@d3 1
a3 1
  WCSLIB 7.2 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 7.1.1.1 2019/12/31 13:28:19 mcalabre Exp mcalabre $
@


7.2.1.1
log
@WCSLIB 7.2 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 7.2 2020/03/09 07:31:23 mcalabre Exp $
@


7.1
log
@WCSLIB 7.1
@
text
@d3 1
a3 1
  WCSLIB 7.1 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 6.4.1.3 2019/12/31 03:28:03 mcalabre Exp mcalabre $
@


7.1.1.1
log
@WCSLIB 7.1 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 7.1 2019/12/31 13:25:19 mcalabre Exp $
@


6.4
log
@WCSLIB 6.4
@
text
@d3 2
a4 2
  WCSLIB 6.4 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2019, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 6.3.1.1 2019/07/12 07:34:37 mcalabre Exp mcalabre $
a86 4
/* To get the prototype for fileno() from stdio.h when gcc is invoked with
 * -std=c89 (same as -ansi) or -std=c99 since we do not define YY_INPUT. */
#define _POSIX_SOURCE 1

d128 3
@


6.4.1.1
log
@WCSLIB 6.4 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 6.4 2019/08/15 09:30:18 mcalabre Exp $
@


6.4.1.2
log
@Provide a dummy definition of YY_INPUT to quell compiler warnings,
particularly from Microsoft Visual C++ (MSVC).
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 6.4.1.1 2019/08/15 09:31:29 mcalabre Exp mcalabre $
d87 4
a131 3

/* Dummy definition to circumvent compiler warnings. */
#define YY_INPUT(inbuff, count, bufsize) { count = YY_NULL; }
@


6.4.1.3
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2020, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 6.4.1.2 2019/12/16 03:34:03 mcalabre Exp mcalabre $
@


6.3
log
@WCSLIB 6.3
@
text
@d3 1
a3 1
  WCSLIB 6.3 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 6.2.1.3 2019/07/08 08:02:29 mcalabre Exp mcalabre $
@


6.3.1.1
log
@WCSLIB 6.3 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 6.3 2019/07/12 07:33:39 mcalabre Exp $
@


6.2
log
@WCSLIB 6.2
@
text
@d3 2
a4 2
  WCSLIB 6.2 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2018, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 6.1.1.1 2018/10/19 08:36:15 mcalabre Exp mcalabre $
d42 1
@


6.2.1.1
log
@WCSLIB 6.2 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 6.2 2018/10/20 10:03:13 mcalabre Exp $
@


6.2.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2019, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 6.2.1.1 2018/10/20 10:04:15 mcalabre Exp mcalabre $
@


6.2.1.3
log
@Set '%option noinput' to quench -Wunused-function compiler warnings that
arise from not using flex's input() function.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 6.2.1.3 2019/07/08 06:55:39 mcalabre Exp mcalabre $
a41 1
%option noinput
@


6.1
log
@WCSLIB 6.1
@
text
@d3 1
a3 1
  WCSLIB 6.1 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.20.1.2 2018/10/19 07:34:25 mcalabre Exp mcalabre $
@


6.1.1.1
log
@WCSLIB 6.1 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 6.1 2018/10/19 08:35:17 mcalabre Exp $
@


5.20
log
@WCSLIB 5.20
@
text
@d3 1
a3 1
  WCSLIB 5.20 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.19.1.1 2018/07/26 15:41:40 mcalabre Exp mcalabre $
d74 1
a74 1
GENERAL	  deg|arcmin|arcsec|mas|d|h|min|erg|Ry|u|D
d438 1
a438 1
	  /* Year (annum). */
d534 7
d827 7
@


5.20.1.1
log
@WCSLIB 5.20 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.20 2018/10/05 05:32:41 mcalabre Exp $
@


5.20.1.2
log
@Recognise new units added by WCS Paper VII: turn, cy (Julian century).
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.20.1.1 2018/10/05 05:33:33 mcalabre Exp mcalabre $
d74 1
a74 1
GENERAL	  deg|arcmin|arcsec|mas|turn|min|h|d|cy|erg|Ry|u|D
d438 1
a438 1
	  /* Julian year (annum). */
a533 7
<UNITS>cy {
	  /* Julian century. */
	  factor *= 3155760000.0;
	  types[WCSUNITS_TIME] += 1.0;
	  BEGIN(EXPON);
	}

a819 7
	  BEGIN(EXPON);
	}

<UNITS>turn {
	  /* Turn. */
	  factor *= 360.0;
	  types[WCSUNITS_PLANE_ANGLE] += 1.0;
@


5.19
log
@WCSLIB 5.19
@
text
@d3 1
a3 1
  WCSLIB 5.19 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.18.1.1 2018/01/10 08:33:04 mcalabre Exp mcalabre $
@


5.19.1.1
log
@WCSLIB 5.19 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.19 2018/07/26 15:37:04 mcalabre Exp $
@


5.18
log
@WCSLIB 5.18
@
text
@d3 1
a3 1
  WCSLIB 5.18 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.17.1.3 2018/01/10 08:25:34 mcalabre Exp mcalabre $
@


5.18.1.1
log
@WCSLIB 5.18 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.18 2018/01/10 08:32:14 mcalabre Exp $
@


5.17
log
@WCSLIB 5.17
@
text
@d3 2
a4 2
  WCSLIB 5.17 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2017, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 5.16.1.2 2017/09/12 13:30:44 mcalabre Exp mcalabre $
d29 1
a29 1
* recursive, multi-buffered lexical scanner that parses FITS units
d45 1
d100 31
a130 2
#define YY_DECL int wcsulexe(const char unitstr[], int *func, double *scale, \
                             double units[WCSUNITS_NTYPE], struct wcserr **err)
a150 1
	int yylex_destroy(void);
d165 1
a165 1
	  yy_delete_buffer(YY_CURRENT_BUFFER);
d168 1
a168 1
	yy_scan_string(unitstr);
d303 1
a303 1
	    yy_switch_to_buffer(buf);
a971 2
	
	  yylex_destroy();
@


5.17.1.1
log
@WCSLIB 5.17 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.17 2017/09/18 08:44:23 mcalabre Exp $
@


5.17.1.2
log
@Implemented as a reentrant scanner (with the same API) by means of a thin
wrapper over the original Flex scanner modified as required (with changed
API) to use the "reentrant" option.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.17.1.1 2017/09/18 08:45:59 mcalabre Exp mcalabre $
d29 1
a29 1
* recursive, multi-buffered lexical scanner and parser for FITS units
a44 1
%option reentrant
d99 2
a100 31
static int wcsulex_scanner(const char unitstr[], int *func, double *scale,
                           double units[WCSUNITS_NTYPE], struct wcserr **err,
                           yyscan_t yyscanner);

/*--------------------------------------------------------------------------*/

int wcsulexe(
  const char unitstr[],
  int *func,
  double *scale,
  double units[WCSUNITS_NTYPE],
  struct wcserr **err)

{
  int status;
  yyscan_t yyscanner;
  int yylex_init(yyscan_t *yyscanner);
  int yylex_destroy(yyscan_t yyscanner);

  yylex_init(&yyscanner);
  status = wcsulex_scanner(unitstr, func, scale, units, err, yyscanner);
  yylex_destroy(yyscanner);

  return status;
}

/*--------------------------------------------------------------------------*/

#define YY_DECL int wcsulex_scanner(const char unitstr[], int *func, \
 double *scale, double units[WCSUNITS_NTYPE], struct wcserr **err, \
 yyscan_t yyscanner)
d121 1
d136 1
a136 1
	  yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
d139 1
a139 1
	yy_scan_string(unitstr, yyscanner);
d274 1
a274 1
	    yy_switch_to_buffer(buf, yyscanner);
d943 2
@


5.17.1.3
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2018, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 5.17.1.2 2017/12/05 01:38:46 mcalabre Exp mcalabre $
@


5.16
log
@WCSLIB 5.16
@
text
@d3 1
a3 1
  WCSLIB 5.16 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.15.1.2 2017/01/15 04:14:00 mcalabre Exp mcalabre $
d873 1
a873 1
	  wcsutil_str2double(ctmp, "%lf", &dexp);
@


5.16.1.1
log
@WCSLIB 5.16 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.16 2017/01/15 04:25:01 mcalabre Exp $
@


5.16.1.2
log
@Revised argument list to wcsutil_str2double().
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.16.1.1 2017/01/15 04:28:59 mcalabre Exp mcalabre $
d873 1
a873 1
	  wcsutil_str2double(ctmp, &dexp);
@


5.15
log
@WCSLIB 5.15
@
text
@d3 2
a4 2
  WCSLIB 5.15 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2016, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 5.14.1.2 2016/04/05 12:40:52 mcalabre Exp mcalabre $
@


5.15.1.1
log
@WCSLIB 5.15 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.15 2016/04/05 12:55:10 mcalabre Exp $
@


5.15.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2017, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 5.15.1.1 2016/04/05 12:58:35 mcalabre Exp mcalabre $
@


5.14
log
@WCSLIB 5.14
@
text
@d3 1
a3 1
  WCSLIB 5.14 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.13.1.3 2016/02/07 10:35:39 mcalabre Exp mcalabre $
d135 1
a135 1
	if (YY_CURRENT_BUFFER->yy_input_file == stdin) {
@


5.14.1.1
log
@WCSLIB 5.14 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.14 2016/02/07 10:49:31 mcalabre Exp $
@


5.14.1.2
log
@Bug fix for the previous change reported by Tammo Jan Dijkema.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.14.1.1 2016/02/07 10:52:44 mcalabre Exp mcalabre $
d135 1
a135 1
	if (YY_CURRENT_BUFFER && YY_CURRENT_BUFFER->yy_input_file == stdin) {
@


5.13
log
@WCSLIB 5.13
@
text
@d3 1
a3 1
  WCSLIB 5.13 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.12.1.2 2016/01/25 05:17:04 mcalabre Exp mcalabre $
d133 5
@


5.13.1.1
log
@WCSLIB 5.13 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.13 2016/01/26 08:51:13 mcalabre Exp $
@


5.13.1.2
log
@Added yy_delete_buffer(YY_CURRENT_BUFFER) before yy_scan_string(unitstr) as
a workaround for a memory leak introduced by a change (bug) in flex in
Aug/2012.  Reported, and fix supplied by Thomas Robitaille and Erik Bray.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.13.1.1 2016/01/26 08:54:32 mcalabre Exp mcalabre $
a133 1
	yy_delete_buffer(YY_CURRENT_BUFFER);
@


5.13.1.3
log
@Refinement of previous change to allow for recursion - don't delete
YY_CURRENT_BUFFER before yy_scan_string() unless it is stdin.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.13.1.2 2016/02/07 08:35:55 mcalabre Exp mcalabre $
d134 1
a134 5
	/* Avert a flex-induced memory leak. */
	if (YY_CURRENT_BUFFER->yy_input_file == stdin) {
	  yy_delete_buffer(YY_CURRENT_BUFFER);
	}
	
@


5.12
log
@WCSLIB 5.12
@
text
@d3 2
a4 2
  WCSLIB 5.12 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2015, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 5.11.1.1 2015/10/18 09:16:27 mcalabre Exp mcalabre $
@


5.12.1.1
log
@WCSLIB 5.12 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.12 2015/11/15 02:13:00 mcalabre Exp $
@


5.12.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2016, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 5.12.1.1 2015/11/15 02:16:14 mcalabre Exp mcalabre $
@


5.11
log
@WCSLIB 5.11
@
text
@d3 1
a3 1
  WCSLIB 5.11 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.10.1.1 2015/10/09 08:22:35 mcalabre Exp mcalabre $
@


5.11.1.1
log
@WCSLIB 5.11 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.11 2015/10/18 09:13:05 mcalabre Exp $
@


5.10
log
@WCSLIB 5.10
@
text
@d3 1
a3 1
  WCSLIB 5.10 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.9.1.1 2015/07/21 09:28:07 mcalabre Exp mcalabre $
@


5.10.1.1
log
@WCSLIB 5.10 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.10 2015/10/09 08:19:15 mcalabre Exp $
@


5.9
log
@WCSLIB 5.9
@
text
@d3 1
a3 1
  WCSLIB 5.9 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.8.1.1 2015/07/08 11:07:18 mcalabre Exp mcalabre $
@


5.9.1.1
log
@WCSLIB 5.9 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.9 2015/07/21 09:20:01 mcalabre Exp $
@


5.8
log
@WCSLIB 5.8
@
text
@d3 1
a3 1
  WCSLIB 5.8 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.7.1.1 2015/06/29 02:47:24 mcalabre Exp mcalabre $
@


5.8.1.1
log
@WCSLIB 5.8 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.8 2015/07/08 11:03:59 mcalabre Exp $
@


5.7
log
@WCSLIB 5.7
@
text
@d3 1
a3 1
  WCSLIB 5.7 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.6.1.1 2015/06/14 07:14:44 mcalabre Exp mcalabre $
@


5.7.1.1
log
@WCSLIB 5.7 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.7 2015/06/29 02:44:16 mcalabre Exp $
@


5.6
log
@WCSLIB 5.6
@
text
@d3 1
a3 1
  WCSLIB 5.6 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.5.1.1 2015/05/05 13:21:00 mcalabre Exp mcalabre $
@


5.6.1.1
log
@WCSLIB 5.6 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.6 2015/06/14 07:11:24 mcalabre Exp $
@


5.5
log
@WCSLIB 5.5
@
text
@d3 1
a3 1
  WCSLIB 5.5 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.4.1.1 2015/04/21 14:44:28 mcalabre Exp mcalabre $
@


5.5.1.1
log
@WCSLIB 5.5 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.5 2015/05/05 13:16:31 mcalabre Exp $
@


5.4
log
@WCSLIB 5.4
@
text
@d3 1
a3 1
  WCSLIB 5.4 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.3.1.1 2015/04/21 02:54:02 mcalabre Exp mcalabre $
@


5.4.1.1
log
@WCSLIB 5.4 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.4 2015/04/21 14:41:05 mcalabre Exp $
@


5.3
log
@WCSLIB 5.3
@
text
@d3 1
a3 1
  WCSLIB 5.3 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.2.1.1 2015/04/15 12:39:14 mcalabre Exp mcalabre $
@


5.3.1.1
log
@WCSLIB 5.3 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.3 2015/04/21 02:50:51 mcalabre Exp $
@


5.2
log
@WCSLIB 5.2
@
text
@d3 1
a3 1
  WCSLIB 5.2 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.1.1.1 2015/04/07 11:01:10 mcalabre Exp mcalabre $
@


5.2.1.1
log
@WCSLIB 5.2 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.2 2015/04/15 12:35:07 mcalabre Exp $
@


5.1
log
@WCSLIB 5.1
@
text
@d3 1
a3 1
  WCSLIB 5.1 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 5.0.1.1 2015/04/05 12:28:00 mcalabre Exp mcalabre $
@


5.1.1.1
log
@WCSLIB 5.1 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.1 2015/04/07 10:56:36 mcalabre Exp $
@


5.0
log
@WCSLIB 5.0
@
text
@d3 1
a3 1
  WCSLIB 5.0 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.25.1.2 2015/01/06 01:01:06 mcalabre Exp mcalabre $
@


5.0.1.1
log
@WCSLIB 5.0 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 5.0 2015/04/05 12:24:59 mcalabre Exp $
@


4.25
log
@WCSLIB 4.25
@
text
@d3 2
a4 2
  WCSLIB 4.25 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2014, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 4.24.1.1 2014/09/18 15:28:09 mcalabre Exp mcalabre $
@


4.25.1.1
log
@WCSLIB 4.25 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.25 2014/12/14 14:29:36 mcalabre Exp $
@


4.25.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2015, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 4.25.1.1 2014/12/14 14:32:45 mcalabre Exp mcalabre $
@


4.24
log
@WCSLIB 4.24
@
text
@d3 1
a3 1
  WCSLIB 4.24 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.23.1.1 2014/05/13 05:53:49 mcalabre Exp mcalabre $
@


4.24.1.1
log
@WCSLIB 4.24 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.24 2014/09/18 15:25:00 mcalabre Exp $
@


4.23
log
@WCSLIB 4.23
@
text
@d3 1
a3 1
  WCSLIB 4.23 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.22.1.1 2014/04/12 15:06:32 mcalabre Exp mcalabre $
@


4.23.1.1
log
@WCSLIB 4.23 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.23 2014/05/13 05:50:51 mcalabre Exp $
@


4.22
log
@WCSLIB 4.22
@
text
@d3 1
a3 1
  WCSLIB 4.22 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.21.1.1 2014/03/24 05:15:28 mcalabre Exp mcalabre $
@


4.22.1.1
log
@WCSLIB 4.22 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.22 2014/04/12 15:03:52 mcalabre Exp $
@


4.21
log
@WCSLIB 4.21
@
text
@d3 1
a3 1
  WCSLIB 4.21 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.20.1.2 2014/03/21 06:32:19 mcalabre Exp mcalabre $
@


4.21.1.1
log
@WCSLIB 4.21 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.21 2014/03/24 05:12:27 mcalabre Exp $
@


4.20
log
@WCSLIB 4.20
@
text
@d3 2
a4 2
  WCSLIB 4.20 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2013, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 4.19.1.1 2013/09/29 14:20:38 mcalabre Exp mcalabre $
@


4.20.1.1
log
@WCSLIB 4.20 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.20 2013/12/18 05:42:49 mcalabre Exp $
@


4.20.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2014, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 4.20.1.1 2013/12/18 05:46:55 mcalabre Exp mcalabre $
@


4.19
log
@WCSLIB 4.19
@
text
@d3 1
a3 1
  WCSLIB 4.19 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.18.1.1 2013/07/13 10:02:37 mcalabre Exp mcalabre $
@


4.19.1.1
log
@WCSLIB 4.19 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.19 2013/09/29 14:17:51 mcalabre Exp $
@


4.18
log
@WCSLIB 4.18
@
text
@d3 1
a3 1
  WCSLIB 4.18 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.17.1.1 2013/01/29 05:32:32 cal103 Exp cal103 $
@


4.18.1.1
log
@WCSLIB 4.18 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.18 2013/07/13 10:00:04 mcalabre Exp $
@


4.17
log
@WCSLIB 4.17
@
text
@d3 1
a3 1
  WCSLIB 4.17 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.16.1.3 2013/01/29 03:43:47 cal103 Exp cal103 $
@


4.17.1.1
log
@WCSLIB 4.17 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.17 2013/01/29 05:29:20 cal103 Exp $
@


4.16
log
@WCSLIB 4.16
@
text
@d3 2
a4 2
  WCSLIB 4.16 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2012, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 4.15.1.1 2012/09/26 14:27:51 cal103 Exp cal103 $
d100 1
a100 1
                             double units[], struct wcserr **err)
@


4.16.1.1
log
@WCSLIB 4.16 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.16 2012/11/07 04:42:44 cal103 Exp $
@


4.16.1.2
log
@Indicate the expected size of the array, units[WCSUNITS_NTYPE], in the
function prototype for wcsulexe().
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.16.1.1 2012/11/07 04:45:56 cal103 Exp cal103 $
d100 1
a100 1
                             double units[WCSUNITS_NTYPE], struct wcserr **err)
@


4.16.1.3
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2013, Mark Calabretta
d25 1
a25 1
  $Id: wcsulex.l,v 4.16.1.2 2012/11/28 13:04:03 cal103 Exp cal103 $
@


4.15
log
@WCSLIB 4.15
@
text
@d3 1
a3 1
  WCSLIB 4.15 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.14.1.2 2012/09/26 07:53:12 cal103 Exp cal103 $
@


4.15.1.1
log
@WCSLIB 4.15 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.15 2012/09/26 14:26:05 cal103 Exp $
@


4.14
log
@WCSLIB 4.14
@
text
@d3 1
a3 1
  WCSLIB 4.14 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: wcsulex.l,v 4.13.1.3 2012/07/13 03:34:20 cal103 Exp cal103 $
d110 2
a111 2

        char ctmp[72];
d123 2
@


4.14.1.1
log
@WCSLIB 4.14 development branch.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.14 2012/07/13 10:02:27 cal103 Exp $
@


4.14.1.2
log
@Bug fix for error reporting, initialize the wcserr pointer.
@
text
@d25 1
a25 1
  $Id: wcsulex.l,v 4.14.1.1 2012/07/13 10:04:44 cal103 Exp cal103 $
d110 2
a111 2
	
	char ctmp[72];
a122 2
	if (err) *err = 0x0;
	
@


4.13
log
@WCSLIB 4.13
@
text
@d3 1
a3 1
  WCSLIB 4.13 - an implementation of the FITS WCS standard.
d19 1
a19 1
  along with WCSLIB.  If not, see <http://www.gnu.org/licenses/>.
d21 5
a25 11
  Correspondence concerning WCSLIB may be directed to:
    Internet email: mcalabre@@atnf.csiro.au
    Postal address: Dr. Mark Calabretta
                    Australia Telescope National Facility, CSIRO
                    PO Box 76
                    Epping NSW 1710
                    AUSTRALIA

  Author: Mark Calabretta, Australia Telescope National Facility
  http://www.atnf.csiro.au/~mcalabre/index.html
  $Id: wcsulex.l,v 4.12.1.1 2012/02/29 07:59:10 cal103 Exp cal103 $
d97 1
d111 1
d865 2
a866 1
	  sscanf(yytext, " (%lf)", &dexp);
@


4.13.1.1
log
@WCSLIB 4.13 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.13 2012/03/14 07:39:30 cal103 Exp $
@


4.13.1.2
log
@Handle locales such as fr_FR where a comma is used to delimit the decimal
part of a floating point number.  Patch provided by Michael Droettboom.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.13.1.1 2012/03/14 07:40:37 cal103 Exp cal103 $
a102 1
#include "wcsutil.h"
a115 1
        char ctmp[72];
d869 1
a869 2
	  sscanf(yytext, " (%s)", ctmp);
	  wcsutil_str2double(ctmp, "%lf", &dexp);
@


4.13.1.3
log
@Changed contact details.
@
text
@d19 1
a19 1
  along with WCSLIB.  If not, see http://www.gnu.org/licenses.
d21 11
a31 5
  Direct correspondence concerning WCSLIB to mark@@calabretta.id.au

  Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
  http://www.atnf.csiro.au/people/Mark.Calabretta
  $Id: wcsulex.l,v 4.13.1.2 2012/07/12 15:24:27 cal103 Exp cal103 $
@


4.12
log
@WCSLIB 4.12
@
text
@d3 1
a3 1
  WCSLIB 4.12 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: wcsulex.l,v 4.11.1.1 2012/02/20 23:31:13 cal103 Exp cal103 $
@


4.12.1.1
log
@WCSLIB 4.12 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.12 2012/02/29 07:57:56 cal103 Exp $
@


4.11
log
@WCSLIB 4.11
@
text
@d3 1
a3 1
  WCSLIB 4.11 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: wcsulex.l,v 4.10.1.1 2012/02/05 23:42:46 cal103 Exp cal103 $
@


4.11.1.1
log
@WCSLIB 4.11 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.11 2012/02/20 23:30:02 cal103 Exp $
@


4.10
log
@WCSLIB 4.10
@
text
@d3 1
a3 1
  WCSLIB 4.10 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: wcsulex.l,v 4.9.1.1 2012/01/24 05:41:45 cal103 Exp cal103 $
@


4.10.1.1
log
@WCSLIB 4.10 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.10 2012/02/05 23:41:44 cal103 Exp $
@


4.9
log
@WCSLIB 4.9
@
text
@d3 1
a3 1
  WCSLIB 4.9 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: wcsulex.l,v 4.8.1.2 2012/01/24 05:23:06 cal103 Exp cal103 $
@


4.9.1.1
log
@WCSLIB 4.9 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.9 2012/01/24 05:40:29 cal103 Exp $
@


4.8
log
@WCSLIB 4.8
@
text
@d3 2
a4 2
  WCSLIB 4.8 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2011, Mark Calabretta
d31 1
a31 1
  $Id: wcsulex.l,v 4.7.1.3 2011/08/09 02:43:50 cal103 Exp cal103 $
@


4.8.1.1
log
@WCSLIB 4.8 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.8 2011/08/15 08:05:53 cal103 Exp $
@


4.8.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2012, Mark Calabretta
d31 1
a31 1
  $Id: wcsulex.l,v 4.8.1.1 2011/08/15 08:07:06 cal103 Exp cal103 $
@


4.7
log
@WCSLIB 4.7
@
text
@d3 1
a3 1
  WCSLIB 4.7 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: wcsulex.l,v 4.6.1.3 2011/01/25 00:26:16 cal103 Exp cal103 $
d100 1
d104 2
a105 2
#define YY_DECL int wcsulex(const char unitstr[], int *func, double *scale, \
                            double units[])
d114 2
d140 2
a141 1
	  return 9;
d164 2
a165 1
	  status = 1;
d194 2
a195 1
	  status = 2;
d248 2
a249 1
	  status = 3;
d270 1
a270 1
	    status = wcsulex(yytext+1, &func_r, &factor_r, types);
d274 2
a275 1
	      status = 4;
d393 2
a394 1
	  status = 9;
d832 2
a833 1
	  status = 9;
d925 2
a926 1
	  status = 5;
d943 2
a944 1
	    status = 6;
d946 5
a950 1
	    status = 7;
d952 2
a953 1
	    status = (operator == 1) ? 2 : 8;
@


4.7.1.1
log
@WCSLIB 4.7 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.7 2011/02/07 07:03:42 cal103 Exp $
@


4.7.1.2
log
@Added error messaging based on wcserr.  Changes supplied by Michael
Droettboom (STScI) with respect to the released WCSLIB 4.7 sources.
@
text
@a44 2
/* ERRTODO: Be more specific about where in the unit string the error occurred. */

a99 1
#include "wcserr.h"
d103 2
a104 2
#define YY_DECL int wcsulex_err(const char unitstr[], int *func, double *scale, \
                                double units[], struct wcserr* err)
d137 1
a137 3
          return WCSERR_SET(
            err, UNITSERR_PARSER_ERROR,
            "Internal units parser error parsing '%s'", unitstr);
d160 1
a160 3
          status = WCSERR_SET(
            err, UNITSERR_BAD_NUM_MULTIPLIER,
            "Invalid numeric multiplier in '%s'", unitstr);
d189 1
a189 3
          status = WCSERR_SET(
            err, UNITSERR_DANGLING_BINOP,
            "Dangling binary operator in '%s'", unitstr);
d242 1
a242 3
          status = WCSERR_SET(
            err, UNITSERR_BAD_INITIAL_SYMBOL,
            "Invalid symbol in INITIAL context in '%s'", unitstr);
d263 1
a263 1
            status = wcsulex_err(yytext+1, &func_r, &factor_r, types, err);
d267 1
a267 3
              status = WCSERR_SET(
                err, UNITSERR_FUNCTION_CONTEXT,
                "Function in invalid context in '%s'", unitstr);
d385 1
a385 3
          status = WCSERR_SET(
            err, UNITSERR_PARSER_ERROR,
            "Internal units parser error parsing '%s'", unitstr);
d823 1
a823 3
          status = WCSERR_SET(
            err, UNITSERR_PARSER_ERROR,
            "Internal units parser error parsing '%s'", unitstr);
d915 1
a915 3
          status = WCSERR_SET(
            err, UNITSERR_BAD_EXPON_SYMBOL,
            "Invalid symbol in EXPON context in '%s'", unitstr);
d932 1
a932 3
            status = WCSERR_SET(
              err, UNITSERR_UNBAL_BRACKET,
              "Unbalanced bracket in '%s'", unitstr);
d934 1
a934 7
            status = WCSERR_SET(
              err, UNITSERR_UNBAL_PAREN,
              "Unbalanced parenthesis in '%s'", unitstr);
          } else if (operator == 1) {
            status = WCSERR_SET(
              err, UNITSERR_DANGLING_BINOP,
              "Dangling binary operator in '%s'", unitstr);
d936 1
a936 3
            status = WCSERR_SET(
              err, UNITSERR_CONSEC_BINOPS,
              "Consecutive binary operators in '%s'", unitstr);
@


4.7.1.3
log
@Revised implementation of Michael Droettboom's error messaging system.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.7.1.1 2011/02/07 07:04:22 cal103 Exp cal103 $
d45 2
d106 2
a107 2
#define YY_DECL int wcsulexe(const char unitstr[], int *func, double *scale, \
                             double units[], struct wcserr **err)
a115 2
	static const char *function = "wcsulexe";

d140 3
a142 2
	  return wcserr_set(WCSERR_SET(UNITSERR_PARSER_ERROR),
	    "Internal units parser error parsing '%s'", unitstr);
d165 3
a167 2
	  status = wcserr_set(WCSERR_SET(UNITSERR_BAD_NUM_MULTIPLIER),
	    "Invalid exponent in '%s'", unitstr);
d196 3
a198 2
	  status = wcserr_set(WCSERR_SET(UNITSERR_DANGLING_BINOP),
	    "Dangling binary operator in '%s'", unitstr);
d251 3
a253 2
	  status = wcserr_set(WCSERR_SET(UNITSERR_BAD_INITIAL_SYMBOL),
	    "Invalid symbol in INITIAL context in '%s'", unitstr);
d274 1
a274 1
	    status = wcsulexe(yytext+1, &func_r, &factor_r, types, err);
d278 3
a280 2
	      status = wcserr_set(WCSERR_SET(UNITSERR_FUNCTION_CONTEXT),
	        "Function in invalid context in '%s'", unitstr);
d398 3
a400 2
	  status = wcserr_set(WCSERR_SET(UNITSERR_PARSER_ERROR),
	    "Internal units parser error parsing '%s'", unitstr);
d838 3
a840 2
	  status = wcserr_set(WCSERR_SET(UNITSERR_PARSER_ERROR),
	    "Internal units parser error parsing '%s'", unitstr);
d932 3
a934 2
	  status = wcserr_set(WCSERR_SET(UNITSERR_BAD_EXPON_SYMBOL),
	    "Invalid symbol in EXPON context in '%s'", unitstr);
d951 3
a953 2
	    status = wcserr_set(WCSERR_SET(UNITSERR_UNBAL_BRACKET),
	      "Unbalanced bracket in '%s'", unitstr);
d955 7
a961 5
	    status = wcserr_set(WCSERR_SET(UNITSERR_UNBAL_PAREN),
	      "Unbalanced parenthesis in '%s'", unitstr);
	  } else if (operator == 1) {
	    status = wcserr_set(WCSERR_SET(UNITSERR_DANGLING_BINOP),
	      "Dangling binary operator in '%s'", unitstr);
d963 3
a965 2
	    status = wcserr_set(WCSERR_SET(UNITSERR_CONSEC_BINOPS),
	      "Consecutive binary operators in '%s'", unitstr);
@


4.6
log
@WCSLIB 4.6
@
text
@d3 2
a4 2
  WCSLIB 4.6 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2010, Mark Calabretta
d31 1
a31 1
  $Id: wcsulex.l,v 4.5.1.2 2010/11/15 01:10:45 cal103 Exp cal103 $
d143 1
a143 1
	printf("\n%s ->\n", unitstr);
d939 1
a939 1
	    printf("EOS\n");
@


4.6.1.1
log
@WCSLIB 4.6 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.6 2010/11/16 06:15:31 cal103 Exp $
@


4.6.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2011, Mark Calabretta
d31 1
a31 1
  $Id: wcsulex.l,v 4.6.1.1 2010/11/16 06:16:19 cal103 Exp cal103 $
@


4.6.1.3
log
@Replaced calls to printf() with fprintf(stderr,...) in the debug
statements.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.6.1.2 2011/01/14 06:33:16 cal103 Exp cal103 $
d143 1
a143 1
	fprintf(stderr, "\n%s ->\n", unitstr);
d939 1
a939 1
	    fprintf(stderr, "EOS\n");
@


4.5
log
@WCSLIB 4.5
@
text
@d3 1
a3 1
  WCSLIB 4.5 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: wcsulex.l,v 4.4.1.4 2010/01/19 03:42:50 cal103 Exp cal103 $
d98 1
@


4.5.1.1
log
@WCSLIB 4.5 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.5 2010/07/16 07:01:25 cal103 Exp $
@


4.5.1.2
log
@stdlib.h must be included before the redefinition of exit(), reported
by Peter Williams.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.5.1.1 2010/07/16 07:05:31 cal103 Exp cal103 $
a97 1
#include <stdlib.h>
@


4.4
log
@WCSLIB 4.4
@
text
@d3 2
a4 2
  WCSLIB 4.4 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2009, Mark Calabretta
d31 1
a31 1
  $Id: wcsulex.l,v 4.3.1.3 2009/07/22 04:53:58 cal103 Exp cal103 $
d72 1
a72 1
/* Additional recognized units: only super-metric prefixes. */
a104 5
#ifdef DEBUG
  /* Print text as it is matched. */
  #define YY_USER_ACTION printf("Rule %03d: \"%s\"\n", yy_act, yytext);
#endif

d146 1
a146 1
	  /* Rule 001: Pretend initial whitespace doesn't exist. */
a150 1
	  /* Rule 002. */
a158 1
	  /* Rule 003. */
a163 1
	  /* Rule 004. */
a168 1
	  /* Rule 005. */
a174 1
	  /* Rule 006. */
a180 1
	  /* Rule 007. */
d187 1
a187 1
	  /* Rule 008: Leading binary multiply. */
d192 1
a192 1
" "+	  /* Rule 009: Discard whitespace in INITIAL context. */
a194 1
	  /* Rule 010. */
d201 1
a201 1
	  /* Rule 011: Gather terms in parentheses. */
a206 1
	  /* Rule 012. */
d212 1
a213 1
	  /* Rule 013. */
d216 1
a216 1
	  } else if (*yytext == '/') {
a221 1
	  /* Rule 014. */
a229 1
	  /* Rules 015-017. */
a235 1
	  /* Rule 018. */
a240 1
	  /* Rule 019. */
a245 1
	  /* Rule 020. */
a251 1
	  /* Rule 022. */
a278 1
	  /* Rule 022. */
a282 1
	  /* Rule 023. */
a287 1
	  /* Rule 024. */
a292 1
	  /* Rule 025. */
a297 1
	  /* Rule 026. */
a302 1
	  /* Rule 027. */
a307 1
	  /* Rule 028. */
a312 1
	  /* Rule 029. */
a317 1
	  /* Rule 030. */
a322 1
	  /* Rule 031. */
a327 1
	  /* Rule 032. */
a332 1
	  /* Rule 033. */
a337 1
	  /* Rule 034. */
a342 1
	  /* Rule 035. */
a347 1
	  /* Rule 036. */
a352 1
	  /* Rule 037. */
a357 1
	  /* Rule 038. */
a362 1
	  /* Rule 039. */
a367 1
	  /* Rule 040. */
a372 1
	  /* Rule 041. */
a377 1
	  /* Rule 042. */
d383 1
a383 1
	  /* Rule 043: Internal parser error. */
d389 1
a389 1
	  /* Rule 044: Ampere. */
d396 1
a396 1
	  /* Rule 045: Year (annum). */
d403 1
a403 1
	  /* Rule 046: Analogue-to-digital converter units. */
d409 1
a409 1
	  /* Rule 047: Angstrom. */
d416 1
a416 1
	  /* Rule 048: Minute of arc. */
d423 1
a423 1
	  /* Rule 049: Second of arc. */
d430 1
a430 1
	  /* Rule 050: Astronomical unit. */
d437 1
a437 1
	  /* Rule 051: Barn. */
d444 1
a444 1
	  /* Rule 052: Beam, as in Jy/beam. */
d450 1
a450 1
	  /* Rule 053: Bin (e.g. histogram). */
d456 1
a456 1
	  /* Rule 054: Bit. */
d462 1
a462 1
	  /* Rule 055: Byte. */
d469 1
a469 1
	  /* Rule 056: Coulomb. */
d475 1
a475 1
	  /* Rule 057: Candela. */
d481 1
a481 1
	  /* Rule 058: Channel. */
d487 1
a487 1
	  /* Rule 059: Count. */
d493 1
a493 1
	  /* Rule 060: Debye. */
d501 1
a501 1
	  /* Rule 061: Day. */
d508 1
a508 1
	  /* Rule 062: Degree. */
d514 1
a514 1
	  /* Rule 063: Erg. */
d523 1
a523 1
	  /* Rule 064: Electron volt. */
d532 1
a532 1
	  /* Rule 065: Farad. */
d541 1
a541 1
	  /* Rule 066: Gauss. */
d550 1
a550 1
	  /* Rule 067: Gram. */
d557 1
a557 1
	  /* Rule 068: Henry. */
d566 1
a566 1
	  /* Rule 069: Hour. */
d573 1
a573 1
	  /* Rule 070: Hertz. */
d579 1
a579 1
	  /* Rule 071: Joule. */
d587 1
a587 1
	  /* Rule 072: Jansky. */
d595 1
a595 1
	  /* Rule 073: Kelvin. */
d601 1
a601 1
	  /* Rule 074: Lumen. */
d608 1
a608 1
	  /* Rule 075: Lux. */
d616 1
a616 1
	  /* Rule 076: Light year. */
d623 1
a623 1
	  /* Rule 077: Metre. */
d629 1
a629 1
	  /* Rule 078: Stellar magnitude. */
d635 1
a635 1
	  /* Rule 079: Milli-arcsec. */
d642 1
a642 1
	  /* Rule 080: Minute. */
d649 1
a649 1
	  /* Rule 081: Mole. */
d655 1
a655 1
	  /* Rule 082: Newton. */
d663 1
a663 1
	  /* Rule 083: Ohm. */
d672 1
a672 1
	  /* Rule 084: Pascal. */
d680 1
a680 1
	  /* Rule 085: Parsec. */
d687 1
a687 1
	  /* Rule 086: Photon. */
d693 1
a693 1
	  /* Rule 087: Pixel. */
d699 1
a699 1
	  /* Rule 088: Rayleigh. */
d708 1
a708 1
	  /* Rule 089: Radian. */
d715 1
a715 1
	  /* Rule 090: Rydberg. */
d724 1
a724 1
	  /* Rule 091: Siemen. */
d733 1
a733 1
	  /* Rule 092: Second. */
d739 1
a739 1
	  /* Rule 093: Solar luminosity. */
d748 1
a748 1
	  /* Rule 094: Solar mass. */
d755 1
a755 1
	  /* Rule 095: Solar radius. */
d762 1
a762 1
	  /* Rule 096: Steradian. */
d768 1
a768 1
	  /* Rule 097: Sun (with respect to). */
d774 1
a774 1
	  /* Rule 098: Tesla. */
d782 1
a782 1
	  /* Rule 099: Unified atomic mass unit. */
d789 1
a789 1
	  /* Rule 100: Volt. */
d798 1
a798 1
	  /* Rule 101: Voxel. */
d804 1
a804 1
	  /* Rule 102: Watt. */
d812 1
a812 1
	  /* Rule 103: Weber. */
d821 1
a821 1
	  /* Rule 104: Internal parser error. */
d827 1
a827 1
	  /* Rule 105: Exponentiation. */
a833 1
	  /* Rule 106. */
a841 1
	  /* Rule 107. */
a849 1
	  /* Rule 108. */
a857 1
	  /* Rule 109. */
d866 1
a866 1
	  /* Rule 110: Multiply. */
d876 1
a876 1
	  /* Rule 111: Multiply. */
d887 1
a887 1
	  /* Rule 112: Multiply. */
d897 1
a897 1
	  /* Rule 113: Divide. */
a907 1
	  /* Rule 114. */
a913 1
	  /* Rule 115. */
d919 1
a919 1
	  /* Rule 116: Discard any remaining input. */
d923 1
a923 1
	  /* Rule unnumbered: End-of-string. */
@


4.4.1.1
log
@WCSLIB 4.4 development branch.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.4 2009/08/06 07:41:33 cal103 Exp $
@


4.4.1.2
log
@Removed the high-maintenance rule numbering and the debug output
implemented via YY_USER_ACTION since flex's '--debug' option provides
what's needed.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.4.1.1 2009/08/10 08:52:49 cal103 Exp cal103 $
d105 5
d151 1
a151 1
	  /* Pretend initial whitespace doesn't exist. */
d156 1
d165 1
d171 1
d177 1
d184 1
d191 1
d198 1
a198 1
	  /* Leading binary multiply. */
d203 1
a203 1
" "+	  /* Discard whitespace in INITIAL context. */
d206 1
d213 1
a213 1
	  /* Gather terms in parentheses. */
d219 1
d226 1
d235 1
d244 1
d251 1
d257 1
d263 1
d270 1
d298 1
d303 1
d309 1
d315 1
d321 1
d327 1
d333 1
d339 1
d345 1
d351 1
d357 1
d363 1
d369 1
d375 1
d381 1
d387 1
d393 1
d399 1
d405 1
d411 1
d417 1
d423 1
a423 1
	  /* Internal parser error. */
d429 1
a429 1
	  /* Ampere. */
d436 1
a436 1
	  /* Year (annum). */
d443 1
a443 1
	  /* Analogue-to-digital converter units. */
d449 1
a449 1
	  /* Angstrom. */
d456 1
a456 1
	  /* Minute of arc. */
d463 1
a463 1
	  /* Second of arc. */
d470 1
a470 1
	  /* Astronomical unit. */
d477 1
a477 1
	  /* Barn. */
d484 1
a484 1
	  /* Beam, as in Jy/beam. */
d490 1
a490 1
	  /* Bin (e.g. histogram). */
d496 1
a496 1
	  /* Bit. */
d502 1
a502 1
	  /* Byte. */
d509 1
a509 1
	  /* Coulomb. */
d515 1
a515 1
	  /* Candela. */
d521 1
a521 1
	  /* Channel. */
d527 1
a527 1
	  /* Count. */
d533 1
a533 1
	  /* Debye. */
d541 1
a541 1
	  /* Day. */
d548 1
a548 1
	  /* Degree. */
d554 1
a554 1
	  /* Erg. */
d563 1
a563 1
	  /* Electron volt. */
d572 1
a572 1
	  /* Farad. */
d581 1
a581 1
	  /* Gauss. */
d590 1
a590 1
	  /* Gram. */
d597 1
a597 1
	  /* Henry. */
d606 1
a606 1
	  /* Hour. */
d613 1
a613 1
	  /* Hertz. */
d619 1
a619 1
	  /* Joule. */
d627 1
a627 1
	  /* Jansky. */
d635 1
a635 1
	  /* Kelvin. */
d641 1
a641 1
	  /* Lumen. */
d648 1
a648 1
	  /* Lux. */
d656 1
a656 1
	  /* Light year. */
d663 1
a663 1
	  /* Metre. */
d669 1
a669 1
	  /* Stellar magnitude. */
d675 1
a675 1
	  /* Milli-arcsec. */
d682 1
a682 1
	  /* Minute. */
d689 1
a689 1
	  /* Mole. */
d695 1
a695 1
	  /* Newton. */
d703 1
a703 1
	  /* Ohm. */
d712 1
a712 1
	  /* Pascal. */
d720 1
a720 1
	  /* Parsec. */
d727 1
a727 1
	  /* Photon. */
d733 1
a733 1
	  /* Pixel. */
d739 1
a739 1
	  /* Rayleigh. */
d748 1
a748 1
	  /* Radian. */
d755 1
a755 1
	  /* Rydberg. */
d764 1
a764 1
	  /* Siemen. */
d773 1
a773 1
	  /* Second. */
d779 1
a779 1
	  /* Solar luminosity. */
d788 1
a788 1
	  /* Solar mass. */
d795 1
a795 1
	  /* Solar radius. */
d802 1
a802 1
	  /* Steradian. */
d808 1
a808 1
	  /* Sun (with respect to). */
d814 1
a814 1
	  /* Tesla. */
d822 1
a822 1
	  /* Unified atomic mass unit. */
d829 1
a829 1
	  /* Volt. */
d838 1
a838 1
	  /* Voxel. */
d844 1
a844 1
	  /* Watt. */
d852 1
a852 1
	  /* Weber. */
d861 1
a861 1
	  /* Internal parser error. */
d867 1
a867 1
	  /* Exponentiation. */
d874 1
d883 1
d892 1
d901 1
d910 1
a910 1
	  /* Multiply. */
d920 1
a920 1
	  /* Multiply. */
d931 1
a931 1
	  /* Multiply. */
d941 1
a941 1
	  /* Divide. */
d952 1
d959 1
d965 1
a965 1
	  /* Discard any remaining input. */
d969 1
a969 1
	  /* End-of-string. */
@


4.4.1.3
log
@Allow unit strings like "1/m" in addition to "/m", provided that the "1"
is the first (non-blank) character in the expression, or sub-expression.
@
text
@d31 1
a31 1
  $Id: wcsulex.l,v 4.4.1.2 2009/09/03 02:42:20 cal103 Exp cal103 $
d72 1
a72 1
/* Additional recognized units: only super-metric prefixes allowed. */
a211 1
^1"/" |
d215 1
a215 1
	  } else {
@


4.4.1.4
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2010, Mark Calabretta
d31 1
a31 1
  $Id: wcsulex.l,v 4.4.1.3 2009/09/03 04:51:55 cal103 Exp cal103 $
@


4.3
log
@WCSLIB 4.3
@
text
@d3 2
a4 2
    WCSLIB 4.3 - an implementation of the FITS WCS standard.
    Copyright (C) 1995-2007, Mark Calabretta
d6 1
a6 1
    This file is part of WCSLIB.
d8 24
a31 24
    WCSLIB is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License as published by the
    Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
    more details.

    You should have received a copy of the GNU Lesser General Public License
    along with WCSLIB.  If not, see <http://www.gnu.org/licenses/>.

    Correspondence concerning WCSLIB may be directed to:
       Internet email: mcalabre@@atnf.csiro.au
       Postal address: Dr. Mark Calabretta
                       Australia Telescope National Facility, CSIRO
                       PO Box 76
                       Epping NSW 1710
                       AUSTRALIA

    Author: Mark Calabretta, Australia Telescope National Facility
    http://www.atnf.csiro.au/~mcalabre/index.html
    $Id: wcsulex.l,v 4.2.1.3 2007/12/27 05:09:41 cal103 Exp cal103 $
d34 3
a36 3
*   wcsulex.l is a Flex description file containing the definition of a
*   recursive, multi-buffered lexical scanner that parses FITS units
*   specifications.
d38 1
a38 1
*   It requires Flex v2.5.4 or later.
d40 2
a41 2
*   Refer to wcsunits.h for a description of the user interface and operating
*   notes.
d96 1
d110 3
a112 2
void wcsulex_add(double *factor, double types[], double *expon,
                 double *scale,  double units[]);
d124 3
a126 1
        int yylex_destroy(void);
d138 6
d155 1
a155 1
^"[" {
d170 1
a170 1
^10 {
d197 1
a197 1
^[*.] {
d212 1
a212 1
"(" {
d218 1
a218 1
[*.] {
d225 1
a225 1
"/" {
d256 1
a256 1
. {
d877 1
a877 1
	  wcsulex_add(&factor, types, &expon, scale, units);
d886 1
a886 1
	  wcsulex_add(&factor, types, &expon, scale, units);
d895 1
a895 1
	  wcsulex_add(&factor, types, &expon, scale, units);
d904 1
a904 1
	  wcsulex_add(&factor, types, &expon, scale, units);
d914 1
a914 1
	    wcsulex_add(&factor, types, &expon, scale, units);
d924 1
a924 1
	    wcsulex_add(&factor, types, &expon, scale, units);
d935 1
a935 1
	    wcsulex_add(&factor, types, &expon, scale, units);
d945 1
a945 1
	    wcsulex_add(&factor, types, &expon, scale, units);
d953 1
a953 1
	  wcsulex_add(&factor, types, &expon, scale, units);
d968 1
a968 1
<<EOF>> {
d971 1
a971 1
	    wcsulex_add(&factor, types, &expon, scale, units);
d1001 1
a1001 1
*   Accumulate a term in a units specification and reset work variables.
d1004 1
a1004 1
void wcsulex_add(
@


4.3.1.1
log
@WCSLIB 4.3 development branch.
@
text
@d3 2
a4 2
    WCSLIB 4.4 - an implementation of the FITS WCS standard.
    Copyright (C) 1995-2008, Mark Calabretta
d31 1
a31 1
    $Id: wcsulex.l,v 4.3 2007/12/27 05:41:36 cal103 Exp cal103 $
@


4.3.1.2
log
@Moved the declaration of helper functions out of global scope and
simplified their names.
@
text
@d31 1
a31 1
    $Id: wcsulex.l,v 4.3.1.1 2007/12/27 13:23:47 cal103 Exp cal103 $
d109 3
d122 1
a122 3
	void add(double *factor, double types[], double *expon, double *scale,
	    double units[]);
	int yylex_destroy(void);
d867 1
a867 1
	  add(&factor, types, &expon, scale, units);
d876 1
a876 1
	  add(&factor, types, &expon, scale, units);
d885 1
a885 1
	  add(&factor, types, &expon, scale, units);
d894 1
a894 1
	  add(&factor, types, &expon, scale, units);
d904 1
a904 1
	    add(&factor, types, &expon, scale, units);
d914 1
a914 1
	    add(&factor, types, &expon, scale, units);
d925 1
a925 1
	    add(&factor, types, &expon, scale, units);
d935 1
a935 1
	    add(&factor, types, &expon, scale, units);
d943 1
a943 1
	  add(&factor, types, &expon, scale, units);
d961 1
a961 1
	    add(&factor, types, &expon, scale, units);
d994 1
a994 1
void add(
@


4.3.1.3
log
@Use setjmp/longjmp to preempt the call to exit() by yy_fatal_error();
changed indentation in the prologue.
@
text
@d3 2
a4 2
  WCSLIB 4.4 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2009, Mark Calabretta
d6 1
a6 1
  This file is part of WCSLIB.
d8 24
a31 24
  WCSLIB is free software: you can redistribute it and/or modify it under the
  terms of the GNU Lesser General Public License as published by the Free
  Software Foundation, either version 3 of the License, or (at your option)
  any later version.

  WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
  more details.

  You should have received a copy of the GNU Lesser General Public License
  along with WCSLIB.  If not, see <http://www.gnu.org/licenses/>.

  Correspondence concerning WCSLIB may be directed to:
    Internet email: mcalabre@@atnf.csiro.au
    Postal address: Dr. Mark Calabretta
                    Australia Telescope National Facility, CSIRO
                    PO Box 76
                    Epping NSW 1710
                    AUSTRALIA

  Author: Mark Calabretta, Australia Telescope National Facility
  http://www.atnf.csiro.au/~mcalabre/index.html
  $Id: wcsulex.l,v 4.3.1.2 2008/04/02 03:51:53 cal103 Exp cal103 $
d34 3
a36 3
* wcsulex.l is a Flex description file containing the definition of a
* recursive, multi-buffered lexical scanner that parses FITS units
* specifications.
d38 1
a38 1
* It requires Flex v2.5.4 or later.
d40 2
a41 2
* Refer to wcsunits.h for a description of the user interface and operating
* notes.
a95 1
#include <setjmp.h>
a108 4
/* Used in preempting the call to exit() by yy_fatal_error(). */
jmp_buf wcsulex_abort_jmp_env;
#define exit(status) longjmp(wcsulex_abort_jmp_env, status)

a132 6
	
	/* Return here via longjmp() invoked by yy_fatal_error(). */
	if (setjmp(wcsulex_abort_jmp_env)) {
	  return 9;
	}
	
d144 1
a144 1
^"["	{
d159 1
a159 1
^10	{
d186 1
a186 1
^[*.]	{
d201 1
a201 1
"("	{
d207 1
a207 1
[*.]	{
d214 1
a214 1
"/"	{
d245 1
a245 1
.	{
d957 1
a957 1
<<EOF>>	{
d990 1
a990 1
* Accumulate a term in a units specification and reset work variables.
@


4.2
log
@WCSLIB 4.2: removed #include <unistd.h> - shouldn't be needed.
@
text
@d2 30
a31 28
*
*   WCSLIB 4.2 - an implementation of the FITS WCS standard.
*   Copyright (C) 1995-2005, Mark Calabretta
*
*   WCSLIB is free software; you can redistribute it and/or modify it under
*   the terms of the GNU General Public License as published by the Free
*   Software Foundation; either version 2 of the License, or (at your option)
*   any later version.
*
*   WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
*   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
*   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
*   details.
*
*   You should have received a copy of the GNU General Public License along
*   with WCSLIB; if not, write to the Free Software Foundation, Inc.,
*   59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
*
*   Correspondence concerning WCSLIB may be directed to:
*      Internet email: mcalabre@@atnf.csiro.au
*      Postal address: Dr. Mark Calabretta
*                      Australia Telescope National Facility, CSIRO
*                      PO Box 76
*                      Epping NSW 1710
*                      AUSTRALIA
*
*   Author: Mark Calabretta, Australia Telescope National Facility
*   $Id: wcsulex.l,v 4.1 2005/08/25 07:26:29 cal103 Exp cal103 $
d49 2
d91 4
d122 1
d964 1
a964 1
	  yy_delete_buffer(YY_CURRENT_BUFFER);
@


4.2.1.1
log
@WCSLIB 4.2 development branch.
@
text
@d3 1
a3 1
*   WCSLIB 4.3 - an implementation of the FITS WCS standard.
d29 1
a29 1
*   $Id: wcsulex.l,v 4.2 2005/09/22 08:59:02 cal103 Exp cal103 $
@


4.2.1.2
log
@Switched to LGPL 3.0.
@
text
@d2 28
a29 30

    WCSLIB 4.3 - an implementation of the FITS WCS standard.
    Copyright (C) 1995-2007, Mark Calabretta

    This file is part of WCSLIB.

    WCSLIB is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License as published by the
    Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
    more details.

    You should have received a copy of the GNU Lesser General Public License
    along with WCSLIB.  If not, see <http://www.gnu.org/licenses/>.

    Correspondence concerning WCSLIB may be directed to:
       Internet email: mcalabre@@atnf.csiro.au
       Postal address: Dr. Mark Calabretta
                       Australia Telescope National Facility, CSIRO
                       PO Box 76
                       Epping NSW 1710
                       AUSTRALIA

    Author: Mark Calabretta, Australia Telescope National Facility
    http://www.atnf.csiro.au/~mcalabre/index.html
    $Id: wcsulex.l,v 4.2.1.1 2005/12/05 02:39:43 cal103 Exp cal103 $
@


4.2.1.3
log
@Call yylex_destroy() to free buffer memory rather than yy_delete_buffer()
as the former reinitializes global variables for subsequent calls.  Set
%option for outfile and prefix to save doing it on the flex command line.
Define _POSIX_SOURCE to get the prototype for fileno() from stdio.h when
gcc is invoked with -std=c89 (same as -ansi).
@
text
@d31 1
a31 1
    $Id: wcsulex.l,v 4.2.1.2 2007/12/03 05:02:17 cal103 Exp cal103 $
a48 2
%option outfile="wcsulex.c"
%option prefix="wcsulex"
a88 4
/* To get the prototype for fileno() from stdio.h when gcc is invoked with
 * -std=c89 (same as -ansi) or -std=c99 since we do not define YY_INPUT. */
#define _POSIX_SOURCE 1

a115 1
        int yylex_destroy(void);
d957 1
a957 1
	  yylex_destroy();
@


4.1
log
@WCSLIB 4.1: initial revision.
@
text
@d3 1
a3 1
*   WCSLIB 4.1 - an implementation of the FITS WCS standard.
d29 1
a29 1
*   $Id$
a88 1
#include <unistd.h>
@


0.0
log
@Empty revision
@
text
@d1 1007
@
