Skip to content

Commit

Permalink
fix: add support for svh, lvh, dvh, svw, lvw, dvw, svmin, lvmin, dvmi…
Browse files Browse the repository at this point in the history
…n, svmax, lvmax, dvmax units
  • Loading branch information
geecko86 committed Aug 11, 2024
1 parent dabface commit dff94f7
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
40 changes: 40 additions & 0 deletions parser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,29 @@
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)ch\b return 'CHS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)rem\b return 'REMS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)vw\b return 'VWS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)svw\b return 'SVWS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)lvw\b return 'LVWS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)dvw\b return 'DVWS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)vh\b return 'VHS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)svh\b return 'SVHS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)lvh\b return 'LVHS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)dvh\b return 'DVHS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)vmin\b return 'VMINS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)svmin\b return 'SVMINS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)lvmin\b return 'LVMINS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)dvmin\b return 'DVMINS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)vmax\b return 'VMAXS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)svmax\b return 'SVMAXS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)lvmax\b return 'LVMAXS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)dvmax\b return 'DVMAXS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)vb\b return 'VBS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)svb\b return 'SVBS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)lvb\b return 'LVBS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)dvb\b return 'DVBS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)vi\b return 'VIS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)svi\b return 'SVIS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)lvi\b return 'LVIS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)dvi\b return 'DVIS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)cqw\b return 'CQWS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)cqh\b return 'CQHS';
(([0-9]+("."[0-9]+)?|"."[0-9]+)(e(\+|-)[0-9]+)?)cqi\b return 'CQIS';
Expand Down Expand Up @@ -102,9 +122,29 @@ expression
| CHS { $$ = { type: 'ChValue', value: parseFloat($1), unit: 'ch' }; }
| REMS { $$ = { type: 'RemValue', value: parseFloat($1), unit: 'rem' }; }
| VHS { $$ = { type: 'VhValue', value: parseFloat($1), unit: 'vh' }; }
| SVHS { $$ = { type: 'SvhValue', value: parseFloat($1), unit: 'svh' }; }
| LVHS { $$ = { type: 'LvhValue', value: parseFloat($1), unit: 'lvh' }; }
| DVHS { $$ = { type: 'DvhValue', value: parseFloat($1), unit: 'dvh' }; }
| VWS { $$ = { type: 'VwValue', value: parseFloat($1), unit: 'vw' }; }
| SVWS { $$ = { type: 'SvwValue', value: parseFloat($1), unit: 'svw' }; }
| LVWS { $$ = { type: 'LvwValue', value: parseFloat($1), unit: 'lvw' }; }
| DVWS { $$ = { type: 'DvwValue', value: parseFloat($1), unit: 'dvw' }; }
| VMINS { $$ = { type: 'VminValue', value: parseFloat($1), unit: 'vmin' }; }
| SVMINS { $$ = { type: 'SvminValue', value: parseFloat($1), unit: 'svmin' }; }
| LVMINS { $$ = { type: 'LvminValue', value: parseFloat($1), unit: 'lvmin' }; }
| DVMINS { $$ = { type: 'DvminValue', value: parseFloat($1), unit: 'dvmin' }; }
| VMAXS { $$ = { type: 'VmaxValue', value: parseFloat($1), unit: 'vmax' }; }
| SVMAXS { $$ = { type: 'SvmaxValue', value: parseFloat($1), unit: 'svmax' }; }
| LVMAXS { $$ = { type: 'LvmaxValue', value: parseFloat($1), unit: 'lvmax' }; }
| DVMAXS { $$ = { type: 'DvmaxValue', value: parseFloat($1), unit: 'dvmax' }; }
| VBS { $$ = { type: 'VbValue', value: parseFloat($1), unit: 'vb' }; }
| SVBS { $$ = { type: 'SvbValue', value: parseFloat($1), unit: 'svb' }; }
| LVBS { $$ = { type: 'LvbValue', value: parseFloat($1), unit: 'lvb' }; }
| DVBS { $$ = { type: 'DvbValue', value: parseFloat($1), unit: 'dvb' }; }
| VIS { $$ = { type: 'VhValue', value: parseFloat($1), unit: 'vi' }; }
| SVIS { $$ = { type: 'SvhValue', value: parseFloat($1), unit: 'svi' }; }
| LVIS { $$ = { type: 'LvhValue', value: parseFloat($1), unit: 'lvi' }; }
| DVIS { $$ = { type: 'DvhValue', value: parseFloat($1), unit: 'dvi' }; }
| CQWS { $$ = { type: 'CqwValue', value: parseFloat($1), unit: 'cqw' }; }
| CQHS { $$ = { type: 'CqhValue', value: parseFloat($1), unit: 'cqh' }; }
| CQIS { $$ = { type: 'CqiValue', value: parseFloat($1), unit: 'cqi' }; }
Expand Down
20 changes: 20 additions & 0 deletions src/lib/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,29 @@ function isValueType(node) {
case 'ChValue':
case 'RemValue':
case 'VhValue':
case 'SvhValue':
case 'LvhValue':
case 'DvhValue':
case 'VwValue':
case 'SvwValue':
case 'LvwValue':
case 'DvwValue':
case 'VminValue':
case 'SvminValue':
case 'LvminValue':
case 'DvminValue':
case 'VmaxValue':
case 'SvmaxValue':
case 'LvmaxValue':
case 'DvmaxValue':
case 'VbValue':
case 'SvbValue':
case 'LvbValue':
case 'DvwValue':
case 'ViValue':
case 'SviValue':
case 'LviValue':
case 'DviValue':
case 'CqwValue':
case 'CqhValue':
case 'CqiValue':
Expand Down
20 changes: 20 additions & 0 deletions src/parser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,29 @@ export interface DimensionExpression {
| 'ChValue'
| 'RemValue'
| 'VhValue'
| 'SvhValue'
| 'LvhValue'
| 'DvhValue'
| 'VwValue'
| 'SvwValue'
| 'LvwValue'
| 'DvwValue'
| 'VminValue'
| 'SvminValue'
| 'LvminValue'
| 'DvminValue'
| 'VmaxValue'
| 'SvmaxValue'
| 'LvmaxValue'
| 'DvmaxValue'
| 'VbValue'
| 'SvbValue'
| 'LvbValue'
| 'DvbValue'
| 'ViValue'
| 'SviValue'
| 'LviValue'
| 'DviValue'
| 'CqwValue'
| 'CqhValue'
| 'CqbValue'
Expand Down

0 comments on commit dff94f7

Please sign in to comment.