fix swedish minus simbol

This commit is contained in:
jriegel 2014-08-03 16:00:59 +02:00
parent ced08b0416
commit 1da5543657
4 changed files with 466 additions and 442 deletions

File diff suppressed because it is too large Load Diff

View File

@ -112,23 +112,24 @@ extern int yydebug;
enum yytokentype {
UNIT = 258,
NUM = 259,
ACOS = 260,
ASIN = 261,
ATAN = 262,
ATAN2 = 263,
COS = 264,
EXP = 265,
ABS = 266,
MOD = 267,
LOG = 268,
LOG10 = 269,
POW = 270,
SIN = 271,
SINH = 272,
TAN = 273,
TANH = 274,
SQRT = 275,
NEG = 276
MINUSSIGN = 260,
ACOS = 261,
ASIN = 262,
ATAN = 263,
ATAN2 = 264,
COS = 265,
EXP = 266,
ABS = 267,
MOD = 268,
LOG = 269,
LOG10 = 270,
POW = 271,
SIN = 272,
SINH = 273,
TAN = 274,
TANH = 275,
SQRT = 276,
NEG = 277
};
#endif
@ -161,7 +162,7 @@ int yyparse ();
/* Copy the second part of user declarations. */
/* Line 390 of yacc.c */
#line 165 "QuantityParser.c"
#line 166 "QuantityParser.c"
#ifdef short
# undef short
@ -390,7 +391,7 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 45
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 262
#define YYLAST 279
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 30
@ -403,7 +404,7 @@ union yyalloc
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 276
#define YYMAXUTOK 277
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@ -415,7 +416,7 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
27, 28, 23, 22, 29, 21, 2, 24, 2, 2,
27, 28, 23, 22, 29, 2, 2, 24, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@ -438,7 +439,7 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 25
15, 16, 17, 18, 19, 20, 21, 25
};
#if YYDEBUG
@ -457,17 +458,17 @@ static const yytype_int8 yyrhs[] =
{
31, 0, -1, -1, 32, -1, 33, -1, 34, -1,
34, 34, -1, 4, -1, 32, 22, 32, -1, 32,
21, 32, -1, 32, 23, 32, -1, 32, 24, 32,
-1, 21, 32, -1, 32, 26, 32, -1, 27, 32,
28, -1, 5, 27, 32, 28, -1, 6, 27, 32,
28, -1, 7, 27, 32, 28, -1, 8, 27, 32,
29, 32, 28, -1, 11, 27, 32, 28, -1, 10,
27, 32, 28, -1, 12, 27, 32, 29, 32, 28,
-1, 13, 27, 32, 28, -1, 14, 27, 32, 28,
-1, 15, 27, 32, 29, 32, 28, -1, 16, 27,
32, 28, -1, 17, 27, 32, 28, -1, 18, 27,
32, 28, -1, 19, 27, 32, 28, -1, 20, 27,
32, 28, -1, 9, 27, 32, 28, -1, 3, -1,
5, 32, -1, 32, 23, 32, -1, 32, 24, 32,
-1, 5, 32, -1, 32, 26, 32, -1, 27, 32,
28, -1, 6, 27, 32, 28, -1, 7, 27, 32,
28, -1, 8, 27, 32, 28, -1, 9, 27, 32,
29, 32, 28, -1, 12, 27, 32, 28, -1, 11,
27, 32, 28, -1, 13, 27, 32, 29, 32, 28,
-1, 14, 27, 32, 28, -1, 15, 27, 32, 28,
-1, 16, 27, 32, 29, 32, 28, -1, 17, 27,
32, 28, -1, 18, 27, 32, 28, -1, 19, 27,
32, 28, -1, 20, 27, 32, 28, -1, 21, 27,
32, 28, -1, 10, 27, 32, 28, -1, 3, -1,
33, 23, 33, -1, 33, 24, 33, -1, 33, 26,
32, -1, 27, 33, 28, -1, 32, 33, -1
};
@ -487,10 +488,11 @@ static const yytype_uint8 yyrline[] =
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"$end", "error", "$undefined", "UNIT", "NUM", "ACOS", "ASIN", "ATAN",
"ATAN2", "COS", "EXP", "ABS", "MOD", "LOG", "LOG10", "POW", "SIN",
"SINH", "TAN", "TANH", "SQRT", "'-'", "'+'", "'*'", "'/'", "NEG", "'^'",
"'('", "')'", "','", "$accept", "input", "num", "unit", "quantity", YY_NULL
"$end", "error", "$undefined", "UNIT", "NUM", "MINUSSIGN", "ACOS",
"ASIN", "ATAN", "ATAN2", "COS", "EXP", "ABS", "MOD", "LOG", "LOG10",
"POW", "SIN", "SINH", "TAN", "TANH", "SQRT", "'+'", "'*'", "'/'", "NEG",
"'^'", "'('", "')'", "','", "$accept", "input", "num", "unit",
"quantity", YY_NULL
};
#endif
@ -501,7 +503,7 @@ static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 45, 43, 42, 47, 276, 94, 40, 41, 44
275, 276, 43, 42, 47, 277, 94, 40, 41, 44
};
# endif
@ -530,9 +532,9 @@ static const yytype_uint8 yydefact[] =
{
2, 31, 7, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 3, 4, 5, 0, 0, 0, 0, 0,
0, 0, 3, 4, 5, 0, 12, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 12, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 36, 0, 0, 0, 0, 6, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 14, 35, 9, 8, 10, 11,
@ -549,26 +551,26 @@ static const yytype_int8 yydefgoto[] =
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
#define YYPACT_NINF -23
#define YYPACT_NINF -26
static const yytype_int16 yypact[] =
{
92, -23, -23, -22, -19, -13, -10, -5, -4, 16,
17, 36, 39, 44, 54, 65, 89, 111, 124, 116,
92, 7, 38, 91, 116, 116, 116, 116, 116, 116,
116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
116, 116, 31, 30, 62, -23, 116, 116, 116, 116,
116, 18, 91, 18, 18, 116, 38, -23, 56, 118,
126, -20, 134, 142, 150, -11, 158, 166, 46, 174,
182, 190, 198, 206, -23, -23, 236, 236, 31, 31,
31, 57, 57, 67, -23, -23, -23, 116, -23, -23,
-23, 116, -23, -23, 116, -23, -23, -23, -23, -23,
214, 222, 230, -23, -23, -23
58, -26, -26, 117, -25, -13, -10, 16, 17, 26,
29, 32, 54, 56, 57, 59, 62, 63, 65, 66,
58, 9, 77, -11, 117, 117, -3, 117, 117, 117,
117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
117, 117, 117, 134, -18, -26, 117, 117, 117, 117,
117, 18, -11, 18, 18, 117, 77, -26, 141, 148,
156, -4, 163, 170, 178, 83, 185, 192, 91, 200,
207, 214, 222, 229, -26, -26, 28, 28, -3, -3,
-3, 69, 69, -15, -26, -26, -26, 117, -26, -26,
-26, 117, -26, -26, 117, -26, -26, -26, -26, -26,
236, 244, 251, -26, -26, -26
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-23, -23, 0, 20, -8
-26, -26, 0, 4, -8
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -577,70 +579,72 @@ static const yytype_int8 yypgoto[] =
#define YYTABLE_NINF -1
static const yytype_uint8 yytable[] =
{
22, 46, 47, 48, 49, 25, 50, 45, 26, 87,
46, 47, 48, 49, 27, 50, 57, 28, 91, 42,
23, 1, 29, 30, 56, 58, 59, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 1, 52, 31, 32, 51, 76, 77, 78, 79,
80, 46, 47, 48, 49, 83, 50, 50, 74, 46,
47, 48, 49, 33, 50, 51, 34, 46, 47, 48,
49, 35, 50, 81, 82, 94, 52, 46, 47, 48,
49, 36, 50, 55, 84, 53, 54, 100, 55, 47,
75, 101, 37, 50, 102, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 53, 54, 38, 55, 0, 20,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 39, 46,
47, 48, 49, 41, 50, 0, 85, 46, 47, 48,
49, 40, 50, 0, 86, 46, 47, 48, 49, 0,
50, 0, 88, 46, 47, 48, 49, 0, 50, 0,
89, 46, 47, 48, 49, 0, 50, 0, 90, 46,
47, 48, 49, 0, 50, 0, 92, 46, 47, 48,
49, 0, 50, 0, 93, 46, 47, 48, 49, 0,
50, 0, 95, 46, 47, 48, 49, 0, 50, 0,
96, 46, 47, 48, 49, 0, 50, 0, 97, 46,
47, 48, 49, 0, 50, 0, 98, 46, 47, 48,
49, 0, 50, 0, 99, 46, 47, 48, 49, 0,
50, 0, 103, 46, 47, 48, 49, 0, 50, 0,
104, 46, 47, 48, 49, 0, 50, 0, 105, 48,
49, 0, 50
22, 46, 27, 26, 23, 53, 54, 47, 55, 45,
75, 50, 53, 54, 28, 55, 57, 29, 47, 48,
49, 1, 50, 50, 56, 87, 52, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 30, 31, 51, 76, 77, 78, 79,
80, 48, 49, 32, 50, 83, 33, 81, 82, 34,
52, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1, 35, 46, 36, 37, 20, 38, 100, 46, 39,
40, 101, 41, 42, 102, 55, 46, 0, 0, 47,
48, 49, 0, 50, 51, 47, 48, 49, 0, 50,
0, 0, 91, 47, 48, 49, 0, 50, 0, 0,
94, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 46,
0, 0, 0, 0, 25, 0, 46, 0, 0, 0,
0, 0, 0, 46, 0, 0, 47, 48, 49, 0,
50, 46, 74, 47, 48, 49, 0, 50, 46, 84,
47, 48, 49, 0, 50, 46, 85, 0, 47, 48,
49, 0, 50, 46, 86, 47, 48, 49, 0, 50,
46, 88, 47, 48, 49, 0, 50, 46, 89, 0,
47, 48, 49, 0, 50, 46, 90, 47, 48, 49,
0, 50, 46, 92, 47, 48, 49, 0, 50, 46,
93, 0, 47, 48, 49, 0, 50, 46, 95, 47,
48, 49, 0, 50, 46, 96, 47, 48, 49, 0,
50, 46, 97, 0, 47, 48, 49, 0, 50, 46,
98, 47, 48, 49, 0, 50, 46, 99, 47, 48,
49, 0, 50, 0, 103, 0, 47, 48, 49, 0,
50, 0, 104, 47, 48, 49, 0, 50, 0, 105
};
#define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-23)))
(!!((Yystate) == (-26)))
#define yytable_value_is_error(Yytable_value) \
YYID (0)
static const yytype_int8 yycheck[] =
{
0, 21, 22, 23, 24, 27, 26, 0, 27, 29,
21, 22, 23, 24, 27, 26, 24, 27, 29, 19,
0, 3, 27, 27, 24, 25, 26, 27, 28, 29,
0, 5, 27, 3, 0, 23, 24, 22, 26, 0,
28, 26, 23, 24, 27, 26, 24, 27, 22, 23,
24, 3, 26, 26, 24, 29, 22, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 3, 22, 27, 27, 27, 46, 47, 48, 49,
50, 21, 22, 23, 24, 55, 26, 26, 28, 21,
22, 23, 24, 27, 26, 27, 27, 21, 22, 23,
24, 27, 26, 53, 54, 29, 56, 21, 22, 23,
24, 27, 26, 26, 28, 23, 24, 87, 26, 22,
28, 91, 27, 26, 94, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 23, 24, 27, 26, -1, 27,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 27, 21,
22, 23, 24, 27, 26, -1, 28, 21, 22, 23,
24, 27, 26, -1, 28, 21, 22, 23, 24, -1,
26, -1, 28, 21, 22, 23, 24, -1, 26, -1,
28, 21, 22, 23, 24, -1, 26, -1, 28, 21,
22, 23, 24, -1, 26, -1, 28, 21, 22, 23,
24, -1, 26, -1, 28, 21, 22, 23, 24, -1,
26, -1, 28, 21, 22, 23, 24, -1, 26, -1,
28, 21, 22, 23, 24, -1, 26, -1, 28, 21,
22, 23, 24, -1, 26, -1, 28, 21, 22, 23,
24, -1, 26, -1, 28, 21, 22, 23, 24, -1,
26, -1, 28, 21, 22, 23, 24, -1, 26, -1,
28, 21, 22, 23, 24, -1, 26, -1, 28, 23,
24, -1, 26
40, 41, 42, 27, 27, 27, 46, 47, 48, 49,
50, 23, 24, 27, 26, 55, 27, 53, 54, 27,
56, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
3, 27, 5, 27, 27, 27, 27, 87, 5, 27,
27, 91, 27, 27, 94, 26, 5, -1, -1, 22,
23, 24, -1, 26, 27, 22, 23, 24, -1, 26,
-1, -1, 29, 22, 23, 24, -1, 26, -1, -1,
29, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 5,
-1, -1, -1, -1, 27, -1, 5, -1, -1, -1,
-1, -1, -1, 5, -1, -1, 22, 23, 24, -1,
26, 5, 28, 22, 23, 24, -1, 26, 5, 28,
22, 23, 24, -1, 26, 5, 28, -1, 22, 23,
24, -1, 26, 5, 28, 22, 23, 24, -1, 26,
5, 28, 22, 23, 24, -1, 26, 5, 28, -1,
22, 23, 24, -1, 26, 5, 28, 22, 23, 24,
-1, 26, 5, 28, 22, 23, 24, -1, 26, 5,
28, -1, 22, 23, 24, -1, 26, 5, 28, 22,
23, 24, -1, 26, 5, 28, 22, 23, 24, -1,
26, 5, 28, -1, 22, 23, 24, -1, 26, 5,
28, 22, 23, 24, -1, 26, 5, 28, 22, 23,
24, -1, 26, -1, 28, -1, 22, 23, 24, -1,
26, -1, 28, 22, 23, 24, -1, 26, -1, 28
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@ -649,9 +653,9 @@ static const yytype_uint8 yystos[] =
{
0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
27, 31, 32, 33, 34, 27, 27, 27, 27, 27,
27, 31, 32, 33, 34, 27, 32, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 32, 32, 33, 0, 21, 22, 23, 24,
27, 27, 27, 32, 33, 0, 5, 22, 23, 24,
26, 27, 33, 23, 24, 26, 32, 34, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 28, 28, 32, 32, 32, 32,
@ -1660,7 +1664,7 @@ yyreduce:
/* Line 1787 of yacc.c */
#line 1664 "QuantityParser.c"
#line 1668 "QuantityParser.c"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires

View File

@ -31,12 +31,15 @@ ID [a-z][a-z0-9]*
<C_COMMENT>"\]" { BEGIN(INITIAL); }
<C_COMMENT>. { ;}
[ \t] ;
[\n]+ ;
[-+()=/*^] { return *yytext; }
[+()=/*^] { return *yytext; }
"-" return MINUSSIGN;
"\xe2\x88\x92" return MINUSSIGN;
"nm" yylval = Quantity::NanoMetre; return UNIT; // nano meter
"um" yylval = Quantity::MicroMetre; return UNIT; // micro meter
"\xC2\xB5m" yylval = Quantity::MicroMetre; return UNIT; // micro meter (greek micro in UTF8)
@ -45,7 +48,7 @@ ID [a-z][a-z0-9]*
"dm" yylval = Quantity::DeciMetre; return UNIT; // deci meter
"m" yylval = Quantity::Metre; return UNIT; // metre
"km" yylval = Quantity::KiloMetre; return UNIT; // kilo meter
"l" yylval = Quantity::Liter; return UNIT; // Liter dm^3
"ug" yylval = Quantity::MicroGram; return UNIT; // micro gram
@ -124,9 +127,11 @@ ID [a-z][a-z0-9]*
"rad" yylval = Quantity::Radian; return UNIT; // radian
"gon" yylval = Quantity::Gon; return UNIT; // gon
{DIGIT}*["."","]{DIGIT}*[eE][-+]?[0-9]+ {for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
{DIGIT}*["."","]{DIGIT}* {for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
{DIGIT}+ {yylval = atof( yytext ); return NUM;}
{DIGIT}*["."","]{DIGIT}*[eE][-+]?[0-9]+ { for(char* c=yytext;*c!='\0';c++) if(*c==',') *c='.'; yylval = atof( yytext ); return NUM; }
{DIGIT}*["."","]{DIGIT}* { for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM; }
{DIGIT}+ { yylval = atof( yytext ); return NUM;}
"pi" {yylval = M_PI ; return NUM;} // constant pi
"e" {yylval = M_E ; return NUM;} // constant e

View File

@ -17,9 +17,9 @@
%}
/* Bison declarations. */
%token UNIT NUM
%token UNIT NUM MINUSSIGN
%token ACOS ASIN ATAN ATAN2 COS EXP ABS MOD LOG LOG10 POW SIN SINH TAN TANH SQRT;
%left '-' '+'
%left MINUSSIGN '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
@ -38,10 +38,10 @@
;
num: NUM { $$ = $1; }
| num '+' num { $$ = $1.getValue() + $3.getValue(); }
| num '-' num { $$ = $1.getValue() - $3.getValue(); }
| num MINUSSIGN num { $$ = $1.getValue() - $3.getValue(); }
| num '*' num { $$ = $1.getValue() * $3.getValue(); }
| num '/' num { $$ = $1.getValue() / $3.getValue(); }
| '-' num %prec NEG { $$ = -$2.getValue(); }
| MINUSSIGN num %prec NEG { $$ = -$2.getValue(); }
| num '^' num { $$ = pow ($1.getValue(), $3.getValue());}
| '(' num ')' { $$ = $2; }
| ACOS '(' num ')' { $$ = acos($3.getValue()); }