mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Finish ECMAScript lexer. Upgrade to ANTLR 4.5.1.
Also added ANTLR src zip so you can see source. Change-Id: I5041445c1401dfe0f35a80b9e5f6809504930120
This commit is contained in:
parent
fac0ca9ddc
commit
91f4a98335
5 changed files with 302 additions and 18 deletions
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="antlr-runtime-4.5.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="src-gen"/>
|
||||
<classpathentry exported="true" kind="lib" path="antlr-runtime-4.5.1.jar" sourcepath="antlr-4.5.1.zip"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
5
qt/org.eclipse.cdt.qt.qml.core/.gitignore
vendored
5
qt/org.eclipse.cdt.qt.qml.core/.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
/src-gen/
|
||||
/antlr-4.5-complete.jar
|
||||
/antlr-runtime-4.5.jar
|
||||
/bbQML.g
|
||||
/antlr-4.5.1-complete.jar
|
||||
/antlr-4.5.1.zip
|
||||
/antlr-runtime-4.5.1.jar
|
||||
|
|
|
@ -10,6 +10,33 @@
|
|||
|
||||
grammar ECMAScript;
|
||||
|
||||
@lexer::members {
|
||||
private boolean strictMode;
|
||||
|
||||
private boolean regexPermitted() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
private boolean insertSemi() {
|
||||
if (getTokenStream().LT(1).getType() == RBRACE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO - look for line terminator in hidden channel before
|
||||
// another token in the default channel
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
semi
|
||||
: SEMI
|
||||
| EOF
|
||||
| {insertSemi()}?
|
||||
;
|
||||
|
||||
singleExpression
|
||||
: Identifier
|
||||
;
|
||||
|
@ -23,7 +50,9 @@ WhiteSpaceSequence
|
|||
;
|
||||
|
||||
fragment WhiteSpace
|
||||
: [\t\u000B\u000C]
|
||||
: '\u0009'
|
||||
| '\u000B'
|
||||
| '\u000C'
|
||||
// Unicode cat: Zs
|
||||
| '\u0020'
|
||||
| '\u00A0'
|
||||
|
@ -32,6 +61,18 @@ fragment WhiteSpace
|
|||
| '\u202F'
|
||||
| '\u205F'
|
||||
| '\u3000'
|
||||
| '\uFEFF'
|
||||
;
|
||||
|
||||
fragment LineTerminator
|
||||
: [\u000A\u000D\u2028\u2029]
|
||||
;
|
||||
|
||||
fragment LineTerminatorSequence
|
||||
: '\u000A'
|
||||
| '\u000D' '\u000A'?
|
||||
| '\u2028'
|
||||
| '\u2029'
|
||||
;
|
||||
|
||||
MultiLineComment
|
||||
|
@ -39,7 +80,248 @@ MultiLineComment
|
|||
;
|
||||
|
||||
SingleLineCOmment
|
||||
: '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN)
|
||||
: '//' ~[\u000A\u000D\u2028\u2029]* -> channel(HIDDEN)
|
||||
;
|
||||
|
||||
// Keywords
|
||||
BREAK : 'break' ;
|
||||
DO : 'do' ;
|
||||
INSTANCEOF : 'instanceof' ;
|
||||
TYPEOF : 'typeof' ;
|
||||
CASE : 'case' ;
|
||||
ELSE : 'else' ;
|
||||
NEW : 'new' ;
|
||||
VAR : 'var' ;
|
||||
CATCH : 'catch' ;
|
||||
FINALLY : 'finally' ;
|
||||
RETURN : 'return' ;
|
||||
VOID : 'void' ;
|
||||
CONTINUE : 'continue' ;
|
||||
FOR : 'for' ;
|
||||
SWITCH : 'switch' ;
|
||||
WHILE : 'while' ;
|
||||
DEBUGGER : 'debugger' ;
|
||||
FUNCTION : 'function' ;
|
||||
THIS : 'this' ;
|
||||
WITH : 'with' ;
|
||||
DEFAULT : 'default' ;
|
||||
IF : 'if' ;
|
||||
THROW : 'throw' ;
|
||||
DELETE : 'delete' ;
|
||||
IN : 'in' ;
|
||||
TRY : 'try' ;
|
||||
|
||||
// Future Reserved Words
|
||||
CLASS : 'class' ;
|
||||
ENUM : 'enum' ;
|
||||
EXTENDS : 'extends' ;
|
||||
SUPER : 'super' ;
|
||||
CONST : 'const' ;
|
||||
EXPORT : 'export' ;
|
||||
IMPORT : 'import' ;
|
||||
|
||||
// Strict Future Reserved Words
|
||||
IMPLEMENTS : {strictMode}? 'implements' ;
|
||||
LET : {strictMode}? 'let' ;
|
||||
PRIVATE : {strictMode}? 'private' ;
|
||||
PUBLIC : {strictMode}? 'public' ;
|
||||
YIELD : {strictMode}? 'yield' ;
|
||||
INTERFACE : {strictMode}? 'interface' ;
|
||||
PACKAGE : {strictMode}? 'package' ;
|
||||
PROTECTED : {strictMode}? 'protected' ;
|
||||
STATIC : {strictMode}? 'static' ;
|
||||
|
||||
LBRACE : '{' ;
|
||||
RBRACE : '}' ;
|
||||
LPAREN : '(' ;
|
||||
RPAREN : ')' ;
|
||||
LBRACK : '[' ;
|
||||
RBRACK : ']' ;
|
||||
DOT : '.' ;
|
||||
SEMI : ';' ;
|
||||
COMMA : ',' ;
|
||||
LT : '<' ;
|
||||
GT : '>' ;
|
||||
LTE : '<=' ;
|
||||
GTE : '>=' ;
|
||||
EQUAL : '==' ;
|
||||
NEQUAL : '!=' ;
|
||||
IEQUAL : '===' ;
|
||||
NIEQUAL : '!==' ;
|
||||
PLUS : '+' ;
|
||||
MINUS : '-' ;
|
||||
MULT : '*' ;
|
||||
MOD : '%' ;
|
||||
INCR : '++' ;
|
||||
DECR : '--' ;
|
||||
SHIFTL : '<<' ;
|
||||
SHIFTR : '>>' ;
|
||||
USHIFTR : '>>>' ;
|
||||
BAND : '&' ;
|
||||
BOR : '|' ;
|
||||
BXOR : '^' ;
|
||||
LNOT : '!' ;
|
||||
BNOT : '~' ;
|
||||
LAND : '&&' ;
|
||||
LOR : '||' ;
|
||||
QUEST : '?' ;
|
||||
COLON : ':' ;
|
||||
ASSIGN : '=' ;
|
||||
PLUSASSIGN : '+=' ;
|
||||
MINUSASSIGN : '-=' ;
|
||||
MULTASSIGN : '*=' ;
|
||||
MODASSIGN : '%=' ;
|
||||
SHIFTLASSIGN : '<<=' ;
|
||||
SHIFTRASSIGN : '>>=' ;
|
||||
USHIFTRASSIGN : '>>>=' ;
|
||||
BANDASSIGN : '&=' ;
|
||||
BORASSIGN : '|=' ;
|
||||
BXORASSIGN : '^=' ;
|
||||
DIV : '/' ;
|
||||
DIVASSIGN : '/=' ;
|
||||
|
||||
NullLiteral
|
||||
: 'null'
|
||||
;
|
||||
|
||||
BooleanLiteral
|
||||
: 'true'
|
||||
| 'false'
|
||||
;
|
||||
|
||||
DecimalLiteral
|
||||
: DecimalIntegerLiteral '.' DecimalDigit* ExponentPart?
|
||||
| '.' DecimalDigit+ ExponentPart?
|
||||
| DecimalIntegerLiteral ExponentPart?
|
||||
;
|
||||
|
||||
fragment DecimalIntegerLiteral
|
||||
: '0'
|
||||
| NonZeroDigit DecimalDigit*
|
||||
;
|
||||
|
||||
fragment DecimalDigit
|
||||
: [0-9]
|
||||
;
|
||||
|
||||
fragment NonZeroDigit
|
||||
: [1-9]
|
||||
;
|
||||
|
||||
fragment ExponentPart
|
||||
: ExponentIndicator SignedInteger
|
||||
;
|
||||
|
||||
fragment ExponentIndicator
|
||||
: [eE]
|
||||
;
|
||||
|
||||
fragment SignedInteger
|
||||
: [+-]? DecimalDigit+
|
||||
;
|
||||
|
||||
HexIntegerLiteral
|
||||
: '0' [xX] HexDigit+
|
||||
;
|
||||
|
||||
fragment HexDigit
|
||||
: [0-9a-fA-F]
|
||||
;
|
||||
|
||||
StringLiteral
|
||||
: '"' DoubleStringCharacter* '"'
|
||||
| '\'' SingleStringCharacter* '\''
|
||||
;
|
||||
|
||||
fragment DoubleStringCharacter
|
||||
: ~["\\\u000A\u000D\u2028\u2029]
|
||||
| '\\' EscapeSequence
|
||||
| LineContinuation
|
||||
;
|
||||
|
||||
fragment SingleStringCharacter
|
||||
: ~['\\\u000A\u000D\u2028\u2029]
|
||||
| '\\' EscapeSequence
|
||||
| LineContinuation
|
||||
;
|
||||
|
||||
fragment LineContinuation
|
||||
: '\\' LineTerminatorSequence
|
||||
;
|
||||
|
||||
fragment EscapeSequence
|
||||
: CharacterEscapeSequence
|
||||
| '0'
|
||||
| HexEscapeSequence
|
||||
| UnicodeEscapeSequence
|
||||
;
|
||||
|
||||
fragment CharacterEscapeSequence
|
||||
: SingleEscapeCharacter
|
||||
| NonEscapeCharacter
|
||||
;
|
||||
|
||||
fragment SingleEscapeCharacter
|
||||
: ['"\\bfnrtv]
|
||||
;
|
||||
|
||||
fragment NonEscapeCharacter
|
||||
: ~['"\\bfnrtv0-9xu\r\n]
|
||||
;
|
||||
|
||||
fragment EscapeCharacter
|
||||
: SingleEscapeCharacter
|
||||
| DecimalDigit
|
||||
| [xu]
|
||||
;
|
||||
|
||||
fragment HexEscapeSequence
|
||||
: '\\' HexDigit HexDigit
|
||||
;
|
||||
|
||||
fragment UnicodeEscapeSequence
|
||||
: '\\' HexDigit HexDigit HexDigit HexDigit
|
||||
;
|
||||
|
||||
RegularExpressionLiteral
|
||||
: {regexPermitted()}? '/' RegularExpressionBody '/' RegularExpressionFlags
|
||||
;
|
||||
|
||||
fragment RegularExpressionBody
|
||||
: RegularExpressionFirstChar RegularExpressionChar*
|
||||
;
|
||||
|
||||
fragment RegularExpressionFirstChar
|
||||
: ~[\u000A\u000D\u2028\u2029*\\/[]
|
||||
| RegularExpressionBackslashSequence
|
||||
| RegularExpressionClass
|
||||
;
|
||||
|
||||
fragment RegularExpressionChar
|
||||
: ~[\u000A\u000D\u2028\u2029\\/[]
|
||||
| RegularExpressionBackslashSequence
|
||||
| RegularExpressionClass
|
||||
;
|
||||
|
||||
fragment RegularExpressionBackslashSequence
|
||||
: '\\' RegularExpressionNonTerminator
|
||||
;
|
||||
|
||||
fragment RegularExpressionNonTerminator
|
||||
: ~[\u000A\u000D\u2028\u2029]
|
||||
;
|
||||
|
||||
fragment RegularExpressionClass
|
||||
: '[' RegularExpressionClassChar* ']'
|
||||
;
|
||||
|
||||
fragment RegularExpressionClassChar
|
||||
: ~[\u000A\u000D\u2028\u2029\]\\]
|
||||
| RegularExpressionBackslashSequence
|
||||
;
|
||||
|
||||
fragment RegularExpressionFlags
|
||||
: IdentifierPart*
|
||||
;
|
||||
|
||||
Identifier
|
||||
|
@ -60,14 +342,6 @@ fragment IdentifierPart
|
|||
| [\u200C\u200D]
|
||||
;
|
||||
|
||||
fragment HexDigit
|
||||
: [0-9a-fA-f]
|
||||
;
|
||||
|
||||
fragment UnicodeEscapeSequence
|
||||
: '\\' HexDigit HexDigit HexDigit HexDigit
|
||||
;
|
||||
|
||||
// Unicode cats: Lu, Ll, Lt, Lm, Lo, Nl
|
||||
fragment UnicodeLetter
|
||||
: [\u0041-\u005A]
|
||||
|
|
|
@ -7,5 +7,5 @@ Bundle-Activator: org.eclipse.cdt.qt.qml.core.internal.Activator
|
|||
Require-Bundle: org.eclipse.core.runtime
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: antlr-runtime-4.5.jar,
|
||||
Bundle-ClassPath: antlr-runtime-4.5.1.jar,
|
||||
.
|
||||
|
|
|
@ -5,19 +5,28 @@
|
|||
</description>
|
||||
|
||||
<target name="getAntlr">
|
||||
<get src="http://www.antlr.org/download/antlr-4.5-complete.jar" dest="antlr-4.5-complete.jar" skipexisting="true"/>
|
||||
<get src="http://www.antlr.org/download/antlr-runtime-4.5.jar" dest="antlr-runtime-4.5.jar" skipexisting="true"/>
|
||||
<get src="http://www.antlr.org/download/antlr-4.5.1-complete.jar" dest="antlr-4.5.1-complete.jar" skipexisting="true"/>
|
||||
<get src="http://www.antlr.org/download/antlr-runtime-4.5.1.jar" dest="antlr-runtime-4.5.1.jar" skipexisting="true"/>
|
||||
<get src="https://github.com/antlr/antlr4/archive/4.5.1.zip" dest="antlr-4.5.1.zip" skipexisting="true"/>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="getAntlr">
|
||||
<java jar="antlr-4.5-complete.jar" fork="true">
|
||||
<java classname="org.antlr.v4.Tool" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="antlr-4.5.1-complete.jar"/>
|
||||
<pathelement path="${java.class.path}"/>
|
||||
</classpath>
|
||||
<arg value="-o"/>
|
||||
<arg value="src-gen/org/eclipse/cdt/qt/qml/core/parser"/>
|
||||
<arg value="-package"/>
|
||||
<arg value="org.eclipse.cdt.qt.qml.core.parser"/>
|
||||
<arg value="ECMAScript.g4"/>
|
||||
</java>
|
||||
<java jar="antlr-4.5-complete.jar" fork="true">
|
||||
<java classname="org.antlr.v4.Tool" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="antlr-4.5.1-complete.jar"/>
|
||||
<pathelement path="${java.class.path}"/>
|
||||
</classpath>
|
||||
<arg value="-o"/>
|
||||
<arg value="src-gen/org/eclipse/cdt/qt/qml/core/parser"/>
|
||||
<arg value="-package"/>
|
||||
|
|
Loading…
Add table
Reference in a new issue