aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/symop.y
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel/src/symop.y')
-rw-r--r--libcrystfel/src/symop.y41
1 files changed, 36 insertions, 5 deletions
diff --git a/libcrystfel/src/symop.y b/libcrystfel/src/symop.y
index 4aec791a..a304ea37 100644
--- a/libcrystfel/src/symop.y
+++ b/libcrystfel/src/symop.y
@@ -30,15 +30,20 @@
#include <stdio.h>
#include "rational.h"
+ #include "symmetry.h"
extern int symoplex();
- extern int symopparse(RationalMatrix *m);
- void symoperror(RationalMatrix *m, const char *s);
+ extern int symopparse(RationalMatrix *m, SymOpList *list);
+ void symoperror(RationalMatrix *m, SymOpList *list, const char *s);
%}
%define api.prefix {symop}
-%parse-param {RationalMatrix *m}
+%parse-param {RationalMatrix *m} {SymOpList *list}
+
+%code requires {
+ #include "symmetry.h"
+}
%union {
RationalMatrix *m; /* Full rational matrix */
@@ -47,6 +52,7 @@
int n; /* Just a number */
}
+%token SEMICOLON
%token COMMA
%token NUMBER
%token OPENB CLOSEB
@@ -63,8 +69,33 @@
%type <n> NUMBER
%type <r> fraction
+%{
+static int try_add_symop(SymOpList *list, RationalMatrix *m)
+{
+ if ( list == NULL ) {
+ yyerror(m, list, "Must be a single symmetry operation");
+ return 1;
+ } else {
+ IntegerMatrix *im;
+ im = intmat_from_rtnl_mtx(m);
+ if ( im == NULL ) {
+ yyerror(m, list, "Symmetry operations must all be integer");
+ return 1;
+ } else {
+ add_symop(list, im);
+ }
+ }
+ return 0;
+}
+%}
+
%%
+symoplist:
+ symop { if ( try_add_symop(list, m) ) YYERROR; }
+| symoplist SEMICOLON symop { if ( try_add_symop(list, m) ) YYERROR; }
+;
+
symop:
axexpr COMMA axexpr COMMA axexpr { rtnl_mtx_set(m, 0, 0, $1[0]);
rtnl_mtx_set(m, 0, 1, $1[1]);
@@ -101,6 +132,6 @@ fraction:
%%
-void symoperror(RationalMatrix *m, const char *s) {
- printf("Error\n");
+void symoperror(RationalMatrix *m, SymOpList *list, const char *s) {
+ printf("Error: %s\n", s);
}