-
Notifications
You must be signed in to change notification settings - Fork 1
Tag Value Lexer
Ahmed Hisham Ismail edited this page Jun 27, 2014
·
2 revisions
The class spdx.parsers.lexers.tagvalue.Lexer is responsible for converting a Tag/Value format SPDX file to a stream of tokens to be parsed. It has a token for every valid Tag.
The Lexer by default ignores all empty lines and lines starting with a # character.
It's implemented using ply.lex
-
reservedA dict of (keyword, token) pairs, it contains all of the valid tags in addition to the special valuesUNKNOWN,NOASSERTION,NONE,SOURCE,BINARY,OTHERandARCHIVE. -
statesa tuple of states for the lexer. -
tokensA list of all token types in order for the parser to know them.
There are two states INITIAL which is the default initial state and text which is the state for recognizing free form text between <text> and </text> tags. The rules for the text state are exclusive to it.
Rules are defined as a series of methods with the t_ prefix the regex that recognizes each token is the method's docstring. The order of the functions specifies the precedence of the rules.