diff --git a/src/ElectroGrammar.g4 b/src/ElectroGrammar.g4 index 9c009f7..fc586a7 100644 --- a/src/ElectroGrammar.g4 +++ b/src/ElectroGrammar.g4 @@ -3,20 +3,10 @@ */ grammar ElectroGrammar; -import Alphabet; +import PackageSize, Units; -electro_grammar : capacitance; +electro_grammar : capacitor; -capacitance : NUMBER CPREFIX FARAD?; - -fragment DIGIT: [0-9]; -NUMBER: DIGIT* '.'? DIGIT+ | DIGIT+ '.'? DIGIT*; - -fragment NANO: 'n' | N A N O; -fragment PICO: 'p' | P I C O; -fragment MICRO: 'u' | M I C R O; -CPREFIX: MICRO | NANO | PICO; - -FARAD: F | F A R A D; +capacitor : capacitance package_size?; WHITESPACE : [\p{White_Space}] -> skip; diff --git a/src/PackageSize.g4 b/src/PackageSize.g4 new file mode 100644 index 0000000..d2d27e2 --- /dev/null +++ b/src/PackageSize.g4 @@ -0,0 +1,33 @@ +grammar PackageSize; +import Alphabet; + +package_size: IMPERIAL_SIZE | METRIC_SIZE; + +IMPERIAL_SIZE: '01005' + | '0201' + | '0805' + | '1008' + | '1206' + | '1806' + | '2010' + | '2512' + | IMPERIAL AMBIGUOUS_SIZE + | AMBIGUOUS_SIZE IMPERIAL; + +METRIC_SIZE : '1005' + | '1608' + | '2012' + | '2520' + | '3216' + | '3225' + | '4516' + | '5025' + | '6332' + | METRIC AMBIGUOUS_SIZE + | AMBIGUOUS_SIZE METRIC; + +AMBIGUOUS_SIZE : '0402' + | '0603'; + +METRIC : M | M E T R I C; +IMPERIAL : I | I M P E R I A L; \ No newline at end of file diff --git a/src/Units.g4 b/src/Units.g4 new file mode 100644 index 0000000..0176ccb --- /dev/null +++ b/src/Units.g4 @@ -0,0 +1,14 @@ +grammar Units; +import Alphabet; + +capacitance: NUMBER CPREFIX FARAD?; + +fragment DIGIT: [0-9]; +NUMBER: DIGIT* '.'? DIGIT+ | DIGIT+ '.'? DIGIT*; + +fragment NANO: 'n' | N A N O; +fragment PICO: 'p' | P I C O; +fragment MICRO: 'u' | M I C R O; +CPREFIX: MICRO | NANO | PICO; + +FARAD: F | F A R A D; \ No newline at end of file