Skip to content

Commit

Permalink
antlr: Add some missing unit specifiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch authored and kasbah committed Jan 23, 2018
1 parent 96dc5a0 commit bb43e6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion python3/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def test_parse_current(self):
parse = parser('current')
assert parse('1A') == 1
assert parse('1mA') == mili
assert parse('1uA') == micro
assert parse('1nA') == nano
assert parse('1pA') == pico

Expand Down Expand Up @@ -64,6 +65,7 @@ def test_parse_inductance(self):
parse = parser('inductance')
assert parse('1H') == 1
assert parse('1mH') == mili
assert parse('1uH') == micro
assert parse('1nH') == nano

def test_parse_frequency(self):
Expand All @@ -78,13 +80,14 @@ def test_parse_time(self):
parse = parser('time')
assert parse('1s') == 1
assert parse('1ms') == mili
assert parse('1us') == micro
assert parse('1ns') == nano
assert parse('1ps') == pico

def test_parse_temperature(self):
parse = parser('temperature')
assert parse('1C') == 1
assert parse('1°C')
assert parse('1°C') == 1

def test_parse_tolerance(self):
parse = parser('tolerance')
Expand Down
2 changes: 1 addition & 1 deletion src/Units.g4
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ frequency: NUMBER fprefix? HERZ tolerance?;
fprefix: GIGA | MEGA | KILO;

time: NUMBER tprefix? SECOND tolerance?;
tprefix: MILI | NANO | PICO;
tprefix: MILI | MICRO | NANO | PICO;

temperature: NUMBER 'u{00b0}'? CELSIUS tolerance?;

0 comments on commit bb43e6e

Please sign in to comment.