Python ply.lex.lineno() Examples
The following are 30
code examples of ply.lex.lineno().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ply.lex
, or try the search function
.
Example #1
Source File: cpp.py From scalyr-agent-2 with Apache License 2.0 | 5 votes |
def t_CPP_WS(t): r'\s+' t.lexer.lineno += t.value.count("\n") return t
Example #2
Source File: cpp.py From Requester with MIT License | 5 votes |
def t_CPP_COMMENT1(t): r'(/\*(.|\n)*?\*/)' ncr = t.value.count("\n") t.lexer.lineno += ncr # replace with one space or a number of '\n' t.type = 'CPP_WS'; t.value = '\n' * ncr if ncr else ' ' return t # Line comment
Example #3
Source File: cpp.py From Requester with MIT License | 5 votes |
def t_CPP_STRING(t): r'\"([^\\\n]|(\\(.|\n)))*?\"' t.lexer.lineno += t.value.count("\n") return t # Character constant 'c' or L'c'
Example #4
Source File: cpp.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def group_lines(self,input): lex = self.lexer.clone() lines = [x.rstrip() for x in input.splitlines()] for i in xrange(len(lines)): j = i+1 while lines[i].endswith('\\') and (j < len(lines)): lines[i] = lines[i][:-1]+lines[j] lines[j] = "" j += 1 input = "\n".join(lines) lex.input(input) lex.lineno = 1 current_line = [] while True: tok = lex.token() if not tok: break current_line.append(tok) if tok.type in self.t_WS and '\n' in tok.value: yield current_line current_line = [] if current_line: yield current_line # ---------------------------------------------------------------------- # tokenstrip() # # Remove leading/trailing whitespace tokens from a token list # ----------------------------------------------------------------------
Example #5
Source File: cpp.py From histogrammar-python with Apache License 2.0 | 5 votes |
def t_CPP_WS(t): r'\s+' t.lexer.lineno += t.value.count("\n") return t
Example #6
Source File: cpp.py From histogrammar-python with Apache License 2.0 | 5 votes |
def t_CPP_STRING(t): r'\"([^\\\n]|(\\(.|\n)))*?\"' t.lexer.lineno += t.value.count("\n") return t # Character constant 'c' or L'c'
Example #7
Source File: cpp.py From histogrammar-python with Apache License 2.0 | 5 votes |
def t_CPP_CHAR(t): r'(L)?\'([^\\\n]|(\\(.|\n)))*?\'' t.lexer.lineno += t.value.count("\n") return t # Comment
Example #8
Source File: cpp.py From histogrammar-python with Apache License 2.0 | 5 votes |
def t_CPP_COMMENT1(t): r'(/\*(.|\n)*?\*/)' ncr = t.value.count("\n") t.lexer.lineno += ncr # replace with one space or a number of '\n' t.type = 'CPP_WS'; t.value = '\n' * ncr if ncr else ' ' return t # Line comment
Example #9
Source File: cpp.py From histogrammar-python with Apache License 2.0 | 5 votes |
def group_lines(self,input): lex = self.lexer.clone() lines = [x.rstrip() for x in input.splitlines()] for i in xrange(len(lines)): j = i+1 while lines[i].endswith('\\') and (j < len(lines)): lines[i] = lines[i][:-1]+lines[j] lines[j] = "" j += 1 input = "\n".join(lines) lex.input(input) lex.lineno = 1 current_line = [] while True: tok = lex.token() if not tok: break current_line.append(tok) if tok.type in self.t_WS and '\n' in tok.value: yield current_line current_line = [] if current_line: yield current_line # ---------------------------------------------------------------------- # tokenstrip() # # Remove leading/trailing whitespace tokens from a token list # ----------------------------------------------------------------------
Example #10
Source File: cpp.py From quickstart-git2s3 with Apache License 2.0 | 5 votes |
def t_CPP_WS(t): r'\s+' t.lexer.lineno += t.value.count("\n") return t
Example #11
Source File: cpp.py From quickstart-git2s3 with Apache License 2.0 | 5 votes |
def t_CPP_STRING(t): r'\"([^\\\n]|(\\(.|\n)))*?\"' t.lexer.lineno += t.value.count("\n") return t # Character constant 'c' or L'c'
Example #12
Source File: cpp.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def t_CPP_COMMENT1(t): r'(/\*(.|\n)*?\*/)' ncr = t.value.count("\n") t.lexer.lineno += ncr # replace with one space or a number of '\n' t.type = 'CPP_WS'; t.value = '\n' * ncr if ncr else ' ' return t # Line comment
Example #13
Source File: cpp.py From scalyr-agent-2 with Apache License 2.0 | 5 votes |
def t_CPP_COMMENT1(t): r'(/\*(.|\n)*?\*/)' ncr = t.value.count("\n") t.lexer.lineno += ncr # replace with one space or a number of '\n' t.type = 'CPP_WS'; t.value = '\n' * ncr if ncr else ' ' return t # Line comment
Example #14
Source File: cpp.py From scalyr-agent-2 with Apache License 2.0 | 5 votes |
def t_CPP_CHAR(t): r'(L)?\'([^\\\n]|(\\(.|\n)))*?\'' t.lexer.lineno += t.value.count("\n") return t # Comment
Example #15
Source File: cpp.py From scalyr-agent-2 with Apache License 2.0 | 5 votes |
def t_CPP_STRING(t): r'\"([^\\\n]|(\\(.|\n)))*?\"' t.lexer.lineno += t.value.count("\n") return t # Character constant 'c' or L'c'
Example #16
Source File: cpp.py From scalyr-agent-2 with Apache License 2.0 | 5 votes |
def group_lines(self,input): lex = self.lexer.clone() lines = [x.rstrip() for x in input.splitlines()] for i in xrange(len(lines)): j = i+1 while lines[i].endswith('\\') and (j < len(lines)): lines[i] = lines[i][:-1]+lines[j] lines[j] = "" j += 1 input = "\n".join(lines) lex.input(input) lex.lineno = 1 current_line = [] while True: tok = lex.token() if not tok: break current_line.append(tok) if tok.type in self.t_WS and '\n' in tok.value: yield current_line current_line = [] if current_line: yield current_line # ---------------------------------------------------------------------- # tokenstrip() # # Remove leading/trailing whitespace tokens from a token list # ----------------------------------------------------------------------
Example #17
Source File: cpp.py From learn_python3_spider with MIT License | 5 votes |
def group_lines(self,input): lex = self.lexer.clone() lines = [x.rstrip() for x in input.splitlines()] for i in xrange(len(lines)): j = i+1 while lines[i].endswith('\\') and (j < len(lines)): lines[i] = lines[i][:-1]+lines[j] lines[j] = "" j += 1 input = "\n".join(lines) lex.input(input) lex.lineno = 1 current_line = [] while True: tok = lex.token() if not tok: break current_line.append(tok) if tok.type in self.t_WS and '\n' in tok.value: yield current_line current_line = [] if current_line: yield current_line # ---------------------------------------------------------------------- # tokenstrip() # # Remove leading/trailing whitespace tokens from a token list # ----------------------------------------------------------------------
Example #18
Source File: cpp.py From learn_python3_spider with MIT License | 5 votes |
def t_CPP_COMMENT1(t): r'(/\*(.|\n)*?\*/)' ncr = t.value.count("\n") t.lexer.lineno += ncr # replace with one space or a number of '\n' t.type = 'CPP_WS'; t.value = '\n' * ncr if ncr else ' ' return t # Line comment
Example #19
Source File: cpp.py From learn_python3_spider with MIT License | 5 votes |
def t_CPP_CHAR(t): r'(L)?\'([^\\\n]|(\\(.|\n)))*?\'' t.lexer.lineno += t.value.count("\n") return t # Comment
Example #20
Source File: cpp.py From learn_python3_spider with MIT License | 5 votes |
def t_CPP_STRING(t): r'\"([^\\\n]|(\\(.|\n)))*?\"' t.lexer.lineno += t.value.count("\n") return t # Character constant 'c' or L'c'
Example #21
Source File: cpp.py From learn_python3_spider with MIT License | 5 votes |
def t_CPP_WS(t): r'\s+' t.lexer.lineno += t.value.count("\n") return t
Example #22
Source File: cpp.py From retdec-regression-tests-framework with MIT License | 5 votes |
def group_lines(self,input): lex = self.lexer.clone() lines = [x.rstrip() for x in input.splitlines()] for i in xrange(len(lines)): j = i+1 while lines[i].endswith('\\') and (j < len(lines)): lines[i] = lines[i][:-1]+lines[j] lines[j] = "" j += 1 input = "\n".join(lines) lex.input(input) lex.lineno = 1 current_line = [] while True: tok = lex.token() if not tok: break current_line.append(tok) if tok.type in self.t_WS and '\n' in tok.value: yield current_line current_line = [] if current_line: yield current_line # ---------------------------------------------------------------------- # tokenstrip() # # Remove leading/trailing whitespace tokens from a token list # ----------------------------------------------------------------------
Example #23
Source File: cpp.py From retdec-regression-tests-framework with MIT License | 5 votes |
def t_CPP_COMMENT1(t): r'(/\*(.|\n)*?\*/)' ncr = t.value.count("\n") t.lexer.lineno += ncr # replace with one space or a number of '\n' t.type = 'CPP_WS'; t.value = '\n' * ncr if ncr else ' ' return t # Line comment
Example #24
Source File: cpp.py From retdec-regression-tests-framework with MIT License | 5 votes |
def t_CPP_CHAR(t): r'(L)?\'([^\\\n]|(\\(.|\n)))*?\'' t.lexer.lineno += t.value.count("\n") return t # Comment
Example #25
Source File: cpp.py From retdec-regression-tests-framework with MIT License | 5 votes |
def t_CPP_STRING(t): r'\"([^\\\n]|(\\(.|\n)))*?\"' t.lexer.lineno += t.value.count("\n") return t # Character constant 'c' or L'c'
Example #26
Source File: cpp.py From retdec-regression-tests-framework with MIT License | 5 votes |
def t_CPP_WS(t): r'\s+' t.lexer.lineno += t.value.count("\n") return t
Example #27
Source File: cpp.py From SublimeKSP with GNU General Public License v3.0 | 5 votes |
def t_CPP_WS(t): r'\s+' t.lexer.lineno += t.value.count("\n") return t
Example #28
Source File: cpp.py From rfmt with Apache License 2.0 | 5 votes |
def t_CPP_COMMENT1(t): r'(/\*(.|\n)*?\*/)' ncr = t.value.count("\n") t.lexer.lineno += ncr # replace with one space or a number of '\n' t.type = 'CPP_WS'; t.value = '\n' * ncr if ncr else ' ' return t # Line comment
Example #29
Source File: cpp.py From rfmt with Apache License 2.0 | 5 votes |
def t_CPP_CHAR(t): r'(L)?\'([^\\\n]|(\\(.|\n)))*?\'' t.lexer.lineno += t.value.count("\n") return t # Comment
Example #30
Source File: cpp.py From rfmt with Apache License 2.0 | 5 votes |
def t_CPP_STRING(t): r'\"([^\\\n]|(\\(.|\n)))*?\"' t.lexer.lineno += t.value.count("\n") return t # Character constant 'c' or L'c'