Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: None  |  size: 1.45 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ANTLR generated parser produces MissingTokenException
  2. * this is an outline item at level 1
  3. ** item at level 2
  4. *** item at level 3
  5. * another item at level 1
  6. * an item with *bold* text
  7.        
  8. outline_item: OUTLINE_ITEM_MARKER ITEM_TEXT;
  9. OUTLINE_ITEM_MARKER: STAR_IN_COLUMN_ZERO STAR* (' '|'t');
  10. ITEM_TEXT: ('a'..'z'|'A'..'Z'|'0'..'9'|'r'|'n'|' '|'t')+;
  11. fragment STAR_IN_COLUMN_ZERO: {getCharPositionInLine()==0}? '*';
  12. fragment STAR: {getCharPositionInLine()>0}? '*';
  13.        
  14. ITEM_TEXT: ('a'..'z'|'A'..'Z'|'0'..'9'|'r'|'n'|' '|'t'|STAR)+;
  15.        
  16. input.txt line 1:0 rule STAR failed predicate: {getCharPositionInLine()>0}?
  17. input.txt line 1:1 missing OUTLINE_ITEM_MARKER at '** foo bar'
  18.        
  19. grammar Test;
  20.  
  21. outline_items
  22.  : outline_item+ EOF
  23.  ;
  24.  
  25. outline_item
  26.  : OUTLINE_ITEM_MARKER ITEM_TEXT
  27.  ;
  28.  
  29. OUTLINE_ITEM_MARKER
  30.  : STAR_IN_COLUMN_ZERO STAR* (' '|'t')
  31.  ;
  32.  
  33. ITEM_TEXT
  34.  : ('a'..'z'|'A'..'Z'|'0'..'9'|'r'|'n'|' '|'t'|STAR)+
  35.  ;
  36.  
  37. fragment STAR_IN_COLUMN_ZERO
  38.  : {getCharPositionInLine()==0}?=> '*'
  39.  ;
  40.  
  41. fragment STAR
  42.  : {getCharPositionInLine()>0}?=> '*'
  43.  ;
  44.        
  45. * this is an outline item at level 1
  46. ** item at level 2
  47. *** item at level 3
  48. * another item at level 1
  49. * an item with *bold* text
  50.        
  51. outline_item: OUTLINE_ITEM_MARKER ITEM_TEXT;
  52.  
  53. ITEM_TEXT:
  54.     (' '|'t') (' '|'t'|'a'..'z'|'A'..'Z'|'0'..'9'| STAR)+
  55. ;
  56.  
  57. OUTLINE_ITEM_MARKER:
  58.     STAR+
  59. ;
  60.  
  61. fragment STAR:  
  62.     '*'
  63. ;
  64.        
  65. outline_item: OUTLINE_ITEM_MARKER ITEM_TEXT;
  66.  
  67. ITEM_TEXT:
  68.     (' '|'t') (~('n'|'r'))+
  69. ;
  70.  
  71. OUTLINE_ITEM_MARKER:
  72.     '*'+
  73. ;