Bladeren bron

Clean up the way contexts are defined.

tags/v0.3
Ben Kurtovic 11 jaren geleden
bovenliggende
commit
4cfa40685e
1 gewijzigde bestanden met toevoegingen van 39 en 37 verwijderingen
  1. +39
    -37
      mwparserfromhell/parser/contexts.py

+ 39
- 37
mwparserfromhell/parser/contexts.py Bestand weergeven

@@ -85,43 +85,45 @@ Global contexts:

# Local contexts:

TEMPLATE = 0b000000000000000000000111
TEMPLATE_NAME = 0b000000000000000000000001
TEMPLATE_PARAM_KEY = 0b000000000000000000000010
TEMPLATE_PARAM_VALUE = 0b000000000000000000000100

ARGUMENT = 0b000000000000000000011000
ARGUMENT_NAME = 0b000000000000000000001000
ARGUMENT_DEFAULT = 0b000000000000000000010000

WIKILINK = 0b000000000000000001100000
WIKILINK_TITLE = 0b000000000000000000100000
WIKILINK_TEXT = 0b000000000000000001000000

HEADING = 0b000000000001111110000000
HEADING_LEVEL_1 = 0b000000000000000010000000
HEADING_LEVEL_2 = 0b000000000000000100000000
HEADING_LEVEL_3 = 0b000000000000001000000000
HEADING_LEVEL_4 = 0b000000000000010000000000
HEADING_LEVEL_5 = 0b000000000000100000000000
HEADING_LEVEL_6 = 0b000000000001000000000000

COMMENT = 0b000000000010000000000000

TAG = 0b000000111100000000000000
TAG_OPEN = 0b000000000100000000000000
TAG_ATTR = 0b000000001000000000000000
TAG_BODY = 0b000000010000000000000000
TAG_CLOSE = 0b000000100000000000000000

SAFETY_CHECK = 0b111111000000000000000000
HAS_TEXT = 0b000001000000000000000000
FAIL_ON_TEXT = 0b000010000000000000000000
FAIL_NEXT = 0b000100000000000000000000
FAIL_ON_LBRACE = 0b001000000000000000000000
FAIL_ON_RBRACE = 0b010000000000000000000000
FAIL_ON_EQUALS = 0b100000000000000000000000
TEMPLATE_NAME = 1 << 0
TEMPLATE_PARAM_KEY = 1 << 1
TEMPLATE_PARAM_VALUE = 1 << 2
TEMPLATE = TEMPLATE_NAME + TEMPLATE_PARAM_KEY + TEMPLATE_PARAM_VALUE

ARGUMENT_NAME = 1 << 3
ARGUMENT_DEFAULT = 1 << 4
ARGUMENT = ARGUMENT_NAME + ARGUMENT_DEFAULT

WIKILINK_TITLE = 1 << 5
WIKILINK_TEXT = 1 << 6
WIKILINK = WIKILINK_TITLE + WIKILINK_TEXT

HEADING_LEVEL_1 = 1 << 7
HEADING_LEVEL_2 = 1 << 8
HEADING_LEVEL_3 = 1 << 9
HEADING_LEVEL_4 = 1 << 10
HEADING_LEVEL_5 = 1 << 11
HEADING_LEVEL_6 = 1 << 12
HEADING = (HEADING_LEVEL_1 + HEADING_LEVEL_2 + HEADING_LEVEL_3 +
HEADING_LEVEL_4 + HEADING_LEVEL_5 + HEADING_LEVEL_6)

COMMENT = 1 << 13

TAG_OPEN = 1 << 14
TAG_ATTR = 1 << 15
TAG_BODY = 1 << 16
TAG_CLOSE = 1 << 17
TAG = TAG_OPEN + TAG_ATTR + TAG_BODY + TAG_CLOSE

HAS_TEXT = 1 << 18
FAIL_ON_TEXT = 1 << 19
FAIL_NEXT = 1 << 20
FAIL_ON_LBRACE = 1 << 21
FAIL_ON_RBRACE = 1 << 22
FAIL_ON_EQUALS = 1 << 23
SAFETY_CHECK = (HAS_TEXT + FAIL_ON_TEXT + FAIL_NEXT + FAIL_ON_LBRACE +
FAIL_ON_RBRACE + FAIL_ON_EQUALS)

# Global contexts:

GL_HEADING = 0b1
GL_HEADING = 1 << 0

Laden…
Annuleren
Opslaan