Advertisement
SMASIF

Telephone Number Parser

Apr 6th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. grammar telephone;
  2.  
  3. start: '+1'? '+'? variation
  4. ;
  5.  
  6. variation
  7. : nanp
  8. | japan
  9. | airtel
  10. | gp
  11. | robi
  12. | bl
  13. ;
  14.  
  15. // North American Numbering Plan
  16. nanp
  17. : '011' areacode exchange subscriber
  18. ;
  19.  
  20. // Airtel Numbering Plan
  21. airtel
  22. : '016' areacode exchange subscriber
  23. ;
  24.  
  25. //Grameenphone Numbering Plan
  26. gp
  27. : '017' areacode exchange subscriber
  28. ;
  29.  
  30. //Robi Numbering Plan
  31. robi
  32. : '018' areacode exchange subscriber
  33. ;
  34.  
  35. //Banglalink Numbering Plan
  36. bl
  37. : '019' areacode exchange subscriber
  38. ;
  39.  
  40. areacode
  41. : DIGIT DIGIT DIGIT
  42. ;
  43.  
  44. // Exhange
  45. exchange
  46. : DIGIT DIGIT DIGIT
  47. ;
  48.  
  49. // Subscriber
  50. subscriber
  51. : DIGIT DIGIT DIGIT DIGIT
  52. ;
  53.  
  54. // Japan
  55. japan
  56. : '010' areacode exchange subscriber
  57. ;
  58.  
  59. DIGIT
  60. : [0-9]
  61. ;
  62.  
  63. WS
  64. : [ \r\n] + -> skip
  65. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement