BaseTools/Ecc/EOT: Add Python 3 support on ECC and EOT tools.
1. Add Python 3 support on ECC and EOT tools 2. Add C grammar file of ANTLR4 and fix some bugs Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
636
BaseTools/Source/Python/Ecc/C.g4
Normal file
636
BaseTools/Source/Python/Ecc/C.g4
Normal file
@ -0,0 +1,636 @@
|
||||
/* @file
|
||||
This file is used to be the grammar file of ECC tool
|
||||
|
||||
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
*/
|
||||
|
||||
|
||||
grammar C;
|
||||
options {
|
||||
language=Python;
|
||||
}
|
||||
|
||||
@header {
|
||||
## @file
|
||||
# The file defines the parser for C source files.
|
||||
#
|
||||
# THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE.
|
||||
# This file is generated by running:
|
||||
# java org.antlr.Tool C.g
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, Intel Corporation All rights reserved.
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at:
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
##
|
||||
|
||||
import Ecc.CodeFragment as CodeFragment
|
||||
import Ecc.FileProfile as FileProfile
|
||||
}
|
||||
|
||||
@members {
|
||||
|
||||
def printTokenInfo(self, line, offset, tokenText):
|
||||
print(str(line)+ ',' + str(offset) + ':' + str(tokenText))
|
||||
|
||||
def StorePredicateExpression(self, StartLine, StartOffset, EndLine, EndOffset, Text):
|
||||
PredExp = CodeFragment.PredicateExpression(Text, (StartLine, StartOffset), (EndLine, EndOffset))
|
||||
FileProfile.PredicateExpressionList.append(PredExp)
|
||||
|
||||
def StoreEnumerationDefinition(self, StartLine, StartOffset, EndLine, EndOffset, Text):
|
||||
EnumDef = CodeFragment.EnumerationDefinition(Text, (StartLine, StartOffset), (EndLine, EndOffset))
|
||||
FileProfile.EnumerationDefinitionList.append(EnumDef)
|
||||
|
||||
def StoreStructUnionDefinition(self, StartLine, StartOffset, EndLine, EndOffset, Text):
|
||||
SUDef = CodeFragment.StructUnionDefinition(Text, (StartLine, StartOffset), (EndLine, EndOffset))
|
||||
FileProfile.StructUnionDefinitionList.append(SUDef)
|
||||
|
||||
def StoreTypedefDefinition(self, StartLine, StartOffset, EndLine, EndOffset, FromText, ToText):
|
||||
Tdef = CodeFragment.TypedefDefinition(FromText, ToText, (StartLine, StartOffset), (EndLine, EndOffset))
|
||||
FileProfile.TypedefDefinitionList.append(Tdef)
|
||||
|
||||
def StoreFunctionDefinition(self, StartLine, StartOffset, EndLine, EndOffset, ModifierText, DeclText, LeftBraceLine, LeftBraceOffset, DeclLine, DeclOffset):
|
||||
FuncDef = CodeFragment.FunctionDefinition(ModifierText, DeclText, (StartLine, StartOffset), (EndLine, EndOffset), (LeftBraceLine, LeftBraceOffset), (DeclLine, DeclOffset))
|
||||
FileProfile.FunctionDefinitionList.append(FuncDef)
|
||||
|
||||
def StoreVariableDeclaration(self, StartLine, StartOffset, EndLine, EndOffset, ModifierText, DeclText):
|
||||
VarDecl = CodeFragment.VariableDeclaration(ModifierText, DeclText, (StartLine, StartOffset), (EndLine, EndOffset))
|
||||
FileProfile.VariableDeclarationList.append(VarDecl)
|
||||
|
||||
def StoreFunctionCalling(self, StartLine, StartOffset, EndLine, EndOffset, FuncName, ParamList):
|
||||
FuncCall = CodeFragment.FunctionCalling(FuncName, ParamList, (StartLine, StartOffset), (EndLine, EndOffset))
|
||||
FileProfile.FunctionCallingList.append(FuncCall)
|
||||
|
||||
}
|
||||
|
||||
translation_unit
|
||||
: external_declaration*
|
||||
;
|
||||
|
||||
|
||||
external_declaration
|
||||
: ( declaration_specifiers? declarator declaration* '{' )
|
||||
| function_definition
|
||||
| declaration
|
||||
| macro_statement (';')?
|
||||
;
|
||||
|
||||
function_definition
|
||||
locals [String ModifierText = '', String DeclText = '', int LBLine = 0, int LBOffset = 0, int DeclLine = 0, int DeclOffset = 0]
|
||||
@init {
|
||||
ModifierText = '';
|
||||
DeclText = '';
|
||||
LBLine = 0;
|
||||
LBOffset = 0;
|
||||
DeclLine = 0;
|
||||
DeclOffset = 0;
|
||||
}
|
||||
@after{
|
||||
self.StoreFunctionDefinition(localctx.start.line, localctx.start.column, localctx.stop.line, localctx.stop.column, ModifierText, DeclText, LBLine, LBOffset, DeclLine, DeclOffset)
|
||||
}
|
||||
: d=declaration_specifiers? declarator
|
||||
( declaration+ a=compound_statement // K&R style
|
||||
| b=compound_statement // ANSI style
|
||||
) {
|
||||
if localctx.d != None:
|
||||
ModifierText = $declaration_specifiers.text
|
||||
else:
|
||||
ModifierText = ''
|
||||
DeclText = $declarator.text
|
||||
DeclLine = $declarator.start.line
|
||||
DeclOffset = $declarator.start.column
|
||||
if localctx.a != None:
|
||||
LBLine = $a.start.line
|
||||
LBOffset = $a.start.column
|
||||
else:
|
||||
LBLine = $b.start.line
|
||||
LBOffset = $b.start.column
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
declaration_specifiers
|
||||
: ( storage_class_specifier
|
||||
| type_specifier
|
||||
| type_qualifier
|
||||
)+
|
||||
;
|
||||
|
||||
declaration
|
||||
: a='typedef' b=declaration_specifiers? c=init_declarator_list d=';'
|
||||
{
|
||||
if localctx.b is not None:
|
||||
self.StoreTypedefDefinition(localctx.a.line, localctx.a.column, $d.line, localctx.d.column, $b.text, $c.text)
|
||||
else:
|
||||
self.StoreTypedefDefinition(localctx.a.line, localctx.a.column, $d.line, localctx.d.column, '', $c.text)
|
||||
}
|
||||
| s=declaration_specifiers t=init_declarator_list? e=';'
|
||||
{
|
||||
if localctx.t is not None:
|
||||
self.StoreVariableDeclaration($s.start.line, $s.start.column, $t.start.line, $t.start.column, $s.text, $t.text)
|
||||
}
|
||||
;
|
||||
|
||||
init_declarator_list
|
||||
: init_declarator (',' init_declarator)*
|
||||
;
|
||||
|
||||
init_declarator
|
||||
: declarator ('=' initializer)?
|
||||
;
|
||||
|
||||
storage_class_specifier
|
||||
: 'extern'
|
||||
| 'static'
|
||||
| 'auto'
|
||||
| 'register'
|
||||
| 'STATIC'
|
||||
;
|
||||
|
||||
type_specifier
|
||||
: 'void'
|
||||
| 'char'
|
||||
| 'short'
|
||||
| 'int'
|
||||
| 'long'
|
||||
| 'float'
|
||||
| 'double'
|
||||
| 'signed'
|
||||
| 'unsigned'
|
||||
| s=struct_or_union_specifier
|
||||
{
|
||||
if localctx.s.stop is not None:
|
||||
self.StoreStructUnionDefinition($s.start.line, $s.start.column, $s.stop.line, $s.stop.column, $s.text)
|
||||
}
|
||||
| e=enum_specifier
|
||||
{
|
||||
if localctx.e.stop is not None:
|
||||
self.StoreEnumerationDefinition($e.start.line, $e.start.column, $e.stop.line, $e.stop.column, $e.text)
|
||||
}
|
||||
| (IDENTIFIER type_qualifier* declarator)
|
||||
| type_id
|
||||
;
|
||||
|
||||
type_id
|
||||
: IDENTIFIER
|
||||
//{self.printTokenInfo($a.line, $a.pos, $a.text)}
|
||||
;
|
||||
|
||||
struct_or_union_specifier
|
||||
: struct_or_union IDENTIFIER? '{' struct_declaration_list '}'
|
||||
| struct_or_union IDENTIFIER
|
||||
;
|
||||
|
||||
struct_or_union
|
||||
: 'struct'
|
||||
| 'union'
|
||||
;
|
||||
|
||||
struct_declaration_list
|
||||
: struct_declaration+
|
||||
;
|
||||
|
||||
struct_declaration
|
||||
: specifier_qualifier_list struct_declarator_list ';'
|
||||
;
|
||||
|
||||
specifier_qualifier_list
|
||||
: ( type_qualifier | type_specifier )+
|
||||
;
|
||||
|
||||
struct_declarator_list
|
||||
: struct_declarator (',' struct_declarator)*
|
||||
;
|
||||
|
||||
struct_declarator
|
||||
: declarator (':' constant_expression)?
|
||||
| ':' constant_expression
|
||||
;
|
||||
|
||||
enum_specifier
|
||||
: 'enum' '{' enumerator_list ','? '}'
|
||||
| 'enum' IDENTIFIER '{' enumerator_list ','? '}'
|
||||
| 'enum' IDENTIFIER
|
||||
;
|
||||
|
||||
enumerator_list
|
||||
: enumerator (',' enumerator)*
|
||||
;
|
||||
|
||||
enumerator
|
||||
: IDENTIFIER ('=' constant_expression)?
|
||||
;
|
||||
|
||||
type_qualifier
|
||||
: 'const'
|
||||
| 'volatile'
|
||||
| 'IN'
|
||||
| 'OUT'
|
||||
| 'OPTIONAL'
|
||||
| 'CONST'
|
||||
| 'UNALIGNED'
|
||||
| 'VOLATILE'
|
||||
| 'GLOBAL_REMOVE_IF_UNREFERENCED'
|
||||
| 'EFIAPI'
|
||||
| 'EFI_BOOTSERVICE'
|
||||
| 'EFI_RUNTIMESERVICE'
|
||||
| 'PACKED'
|
||||
;
|
||||
|
||||
declarator
|
||||
: pointer? ('EFIAPI')? ('EFI_BOOTSERVICE')? ('EFI_RUNTIMESERVICE')? direct_declarator
|
||||
// | ('EFIAPI')? ('EFI_BOOTSERVICE')? ('EFI_RUNTIMESERVICE')? pointer? direct_declarator
|
||||
| pointer
|
||||
;
|
||||
|
||||
direct_declarator
|
||||
: IDENTIFIER declarator_suffix*
|
||||
| '(' ('EFIAPI')? declarator ')' declarator_suffix+
|
||||
;
|
||||
|
||||
declarator_suffix
|
||||
: '[' constant_expression ']'
|
||||
| '[' ']'
|
||||
| '(' parameter_type_list ')'
|
||||
| '(' identifier_list ')'
|
||||
| '(' ')'
|
||||
;
|
||||
|
||||
pointer
|
||||
: '*' type_qualifier+ pointer?
|
||||
| '*' pointer
|
||||
| '*'
|
||||
;
|
||||
|
||||
parameter_type_list
|
||||
: parameter_list (',' ('OPTIONAL')? '...')?
|
||||
;
|
||||
|
||||
parameter_list
|
||||
: parameter_declaration (',' ('OPTIONAL')? parameter_declaration)*
|
||||
;
|
||||
|
||||
parameter_declaration
|
||||
: declaration_specifiers (declarator|abstract_declarator)* ('OPTIONAL')?
|
||||
//accomerdate user-defined type only, no declarator follow.
|
||||
| pointer* IDENTIFIER
|
||||
;
|
||||
|
||||
identifier_list
|
||||
: IDENTIFIER
|
||||
(',' IDENTIFIER)*
|
||||
;
|
||||
|
||||
type_name
|
||||
: specifier_qualifier_list abstract_declarator?
|
||||
| type_id
|
||||
;
|
||||
|
||||
abstract_declarator
|
||||
: pointer direct_abstract_declarator?
|
||||
| direct_abstract_declarator
|
||||
;
|
||||
|
||||
direct_abstract_declarator
|
||||
: ( '(' abstract_declarator ')' | abstract_declarator_suffix ) abstract_declarator_suffix*
|
||||
;
|
||||
|
||||
abstract_declarator_suffix
|
||||
: '[' ']'
|
||||
| '[' constant_expression ']'
|
||||
| '(' ')'
|
||||
| '(' parameter_type_list ')'
|
||||
;
|
||||
|
||||
initializer
|
||||
|
||||
: assignment_expression
|
||||
| '{' initializer_list ','? '}'
|
||||
;
|
||||
|
||||
initializer_list
|
||||
: initializer (',' initializer )*
|
||||
;
|
||||
|
||||
// E x p r e s s i o n s
|
||||
|
||||
argument_expression_list
|
||||
: assignment_expression ('OPTIONAL')? (',' assignment_expression ('OPTIONAL')?)*
|
||||
;
|
||||
|
||||
additive_expression
|
||||
: (multiplicative_expression) ('+' multiplicative_expression | '-' multiplicative_expression)*
|
||||
;
|
||||
|
||||
multiplicative_expression
|
||||
: (cast_expression) ('*' cast_expression | '/' cast_expression | '%' cast_expression)*
|
||||
;
|
||||
|
||||
cast_expression
|
||||
: '(' type_name ')' cast_expression
|
||||
| unary_expression
|
||||
;
|
||||
|
||||
unary_expression
|
||||
: postfix_expression
|
||||
| '++' unary_expression
|
||||
| '--' unary_expression
|
||||
| unary_operator cast_expression
|
||||
| 'sizeof' unary_expression
|
||||
| 'sizeof' '(' type_name ')'
|
||||
;
|
||||
|
||||
postfix_expression
|
||||
locals [FuncCallText='']
|
||||
@init
|
||||
{
|
||||
self.FuncCallText=''
|
||||
}
|
||||
: p=primary_expression {self.FuncCallText += $p.text}
|
||||
( '[' expression ']'
|
||||
| '(' a=')'{self.StoreFunctionCalling($p.start.line, $p.start.column, $a.line, localctx.a.column, self.FuncCallText, '')}
|
||||
| '(' c=argument_expression_list b=')' {self.StoreFunctionCalling($p.start.line, $p.start.column, $b.line, localctx.b.column, self.FuncCallText, $c.text)}
|
||||
| '(' macro_parameter_list ')'
|
||||
| '.' x=IDENTIFIER {self.FuncCallText += '.' + $x.text}
|
||||
| '*' y=IDENTIFIER {self.FuncCallText = $y.text}
|
||||
| '->' z=IDENTIFIER {self.FuncCallText += '->' + $z.text}
|
||||
| '++'
|
||||
| '--'
|
||||
)*
|
||||
;
|
||||
|
||||
macro_parameter_list
|
||||
: parameter_declaration (',' parameter_declaration)*
|
||||
;
|
||||
|
||||
unary_operator
|
||||
: '&'
|
||||
| '*'
|
||||
| '+'
|
||||
| '-'
|
||||
| '~'
|
||||
| '!'
|
||||
;
|
||||
|
||||
primary_expression
|
||||
: IDENTIFIER
|
||||
| constant
|
||||
| '(' expression ')'
|
||||
;
|
||||
|
||||
constant
|
||||
: HEX_LITERAL
|
||||
| OCTAL_LITERAL
|
||||
| DECIMAL_LITERAL
|
||||
| CHARACTER_LITERAL
|
||||
| (IDENTIFIER* STRING_LITERAL+)+ IDENTIFIER*
|
||||
| FLOATING_POINT_LITERAL
|
||||
;
|
||||
|
||||
/////
|
||||
|
||||
expression
|
||||
: assignment_expression (',' assignment_expression)*
|
||||
;
|
||||
|
||||
constant_expression
|
||||
: conditional_expression
|
||||
;
|
||||
|
||||
assignment_expression
|
||||
: lvalue assignment_operator assignment_expression
|
||||
| conditional_expression
|
||||
;
|
||||
|
||||
lvalue
|
||||
: unary_expression
|
||||
;
|
||||
|
||||
assignment_operator
|
||||
: '='
|
||||
| '*='
|
||||
| '/='
|
||||
| '%='
|
||||
| '+='
|
||||
| '-='
|
||||
| '<<='
|
||||
| '>>='
|
||||
| '&='
|
||||
| '^='
|
||||
| '|='
|
||||
;
|
||||
|
||||
conditional_expression
|
||||
: e=logical_or_expression ('?' expression ':' conditional_expression {self.StorePredicateExpression($e.start.line, $e.start.column, $e.stop.line, $e.stop.column, $e.text)})?
|
||||
;
|
||||
|
||||
logical_or_expression
|
||||
: logical_and_expression ('||' logical_and_expression)*
|
||||
;
|
||||
|
||||
logical_and_expression
|
||||
: inclusive_or_expression ('&&' inclusive_or_expression)*
|
||||
;
|
||||
|
||||
inclusive_or_expression
|
||||
: exclusive_or_expression ('|' exclusive_or_expression)*
|
||||
;
|
||||
|
||||
exclusive_or_expression
|
||||
: and_expression ('^' and_expression)*
|
||||
;
|
||||
|
||||
and_expression
|
||||
: equality_expression ('&' equality_expression)*
|
||||
;
|
||||
equality_expression
|
||||
: relational_expression (('=='|'!=') relational_expression )*
|
||||
;
|
||||
|
||||
relational_expression
|
||||
: shift_expression (('<'|'>'|'<='|'>=') shift_expression)*
|
||||
;
|
||||
|
||||
shift_expression
|
||||
: additive_expression (('<<'|'>>') additive_expression)*
|
||||
;
|
||||
|
||||
// S t a t e m e n t s
|
||||
|
||||
statement
|
||||
: labeled_statement
|
||||
| compound_statement
|
||||
| expression_statement
|
||||
| selection_statement
|
||||
| iteration_statement
|
||||
| jump_statement
|
||||
| macro_statement
|
||||
| asm2_statement
|
||||
| asm1_statement
|
||||
| asm_statement
|
||||
| declaration
|
||||
;
|
||||
|
||||
asm2_statement
|
||||
: '__asm__'? IDENTIFIER '(' (~(';'))* ')' ';'
|
||||
;
|
||||
|
||||
asm1_statement
|
||||
: '_asm' '{' (~('}'))* '}'
|
||||
;
|
||||
|
||||
asm_statement
|
||||
: '__asm' '{' (~('}'))* '}'
|
||||
;
|
||||
|
||||
macro_statement
|
||||
: IDENTIFIER '(' declaration* statement_list? expression? ')'
|
||||
;
|
||||
|
||||
labeled_statement
|
||||
: IDENTIFIER ':' statement
|
||||
| 'case' constant_expression ':' statement
|
||||
| 'default' ':' statement
|
||||
;
|
||||
|
||||
compound_statement
|
||||
: '{' declaration* statement_list? '}'
|
||||
;
|
||||
|
||||
statement_list
|
||||
: statement+
|
||||
;
|
||||
|
||||
expression_statement
|
||||
: ';'
|
||||
| expression ';'
|
||||
;
|
||||
|
||||
selection_statement
|
||||
: 'if' '(' e=expression ')' {self.StorePredicateExpression($e.start.line, $e.start.column, $e.stop.line, $e.stop.column, $e.text)} statement (:'else' statement)?
|
||||
| 'switch' '(' expression ')' statement
|
||||
;
|
||||
|
||||
iteration_statement
|
||||
: 'while' '(' e=expression ')' statement {self.StorePredicateExpression($e.start.line, $e.start.column, $e.stop.line, $e.stop.column, $e.text)}
|
||||
| 'do' statement 'while' '(' e=expression ')' ';' {self.StorePredicateExpression($e.start.line, $e.start.column, $e.stop.line, $e.stop.column, $e.text)}
|
||||
//| 'for' '(' expression_statement e=expression_statement expression? ')' statement {self.StorePredicateExpression($e.start.line, $e.start.column, $e.stop.line, $e.stop.column, $e.text)}
|
||||
;
|
||||
|
||||
jump_statement
|
||||
: 'goto' IDENTIFIER ';'
|
||||
| 'continue' ';'
|
||||
| 'break' ';'
|
||||
| 'return' ';'
|
||||
| 'return' expression ';'
|
||||
;
|
||||
|
||||
IDENTIFIER
|
||||
: LETTER (LETTER|'0'..'9')*
|
||||
;
|
||||
|
||||
fragment
|
||||
LETTER
|
||||
: '$'
|
||||
| 'A'..'Z'
|
||||
| 'a'..'z'
|
||||
| '_'
|
||||
;
|
||||
|
||||
CHARACTER_LITERAL
|
||||
: ('L')? '\'' ( EscapeSequence | ~('\''|'\\') ) '\''
|
||||
;
|
||||
|
||||
STRING_LITERAL
|
||||
: ('L')? '"' ( EscapeSequence | ~('\\'|'"') )* '"'
|
||||
;
|
||||
|
||||
HEX_LITERAL : '0' ('x'|'X') HexDigit+ IntegerTypeSuffix? ;
|
||||
|
||||
DECIMAL_LITERAL : ('0' | '1'..'9' '0'..'9'*) IntegerTypeSuffix? ;
|
||||
|
||||
OCTAL_LITERAL : '0' ('0'..'7')+ IntegerTypeSuffix? ;
|
||||
|
||||
fragment
|
||||
HexDigit : ('0'..'9'|'a'..'f'|'A'..'F') ;
|
||||
|
||||
fragment
|
||||
IntegerTypeSuffix
|
||||
: ('u'|'U')
|
||||
| ('l'|'L')
|
||||
| ('u'|'U') ('l'|'L')
|
||||
| ('u'|'U') ('l'|'L') ('l'|'L')
|
||||
;
|
||||
|
||||
FLOATING_POINT_LITERAL
|
||||
: ('0'..'9')+ '.' ('0'..'9')* Exponent? FloatTypeSuffix?
|
||||
| '.' ('0'..'9')+ Exponent? FloatTypeSuffix?
|
||||
| ('0'..'9')+ Exponent FloatTypeSuffix?
|
||||
| ('0'..'9')+ Exponent? FloatTypeSuffix
|
||||
;
|
||||
|
||||
fragment
|
||||
Exponent : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
|
||||
|
||||
fragment
|
||||
FloatTypeSuffix : ('f'|'F'|'d'|'D') ;
|
||||
|
||||
fragment
|
||||
EscapeSequence
|
||||
: '\\' ('b'|'t'|'n'|'f'|'r'|'\''|'\\')
|
||||
| OctalEscape
|
||||
;
|
||||
|
||||
fragment
|
||||
OctalEscape
|
||||
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
|
||||
| '\\' ('0'..'7') ('0'..'7')
|
||||
| '\\' ('0'..'7')
|
||||
;
|
||||
|
||||
fragment
|
||||
UnicodeEscape
|
||||
: '\\' 'u' HexDigit HexDigit HexDigit HexDigit
|
||||
;
|
||||
|
||||
WS : (' '|'\r'|'\t'|'\u000C'|'\n')
|
||||
-> channel(HIDDEN)
|
||||
;
|
||||
|
||||
// ingore '\' of line concatenation
|
||||
BS : ('\\')
|
||||
-> channel(HIDDEN)
|
||||
;
|
||||
|
||||
UnicodeVocabulary
|
||||
: '\u0003'..'\uFFFE'
|
||||
;
|
||||
|
||||
COMMENT
|
||||
: '/*' .*? '*/'
|
||||
-> channel(HIDDEN)
|
||||
;
|
||||
|
||||
LINE_COMMENT
|
||||
: '//' ~('\n'|'\r')* '\r'? '\n'
|
||||
-> channel(HIDDEN)
|
||||
;
|
||||
|
||||
// ignore #line info for now
|
||||
LINE_COMMAND
|
||||
: '#' ~('\n'|'\r')* '\r'? '\n'
|
||||
-> channel(HIDDEN)
|
||||
;
|
File diff suppressed because it is too large
Load Diff
672
BaseTools/Source/Python/Ecc/CListener.py
Normal file
672
BaseTools/Source/Python/Ecc/CListener.py
Normal file
@ -0,0 +1,672 @@
|
||||
# Generated from C.g4 by ANTLR 4.7.1
|
||||
from antlr4 import *
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .CParser import CParser
|
||||
else:
|
||||
from CParser import CParser
|
||||
|
||||
## @file
|
||||
# The file defines the parser for C source files.
|
||||
#
|
||||
# THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE.
|
||||
# This file is generated by running:
|
||||
# java org.antlr.Tool C.g
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, Intel Corporation All rights reserved.
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at:
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
##
|
||||
|
||||
import Ecc.CodeFragment as CodeFragment
|
||||
import Ecc.FileProfile as FileProfile
|
||||
|
||||
|
||||
# This class defines a complete listener for a parse tree produced by CParser.
|
||||
class CListener(ParseTreeListener):
|
||||
|
||||
# Enter a parse tree produced by CParser#translation_unit.
|
||||
def enterTranslation_unit(self, ctx:CParser.Translation_unitContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#translation_unit.
|
||||
def exitTranslation_unit(self, ctx:CParser.Translation_unitContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#external_declaration.
|
||||
def enterExternal_declaration(self, ctx:CParser.External_declarationContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#external_declaration.
|
||||
def exitExternal_declaration(self, ctx:CParser.External_declarationContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#function_definition.
|
||||
def enterFunction_definition(self, ctx:CParser.Function_definitionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#function_definition.
|
||||
def exitFunction_definition(self, ctx:CParser.Function_definitionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#declaration_specifiers.
|
||||
def enterDeclaration_specifiers(self, ctx:CParser.Declaration_specifiersContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#declaration_specifiers.
|
||||
def exitDeclaration_specifiers(self, ctx:CParser.Declaration_specifiersContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#declaration.
|
||||
def enterDeclaration(self, ctx:CParser.DeclarationContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#declaration.
|
||||
def exitDeclaration(self, ctx:CParser.DeclarationContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#init_declarator_list.
|
||||
def enterInit_declarator_list(self, ctx:CParser.Init_declarator_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#init_declarator_list.
|
||||
def exitInit_declarator_list(self, ctx:CParser.Init_declarator_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#init_declarator.
|
||||
def enterInit_declarator(self, ctx:CParser.Init_declaratorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#init_declarator.
|
||||
def exitInit_declarator(self, ctx:CParser.Init_declaratorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#storage_class_specifier.
|
||||
def enterStorage_class_specifier(self, ctx:CParser.Storage_class_specifierContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#storage_class_specifier.
|
||||
def exitStorage_class_specifier(self, ctx:CParser.Storage_class_specifierContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#type_specifier.
|
||||
def enterType_specifier(self, ctx:CParser.Type_specifierContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#type_specifier.
|
||||
def exitType_specifier(self, ctx:CParser.Type_specifierContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#type_id.
|
||||
def enterType_id(self, ctx:CParser.Type_idContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#type_id.
|
||||
def exitType_id(self, ctx:CParser.Type_idContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#struct_or_union_specifier.
|
||||
def enterStruct_or_union_specifier(self, ctx:CParser.Struct_or_union_specifierContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#struct_or_union_specifier.
|
||||
def exitStruct_or_union_specifier(self, ctx:CParser.Struct_or_union_specifierContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#struct_or_union.
|
||||
def enterStruct_or_union(self, ctx:CParser.Struct_or_unionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#struct_or_union.
|
||||
def exitStruct_or_union(self, ctx:CParser.Struct_or_unionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#struct_declaration_list.
|
||||
def enterStruct_declaration_list(self, ctx:CParser.Struct_declaration_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#struct_declaration_list.
|
||||
def exitStruct_declaration_list(self, ctx:CParser.Struct_declaration_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#struct_declaration.
|
||||
def enterStruct_declaration(self, ctx:CParser.Struct_declarationContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#struct_declaration.
|
||||
def exitStruct_declaration(self, ctx:CParser.Struct_declarationContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#specifier_qualifier_list.
|
||||
def enterSpecifier_qualifier_list(self, ctx:CParser.Specifier_qualifier_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#specifier_qualifier_list.
|
||||
def exitSpecifier_qualifier_list(self, ctx:CParser.Specifier_qualifier_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#struct_declarator_list.
|
||||
def enterStruct_declarator_list(self, ctx:CParser.Struct_declarator_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#struct_declarator_list.
|
||||
def exitStruct_declarator_list(self, ctx:CParser.Struct_declarator_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#struct_declarator.
|
||||
def enterStruct_declarator(self, ctx:CParser.Struct_declaratorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#struct_declarator.
|
||||
def exitStruct_declarator(self, ctx:CParser.Struct_declaratorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#enum_specifier.
|
||||
def enterEnum_specifier(self, ctx:CParser.Enum_specifierContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#enum_specifier.
|
||||
def exitEnum_specifier(self, ctx:CParser.Enum_specifierContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#enumerator_list.
|
||||
def enterEnumerator_list(self, ctx:CParser.Enumerator_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#enumerator_list.
|
||||
def exitEnumerator_list(self, ctx:CParser.Enumerator_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#enumerator.
|
||||
def enterEnumerator(self, ctx:CParser.EnumeratorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#enumerator.
|
||||
def exitEnumerator(self, ctx:CParser.EnumeratorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#type_qualifier.
|
||||
def enterType_qualifier(self, ctx:CParser.Type_qualifierContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#type_qualifier.
|
||||
def exitType_qualifier(self, ctx:CParser.Type_qualifierContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#declarator.
|
||||
def enterDeclarator(self, ctx:CParser.DeclaratorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#declarator.
|
||||
def exitDeclarator(self, ctx:CParser.DeclaratorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#direct_declarator.
|
||||
def enterDirect_declarator(self, ctx:CParser.Direct_declaratorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#direct_declarator.
|
||||
def exitDirect_declarator(self, ctx:CParser.Direct_declaratorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#declarator_suffix.
|
||||
def enterDeclarator_suffix(self, ctx:CParser.Declarator_suffixContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#declarator_suffix.
|
||||
def exitDeclarator_suffix(self, ctx:CParser.Declarator_suffixContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#pointer.
|
||||
def enterPointer(self, ctx:CParser.PointerContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#pointer.
|
||||
def exitPointer(self, ctx:CParser.PointerContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#parameter_type_list.
|
||||
def enterParameter_type_list(self, ctx:CParser.Parameter_type_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#parameter_type_list.
|
||||
def exitParameter_type_list(self, ctx:CParser.Parameter_type_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#parameter_list.
|
||||
def enterParameter_list(self, ctx:CParser.Parameter_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#parameter_list.
|
||||
def exitParameter_list(self, ctx:CParser.Parameter_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#parameter_declaration.
|
||||
def enterParameter_declaration(self, ctx:CParser.Parameter_declarationContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#parameter_declaration.
|
||||
def exitParameter_declaration(self, ctx:CParser.Parameter_declarationContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#identifier_list.
|
||||
def enterIdentifier_list(self, ctx:CParser.Identifier_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#identifier_list.
|
||||
def exitIdentifier_list(self, ctx:CParser.Identifier_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#type_name.
|
||||
def enterType_name(self, ctx:CParser.Type_nameContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#type_name.
|
||||
def exitType_name(self, ctx:CParser.Type_nameContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#abstract_declarator.
|
||||
def enterAbstract_declarator(self, ctx:CParser.Abstract_declaratorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#abstract_declarator.
|
||||
def exitAbstract_declarator(self, ctx:CParser.Abstract_declaratorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#direct_abstract_declarator.
|
||||
def enterDirect_abstract_declarator(self, ctx:CParser.Direct_abstract_declaratorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#direct_abstract_declarator.
|
||||
def exitDirect_abstract_declarator(self, ctx:CParser.Direct_abstract_declaratorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#abstract_declarator_suffix.
|
||||
def enterAbstract_declarator_suffix(self, ctx:CParser.Abstract_declarator_suffixContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#abstract_declarator_suffix.
|
||||
def exitAbstract_declarator_suffix(self, ctx:CParser.Abstract_declarator_suffixContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#initializer.
|
||||
def enterInitializer(self, ctx:CParser.InitializerContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#initializer.
|
||||
def exitInitializer(self, ctx:CParser.InitializerContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#initializer_list.
|
||||
def enterInitializer_list(self, ctx:CParser.Initializer_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#initializer_list.
|
||||
def exitInitializer_list(self, ctx:CParser.Initializer_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#argument_expression_list.
|
||||
def enterArgument_expression_list(self, ctx:CParser.Argument_expression_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#argument_expression_list.
|
||||
def exitArgument_expression_list(self, ctx:CParser.Argument_expression_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#additive_expression.
|
||||
def enterAdditive_expression(self, ctx:CParser.Additive_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#additive_expression.
|
||||
def exitAdditive_expression(self, ctx:CParser.Additive_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#multiplicative_expression.
|
||||
def enterMultiplicative_expression(self, ctx:CParser.Multiplicative_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#multiplicative_expression.
|
||||
def exitMultiplicative_expression(self, ctx:CParser.Multiplicative_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#cast_expression.
|
||||
def enterCast_expression(self, ctx:CParser.Cast_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#cast_expression.
|
||||
def exitCast_expression(self, ctx:CParser.Cast_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#unary_expression.
|
||||
def enterUnary_expression(self, ctx:CParser.Unary_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#unary_expression.
|
||||
def exitUnary_expression(self, ctx:CParser.Unary_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#postfix_expression.
|
||||
def enterPostfix_expression(self, ctx:CParser.Postfix_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#postfix_expression.
|
||||
def exitPostfix_expression(self, ctx:CParser.Postfix_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#macro_parameter_list.
|
||||
def enterMacro_parameter_list(self, ctx:CParser.Macro_parameter_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#macro_parameter_list.
|
||||
def exitMacro_parameter_list(self, ctx:CParser.Macro_parameter_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#unary_operator.
|
||||
def enterUnary_operator(self, ctx:CParser.Unary_operatorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#unary_operator.
|
||||
def exitUnary_operator(self, ctx:CParser.Unary_operatorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#primary_expression.
|
||||
def enterPrimary_expression(self, ctx:CParser.Primary_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#primary_expression.
|
||||
def exitPrimary_expression(self, ctx:CParser.Primary_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#constant.
|
||||
def enterConstant(self, ctx:CParser.ConstantContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#constant.
|
||||
def exitConstant(self, ctx:CParser.ConstantContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#expression.
|
||||
def enterExpression(self, ctx:CParser.ExpressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#expression.
|
||||
def exitExpression(self, ctx:CParser.ExpressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#constant_expression.
|
||||
def enterConstant_expression(self, ctx:CParser.Constant_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#constant_expression.
|
||||
def exitConstant_expression(self, ctx:CParser.Constant_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#assignment_expression.
|
||||
def enterAssignment_expression(self, ctx:CParser.Assignment_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#assignment_expression.
|
||||
def exitAssignment_expression(self, ctx:CParser.Assignment_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#lvalue.
|
||||
def enterLvalue(self, ctx:CParser.LvalueContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#lvalue.
|
||||
def exitLvalue(self, ctx:CParser.LvalueContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#assignment_operator.
|
||||
def enterAssignment_operator(self, ctx:CParser.Assignment_operatorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#assignment_operator.
|
||||
def exitAssignment_operator(self, ctx:CParser.Assignment_operatorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#conditional_expression.
|
||||
def enterConditional_expression(self, ctx:CParser.Conditional_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#conditional_expression.
|
||||
def exitConditional_expression(self, ctx:CParser.Conditional_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#logical_or_expression.
|
||||
def enterLogical_or_expression(self, ctx:CParser.Logical_or_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#logical_or_expression.
|
||||
def exitLogical_or_expression(self, ctx:CParser.Logical_or_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#logical_and_expression.
|
||||
def enterLogical_and_expression(self, ctx:CParser.Logical_and_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#logical_and_expression.
|
||||
def exitLogical_and_expression(self, ctx:CParser.Logical_and_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#inclusive_or_expression.
|
||||
def enterInclusive_or_expression(self, ctx:CParser.Inclusive_or_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#inclusive_or_expression.
|
||||
def exitInclusive_or_expression(self, ctx:CParser.Inclusive_or_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#exclusive_or_expression.
|
||||
def enterExclusive_or_expression(self, ctx:CParser.Exclusive_or_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#exclusive_or_expression.
|
||||
def exitExclusive_or_expression(self, ctx:CParser.Exclusive_or_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#and_expression.
|
||||
def enterAnd_expression(self, ctx:CParser.And_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#and_expression.
|
||||
def exitAnd_expression(self, ctx:CParser.And_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#equality_expression.
|
||||
def enterEquality_expression(self, ctx:CParser.Equality_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#equality_expression.
|
||||
def exitEquality_expression(self, ctx:CParser.Equality_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#relational_expression.
|
||||
def enterRelational_expression(self, ctx:CParser.Relational_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#relational_expression.
|
||||
def exitRelational_expression(self, ctx:CParser.Relational_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#shift_expression.
|
||||
def enterShift_expression(self, ctx:CParser.Shift_expressionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#shift_expression.
|
||||
def exitShift_expression(self, ctx:CParser.Shift_expressionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#statement.
|
||||
def enterStatement(self, ctx:CParser.StatementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#statement.
|
||||
def exitStatement(self, ctx:CParser.StatementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#asm2_statement.
|
||||
def enterAsm2_statement(self, ctx:CParser.Asm2_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#asm2_statement.
|
||||
def exitAsm2_statement(self, ctx:CParser.Asm2_statementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#asm1_statement.
|
||||
def enterAsm1_statement(self, ctx:CParser.Asm1_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#asm1_statement.
|
||||
def exitAsm1_statement(self, ctx:CParser.Asm1_statementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#asm_statement.
|
||||
def enterAsm_statement(self, ctx:CParser.Asm_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#asm_statement.
|
||||
def exitAsm_statement(self, ctx:CParser.Asm_statementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#macro_statement.
|
||||
def enterMacro_statement(self, ctx:CParser.Macro_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#macro_statement.
|
||||
def exitMacro_statement(self, ctx:CParser.Macro_statementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#labeled_statement.
|
||||
def enterLabeled_statement(self, ctx:CParser.Labeled_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#labeled_statement.
|
||||
def exitLabeled_statement(self, ctx:CParser.Labeled_statementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#compound_statement.
|
||||
def enterCompound_statement(self, ctx:CParser.Compound_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#compound_statement.
|
||||
def exitCompound_statement(self, ctx:CParser.Compound_statementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#statement_list.
|
||||
def enterStatement_list(self, ctx:CParser.Statement_listContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#statement_list.
|
||||
def exitStatement_list(self, ctx:CParser.Statement_listContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#expression_statement.
|
||||
def enterExpression_statement(self, ctx:CParser.Expression_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#expression_statement.
|
||||
def exitExpression_statement(self, ctx:CParser.Expression_statementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#selection_statement.
|
||||
def enterSelection_statement(self, ctx:CParser.Selection_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#selection_statement.
|
||||
def exitSelection_statement(self, ctx:CParser.Selection_statementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#iteration_statement.
|
||||
def enterIteration_statement(self, ctx:CParser.Iteration_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#iteration_statement.
|
||||
def exitIteration_statement(self, ctx:CParser.Iteration_statementContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by CParser#jump_statement.
|
||||
def enterJump_statement(self, ctx:CParser.Jump_statementContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by CParser#jump_statement.
|
||||
def exitJump_statement(self, ctx:CParser.Jump_statementContext):
|
||||
pass
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -223,7 +223,7 @@ class Check(object):
|
||||
IndexOfLine = 0
|
||||
for Line in op:
|
||||
IndexOfLine += 1
|
||||
if not Line.endswith('\r\n'):
|
||||
if not bytes.decode(Line).endswith('\r\n'):
|
||||
OtherMsg = "File %s has invalid line ending at line %s" % (Record[1], IndexOfLine)
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_GENERAL_CHECK_INVALID_LINE_ENDING, OtherMsg=OtherMsg, BelongsToTable='File', BelongsToItem=Record[0])
|
||||
|
||||
@ -235,7 +235,7 @@ class Check(object):
|
||||
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
if Record[2].upper() not in EccGlobalData.gConfig.BinaryExtList:
|
||||
op = open(Record[1], 'rb').readlines()
|
||||
op = open(Record[1], 'r').readlines()
|
||||
IndexOfLine = 0
|
||||
for Line in op:
|
||||
IndexOfLine += 1
|
||||
|
@ -22,7 +22,7 @@ import re
|
||||
import Common.LongFilePathOs as os
|
||||
import sys
|
||||
|
||||
import antlr3
|
||||
import antlr4
|
||||
from Ecc.CLexer import CLexer
|
||||
from Ecc.CParser import CParser
|
||||
|
||||
@ -499,13 +499,14 @@ class CodeFragmentCollector:
|
||||
def ParseFile(self):
|
||||
self.PreprocessFile()
|
||||
# restore from ListOfList to ListOfString
|
||||
# print(self.Profile.FileLinesList)
|
||||
self.Profile.FileLinesList = ["".join(list) for list in self.Profile.FileLinesList]
|
||||
FileStringContents = ''
|
||||
for fileLine in self.Profile.FileLinesList:
|
||||
FileStringContents += fileLine
|
||||
cStream = antlr3.StringStream(FileStringContents)
|
||||
cStream = antlr4.InputStream(FileStringContents)
|
||||
lexer = CLexer(cStream)
|
||||
tStream = antlr3.CommonTokenStream(lexer)
|
||||
tStream = antlr4.CommonTokenStream(lexer)
|
||||
parser = CParser(tStream)
|
||||
parser.translation_unit()
|
||||
|
||||
@ -516,9 +517,9 @@ class CodeFragmentCollector:
|
||||
FileStringContents = ''
|
||||
for fileLine in self.Profile.FileLinesList:
|
||||
FileStringContents += fileLine
|
||||
cStream = antlr3.StringStream(FileStringContents)
|
||||
cStream = antlr4.InputStream(FileStringContents)
|
||||
lexer = CLexer(cStream)
|
||||
tStream = antlr3.CommonTokenStream(lexer)
|
||||
tStream = antlr4.CommonTokenStream(lexer)
|
||||
parser = CParser(tStream)
|
||||
parser.translation_unit()
|
||||
|
||||
|
@ -205,7 +205,7 @@ class Ecc(object):
|
||||
Op = open(EccGlobalData.gConfig.MetaDataFileCheckPathOfGenerateFileList, 'w+')
|
||||
#SkipDirs = Read from config file
|
||||
SkipDirs = EccGlobalData.gConfig.SkipDirList
|
||||
SkipDirString = string.join(SkipDirs, '|')
|
||||
SkipDirString = '|'.join(SkipDirs)
|
||||
# p = re.compile(r'.*[\\/](?:%s)[\\/]?.*' % SkipDirString)
|
||||
p = re.compile(r'.*[\\/](?:%s^\S)[\\/]?.*' % SkipDirString)
|
||||
for scanFolder in ScanFolders:
|
||||
|
@ -47,7 +47,7 @@ class FileProfile :
|
||||
self.FileLinesList = []
|
||||
self.FileLinesListFromFile = []
|
||||
try:
|
||||
fsock = open(FileName, "rb", 0)
|
||||
fsock = open(FileName, "r")
|
||||
try:
|
||||
self.FileLinesListFromFile = fsock.readlines()
|
||||
finally:
|
||||
|
@ -113,7 +113,7 @@ def ParseHeaderCommentSection(CommentList, FileName = None):
|
||||
#
|
||||
Last = 0
|
||||
HeaderCommentStage = HEADER_COMMENT_NOT_STARTED
|
||||
for Index in xrange(len(CommentList)-1, 0, -1):
|
||||
for Index in range(len(CommentList) - 1, 0, -1):
|
||||
Line = CommentList[Index][0]
|
||||
if _IsCopyrightLine(Line):
|
||||
Last = Index
|
||||
|
@ -35,7 +35,7 @@ IgnoredKeywordList = ['EFI_ERROR']
|
||||
|
||||
def GetIgnoredDirListPattern():
|
||||
skipList = list(EccGlobalData.gConfig.SkipDirList) + ['.svn']
|
||||
DirString = string.join(skipList, '|')
|
||||
DirString = '|'.join(skipList)
|
||||
p = re.compile(r'.*[\\/](?:%s)[\\/]?.*' % DirString)
|
||||
return p
|
||||
|
||||
@ -963,7 +963,7 @@ def StripComments(Str):
|
||||
ListFromStr[Index] = ' '
|
||||
Index += 1
|
||||
# check for // comment
|
||||
elif ListFromStr[Index] == '/' and ListFromStr[Index + 1] == '/' and ListFromStr[Index + 2] != '\n':
|
||||
elif ListFromStr[Index] == '/' and ListFromStr[Index + 1] == '/':
|
||||
InComment = True
|
||||
DoubleSlashComment = True
|
||||
|
||||
@ -1297,7 +1297,7 @@ def CheckFuncLayoutReturnType(FullFileName):
|
||||
Result0 = Result[0]
|
||||
if Result0.upper().startswith('STATIC'):
|
||||
Result0 = Result0[6:].strip()
|
||||
Index = Result0.find(ReturnType)
|
||||
Index = Result0.find(TypeStart)
|
||||
if Index != 0 or Result[3] != 0:
|
||||
PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, '[%s] Return Type should appear at the start of line' % FuncName, 'Function', Result[1])
|
||||
|
||||
|
Reference in New Issue
Block a user