Skip to content

The Unified and Autonomous Development Platform

midwork

robin shinedaf14ef7febf
diff --git a/commons.wicket/pom.xml b/commons.wicket/pom.xml
index 5a3fe64ac8..36ce0aff73 100644
--- a/commons.wicket/pom.xml
+++ b/commons.wicket/pom.xml
@@ -21,6 +21,14 @@
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <configuration>
+ <libDirectory></libDirectory>
+ <visitor>true</visitor>
+ </configuration>
+ </plugin>
</plugins>
</build>
<dependencies>
diff --git a/commons.wicket/src/main/java/LexBasic.g4 b/commons.wicket/src/main/java/LexBasic.g4
new file mode 100644
index 0000000000..241ce5c494
--- /dev/null
+++ b/commons.wicket/src/main/java/LexBasic.g4
@@ -0,0 +1,285 @@
+/*
+ * [The "BSD license"]
+ * Copyright (c) 2014-2015 Gerald Rosenberg
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * A generally reusable set of fragments for import in to Lexer grammars.
+ *
+ * Modified 2015.06.16 gbr -
+ * -- generalized for inclusion into the ANTLRv4 grammar distribution
+ *
+ */
+
+lexer grammar LexBasic;
+
+import LexUnicode; // Formal set of Unicode ranges
+
+
+// ======================================================
+// Lexer fragments
+//
+
+
+// -----------------------------------
+// Whitespace & Comments
+
+fragment Ws : Hws | Vws ;
+fragment Hws : [ \t] ;
+fragment Vws : [\r\n\f] ;
+
+fragment DocComment : '/**' .*? ('*/' | EOF) ;
+fragment BlockComment : '/*' .*? ('*/' | EOF) ;
+
+fragment LineComment : '//' ~[\r\n]* ;
+fragment LineCommentExt : '//' ~'\n'* ( '\n' Hws* '//' ~'\n'* )* ;
+
+
+// -----------------------------------
+// Escapes
+
+// Any kind of escaped character that we can embed within ANTLR literal strings.
+fragment EscSeq
+ : Esc
+ ( [btnfr"'\\] // The standard escaped character set such as tab, newline, etc.
+ | UnicodeEsc // A Unicode escape sequence
+ | . // Invalid escape character
+ | EOF // Incomplete at EOF
+ )
+ ;
+
+fragment EscAny
+ : Esc .
+ ;
+
+fragment UnicodeEsc
+ : 'u' (HexDigit (HexDigit (HexDigit HexDigit?)?)?)?
+ ;
+
+fragment OctalEscape
+ : OctalDigit
+ | OctalDigit OctalDigit
+ | [0-3] OctalDigit OctalDigit
+ ;
+
+
+// -----------------------------------
+// Numerals
+
+fragment HexNumeral
+ : '0' [xX] HexDigits
+ ;
+
+fragment OctalNumeral
+ : '0' '_' OctalDigits
+ ;
+
+fragment DecimalNumeral
+ : '0'
+ | [1-9] DecDigit*
+ ;
+
+fragment BinaryNumeral
+ : '0' [bB] BinaryDigits
+ ;
+
+
+// -----------------------------------
+// Digits
+
+fragment HexDigits : HexDigit+ ;
+fragment DecDigits : DecDigit+ ;
+fragment OctalDigits : OctalDigit+ ;
+fragment BinaryDigits : BinaryDigit+ ;
+
+fragment HexDigit : [0-9a-fA-F] ;
+fragment DecDigit : [0-9] ;
+fragment OctalDigit : [0-7] ;
+fragment BinaryDigit : [01] ;
+
+
+// -----------------------------------
+// Literals
+
+fragment BoolLiteral : True | False ;
+
+fragment CharLiteral : SQuote ( EscSeq | ~['\r\n\\] ) SQuote ;
+fragment SQuoteLiteral : SQuote ( EscSeq | ~['\r\n\\] )* SQuote ;
+fragment DQuoteLiteral : DQuote ( EscSeq | ~["\r\n\\] )* DQuote ;
+fragment USQuoteLiteral : SQuote ( EscSeq | ~['\r\n\\] )* ;
+
+fragment DecimalFloatingPointLiteral
+ : DecDigits Dot DecDigits? ExponentPart? FloatTypeSuffix?
+ | Dot DecDigits ExponentPart? FloatTypeSuffix?
+ | DecDigits ExponentPart FloatTypeSuffix?
+ | DecDigits FloatTypeSuffix
+ ;
+
+fragment ExponentPart
+ : [eE] [+-]? DecDigits
+ ;
+
+fragment FloatTypeSuffix
+ : [fFdD]
+ ;
+
+fragment HexadecimalFloatingPointLiteral
+ : HexSignificand BinaryExponent FloatTypeSuffix?
+ ;
+
+fragment HexSignificand
+ : HexNumeral Dot?
+ | '0' [xX] HexDigits? Dot HexDigits
+ ;
+
+fragment BinaryExponent
+ : [pP] [+-]? DecDigits
+ ;
+
+
+// -----------------------------------
+// Character ranges
+
+fragment NameChar
+ : NameStartChar
+ | '0'..'9'
+ | Underscore
+ | '\u00B7'
+ | '\u0300'..'\u036F'
+ | '\u203F'..'\u2040'
+ ;
+
+fragment NameStartChar
+ : 'A'..'Z'
+ | 'a'..'z'
+ | '\u00C0'..'\u00D6'
+ | '\u00D8'..'\u00F6'
+ | '\u00F8'..'\u02FF'
+ | '\u0370'..'\u037D'
+ | '\u037F'..'\u1FFF'
+ | '\u200C'..'\u200D'
+ | '\u2070'..'\u218F'
+ | '\u2C00'..'\u2FEF'
+ | '\u3001'..'\uD7FF'
+ | '\uF900'..'\uFDCF'
+ | '\uFDF0'..'\uFFFD'
+ ; // ignores | ['\u10000-'\uEFFFF] ;
+
+
+fragment JavaLetter
+ : [a-zA-Z$_] // "java letters" below 0xFF
+ | JavaUnicodeChars
+ ;
+
+fragment JavaLetterOrDigit
+ : [a-zA-Z0-9$_] // "java letters or digits" below 0xFF
+ | JavaUnicodeChars
+ ;
+
+// covers all characters above 0xFF which are not a surrogate
+// and UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
+fragment JavaUnicodeChars
+ : ~[\u0000-\u00FF\uD800-\uDBFF] {Character.isJavaIdentifierPart(_input.LA(-1))}?
+ | [\uD800-\uDBFF] [\uDC00-\uDFFF] {Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}?
+ ;
+
+
+// -----------------------------------
+// Types
+
+fragment Boolean : 'boolean' ;
+fragment Byte : 'byte' ;
+fragment Short : 'short' ;
+fragment Int : 'int' ;
+fragment Long : 'long' ;
+fragment Char : 'char' ;
+fragment Float : 'float' ;
+fragment Double : 'double' ;
+
+fragment True : 'true' ;
+fragment False : 'false' ;
+
+
+// -----------------------------------
+// Symbols
+
+fragment Esc : '\\' ;
+fragment Colon : ':' ;
+fragment DColon : '::' ;
+fragment SQuote : '\'' ;
+fragment DQuote : '"' ;
+fragment BQuote : '`' ;
+fragment LParen : '(' ;
+fragment RParen : ')' ;
+fragment LBrace : '{' ;
+fragment RBrace : '}' ;
+fragment LBrack : '[' ;
+fragment RBrack : ']' ;
+fragment RArrow : '->' ;
+fragment Lt : '<' ;
+fragment Gt : '>' ;
+fragment Lte : '<=' ;
+fragment Gte : '>=' ;
+fragment Equal : '=' ;
+fragment NotEqual : '!=' ;
+fragment Question : '?' ;
+fragment Bang : '!' ;
+fragment Star : '*' ;
+fragment Slash : '/' ;
+fragment Percent : '%' ;
+fragment Caret : '^' ;
+fragment Plus : '+' ;
+fragment Minus : '-' ;
+fragment PlusAssign : '+=' ;
+fragment MinusAssign : '-=' ;
+fragment MulAssign : '*=' ;
+fragment DivAssign : '/=' ;
+fragment AndAssign : '&=' ;
+fragment OrAssign : '|=' ;
+fragment XOrAssign : '^=' ;
+fragment ModAssign : '%=' ;
+fragment LShiftAssign : '<<=' ;
+fragment RShiftAssign : '>>=' ;
+fragment URShiftAssign : '>>>=';
+fragment Underscore : '_' ;
+fragment Pipe : '|' ;
+fragment Amp : '&' ;
+fragment And : '&&' ;
+fragment Or : '||' ;
+fragment Inc : '++' ;
+fragment Dec : '--' ;
+fragment LShift : '<<' ;
+fragment RShift : '>>' ;
+fragment Dollar : '$' ;
+fragment Comma : ',' ;
+fragment Semi : ';' ;
+fragment Dot : '.' ;
+fragment Range : '..' ;
+fragment Ellipsis : '...' ;
+fragment At : '@' ;
+fragment Pound : '#' ;
+fragment Tilde : '~' ;
diff --git a/commons.wicket/src/main/java/LexUnicode.g4 b/commons.wicket/src/main/java/LexUnicode.g4
new file mode 100644
index 0000000000..8aeb0e0a70
--- /dev/null
+++ b/commons.wicket/src/main/java/LexUnicode.g4
@@ -0,0 +1,643 @@
+/*
+ * [The "BSD license"]
+ * Copyright (c) 2014-2015 Gerald Rosenberg
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * A generally reusable Unicode character set description for import in to Lexer grammars.
+ *
+ * Modified 2015.06.16 gbr -
+ * -- generalized for inclusion into the ANTLRv4 grammar distribution
+ *
+ */
+
+lexer grammar LexUnicode;
+
+// ======================================================
+// Lexer fragments
+//
+
+fragment UnicodeLetter
+ : UnicodeClass_LU
+ | UnicodeClass_LL
+ | UnicodeClass_LT
+ | UnicodeClass_LM
+ | UnicodeClass_LO
+ ;
+
+fragment UnicodeClass_LU
+ : '\u0041'..'\u005a'
+ | '\u00c0'..'\u00de'
+ | '\u00d8'..'\u00de'
+ | '\u0100'..'\u0136'
+ | '\u0139'..'\u0147'
+ | '\u014a'..'\u0178'
+ | '\u0179'..'\u017d'
+ | '\u0181'..'\u0182'
+ | '\u0184'..'\u0186'
+ | '\u0187'..'\u0189'
+ | '\u018a'..'\u018b'
+ | '\u018e'..'\u0191'
+ | '\u0193'..'\u0194'
+ | '\u0196'..'\u0198'
+ | '\u019c'..'\u019d'
+ | '\u019f'..'\u01a0'
+ | '\u01a2'..'\u01a6'
+ | '\u01a7'..'\u01a9'
+ | '\u01ac'..'\u01ae'
+ | '\u01af'..'\u01b1'
+ | '\u01b2'..'\u01b3'
+ | '\u01b5'..'\u01b7'
+ | '\u01b8'..'\u01bc'
+ | '\u01c4'..'\u01cd'
+ | '\u01cf'..'\u01db'
+ | '\u01de'..'\u01ee'
+ | '\u01f1'..'\u01f4'
+ | '\u01f6'..'\u01f8'
+ | '\u01fa'..'\u0232'
+ | '\u023a'..'\u023b'
+ | '\u023d'..'\u023e'
+ | '\u0241'..'\u0243'
+ | '\u0244'..'\u0246'
+ | '\u0248'..'\u024e'
+ | '\u0370'..'\u0372'
+ | '\u0376'..'\u037f'
+ | '\u0386'..'\u0388'
+ | '\u0389'..'\u038a'
+ | '\u038c'..'\u038e'
+ | '\u038f'..'\u0391'
+ | '\u0392'..'\u03a1'
+ | '\u03a3'..'\u03ab'
+ | '\u03cf'..'\u03d2'
+ | '\u03d3'..'\u03d4'
+ | '\u03d8'..'\u03ee'
+ | '\u03f4'..'\u03f7'
+ | '\u03f9'..'\u03fa'
+ | '\u03fd'..'\u042f'
+ | '\u0460'..'\u0480'
+ | '\u048a'..'\u04c0'
+ | '\u04c1'..'\u04cd'
+ | '\u04d0'..'\u052e'
+ | '\u0531'..'\u0556'
+ | '\u10a0'..'\u10c5'
+ | '\u10c7'..'\u10cd'
+ | '\u1e00'..'\u1e94'
+ | '\u1e9e'..'\u1efe'
+ | '\u1f08'..'\u1f0f'
+ | '\u1f18'..'\u1f1d'
+ | '\u1f28'..'\u1f2f'
+ | '\u1f38'..'\u1f3f'
+ | '\u1f48'..'\u1f4d'
+ | '\u1f59'..'\u1f5f'
+ | '\u1f68'..'\u1f6f'
+ | '\u1fb8'..'\u1fbb'
+ | '\u1fc8'..'\u1fcb'
+ | '\u1fd8'..'\u1fdb'
+ | '\u1fe8'..'\u1fec'
+ | '\u1ff8'..'\u1ffb'
+ | '\u2102'..'\u2107'
+ | '\u210b'..'\u210d'
+ | '\u2110'..'\u2112'
+ | '\u2115'..'\u2119'
+ | '\u211a'..'\u211d'
+ | '\u2124'..'\u212a'
+ | '\u212b'..'\u212d'
+ | '\u2130'..'\u2133'
+ | '\u213e'..'\u213f'
+ | '\u2145'..'\u2183'
+ | '\u2c00'..'\u2c2e'
+ | '\u2c60'..'\u2c62'
+ | '\u2c63'..'\u2c64'
+ | '\u2c67'..'\u2c6d'
+ | '\u2c6e'..'\u2c70'
+ | '\u2c72'..'\u2c75'
+ | '\u2c7e'..'\u2c80'
+ | '\u2c82'..'\u2ce2'
+ | '\u2ceb'..'\u2ced'
+ | '\u2cf2'..'\ua640'
+ | '\ua642'..'\ua66c'
+ | '\ua680'..'\ua69a'
+ | '\ua722'..'\ua72e'
+ | '\ua732'..'\ua76e'
+ | '\ua779'..'\ua77d'
+ | '\ua77e'..'\ua786'
+ | '\ua78b'..'\ua78d'
+ | '\ua790'..'\ua792'
+ | '\ua796'..'\ua7aa'
+ | '\ua7ab'..'\ua7ad'
+ | '\ua7b0'..'\ua7b1'
+ | '\uff21'..'\uff3a'
+ ;
+
+fragment UnicodeClass_LL
+ : '\u0061'..'\u007A'
+ | '\u00b5'..'\u00df'
+ | '\u00e0'..'\u00f6'
+ | '\u00f8'..'\u00ff'
+ | '\u0101'..'\u0137'
+ | '\u0138'..'\u0148'
+ | '\u0149'..'\u0177'
+ | '\u017a'..'\u017e'
+ | '\u017f'..'\u0180'
+ | '\u0183'..'\u0185'
+ | '\u0188'..'\u018c'
+ | '\u018d'..'\u0192'
+ | '\u0195'..'\u0199'
+ | '\u019a'..'\u019b'
+ | '\u019e'..'\u01a1'
+ | '\u01a3'..'\u01a5'
+ | '\u01a8'..'\u01aa'
+ | '\u01ab'..'\u01ad'
+ | '\u01b0'..'\u01b4'
+ | '\u01b6'..'\u01b9'
+ | '\u01ba'..'\u01bd'
+ | '\u01be'..'\u01bf'
+ | '\u01c6'..'\u01cc'
+ | '\u01ce'..'\u01dc'
+ | '\u01dd'..'\u01ef'
+ | '\u01f0'..'\u01f3'
+ | '\u01f5'..'\u01f9'
+ | '\u01fb'..'\u0233'
+ | '\u0234'..'\u0239'
+ | '\u023c'..'\u023f'
+ | '\u0240'..'\u0242'
+ | '\u0247'..'\u024f'
+ | '\u0250'..'\u0293'
+ | '\u0295'..'\u02af'
+ | '\u0371'..'\u0373'
+ | '\u0377'..'\u037b'
+ | '\u037c'..'\u037d'
+ | '\u0390'..'\u03ac'
+ | '\u03ad'..'\u03ce'
+ | '\u03d0'..'\u03d1'
+ | '\u03d5'..'\u03d7'
+ | '\u03d9'..'\u03ef'
+ | '\u03f0'..'\u03f3'
+ | '\u03f5'..'\u03fb'
+ | '\u03fc'..'\u0430'
+ | '\u0431'..'\u045f'
+ | '\u0461'..'\u0481'
+ | '\u048b'..'\u04bf'
+ | '\u04c2'..'\u04ce'
+ | '\u04cf'..'\u052f'
+ | '\u0561'..'\u0587'
+ | '\u1d00'..'\u1d2b'
+ | '\u1d6b'..'\u1d77'
+ | '\u1d79'..'\u1d9a'
+ | '\u1e01'..'\u1e95'
+ | '\u1e96'..'\u1e9d'
+ | '\u1e9f'..'\u1eff'
+ | '\u1f00'..'\u1f07'
+ | '\u1f10'..'\u1f15'
+ | '\u1f20'..'\u1f27'
+ | '\u1f30'..'\u1f37'
+ | '\u1f40'..'\u1f45'
+ | '\u1f50'..'\u1f57'
+ | '\u1f60'..'\u1f67'
+ | '\u1f70'..'\u1f7d'
+ | '\u1f80'..'\u1f87'
+ | '\u1f90'..'\u1f97'
+ | '\u1fa0'..'\u1fa7'
+ | '\u1fb0'..'\u1fb4'
+ | '\u1fb6'..'\u1fb7'
+ | '\u1fbe'..'\u1fc2'
+ | '\u1fc3'..'\u1fc4'
+ | '\u1fc6'..'\u1fc7'
+ | '\u1fd0'..'\u1fd3'
+ | '\u1fd6'..'\u1fd7'
+ | '\u1fe0'..'\u1fe7'
+ | '\u1ff2'..'\u1ff4'
+ | '\u1ff6'..'\u1ff7'
+ | '\u210a'..'\u210e'
+ | '\u210f'..'\u2113'
+ | '\u212f'..'\u2139'
+ | '\u213c'..'\u213d'
+ | '\u2146'..'\u2149'
+ | '\u214e'..'\u2184'
+ | '\u2c30'..'\u2c5e'
+ | '\u2c61'..'\u2c65'
+ | '\u2c66'..'\u2c6c'
+ | '\u2c71'..'\u2c73'
+ | '\u2c74'..'\u2c76'
+ | '\u2c77'..'\u2c7b'
+ | '\u2c81'..'\u2ce3'
+ | '\u2ce4'..'\u2cec'
+ | '\u2cee'..'\u2cf3'
+ | '\u2d00'..'\u2d25'
+ | '\u2d27'..'\u2d2d'
+ | '\ua641'..'\ua66d'
+ | '\ua681'..'\ua69b'
+ | '\ua723'..'\ua72f'
+ | '\ua730'..'\ua731'
+ | '\ua733'..'\ua771'
+ | '\ua772'..'\ua778'
+ | '\ua77a'..'\ua77c'
+ | '\ua77f'..'\ua787'
+ | '\ua78c'..'\ua78e'
+ | '\ua791'..'\ua793'
+ | '\ua794'..'\ua795'
+ | '\ua797'..'\ua7a9'
+ | '\ua7fa'..'\uab30'
+ | '\uab31'..'\uab5a'
+ | '\uab64'..'\uab65'
+ | '\ufb00'..'\ufb06'
+ | '\ufb13'..'\ufb17'
+ | '\uff41'..'\uff5a'
+ ;
+
+fragment UnicodeClass_LT
+ : '\u01c5'..'\u01cb'
+ | '\u01f2'..'\u1f88'
+ | '\u1f89'..'\u1f8f'
+ | '\u1f98'..'\u1f9f'
+ | '\u1fa8'..'\u1faf'
+ | '\u1fbc'..'\u1fcc'
+ | '\u1ffc'..'\u1ffc'
+ ;
+
+fragment UnicodeClass_LM
+ : '\u02b0'..'\u02c1'
+ | '\u02c6'..'\u02d1'
+ | '\u02e0'..'\u02e4'
+ | '\u02ec'..'\u02ee'
+ | '\u0374'..'\u037a'
+ | '\u0559'..'\u0640'
+ | '\u06e5'..'\u06e6'
+ | '\u07f4'..'\u07f5'
+ | '\u07fa'..'\u081a'
+ | '\u0824'..'\u0828'
+ | '\u0971'..'\u0e46'
+ | '\u0ec6'..'\u10fc'
+ | '\u17d7'..'\u1843'
+ | '\u1aa7'..'\u1c78'
+ | '\u1c79'..'\u1c7d'
+ | '\u1d2c'..'\u1d6a'
+ | '\u1d78'..'\u1d9b'
+ | '\u1d9c'..'\u1dbf'
+ | '\u2071'..'\u207f'
+ | '\u2090'..'\u209c'
+ | '\u2c7c'..'\u2c7d'
+ | '\u2d6f'..'\u2e2f'
+ | '\u3005'..'\u3031'
+ | '\u3032'..'\u3035'
+ | '\u303b'..'\u309d'
+ | '\u309e'..'\u30fc'
+ | '\u30fd'..'\u30fe'
+ | '\ua015'..'\ua4f8'
+ | '\ua4f9'..'\ua4fd'
+ | '\ua60c'..'\ua67f'
+ | '\ua69c'..'\ua69d'
+ | '\ua717'..'\ua71f'
+ | '\ua770'..'\ua788'
+ | '\ua7f8'..'\ua7f9'
+ | '\ua9cf'..'\ua9e6'
+ | '\uaa70'..'\uaadd'
+ | '\uaaf3'..'\uaaf4'
+ | '\uab5c'..'\uab5f'
+ | '\uff70'..'\uff9e'
+ | '\uff9f'..'\uff9f'
+ ;
+
+fragment UnicodeClass_LO
+ : '\u00aa'..'\u00ba'
+ | '\u01bb'..'\u01c0'
+ | '\u01c1'..'\u01c3'
+ | '\u0294'..'\u05d0'
+ | '\u05d1'..'\u05ea'
+ | '\u05f0'..'\u05f2'
+ | '\u0620'..'\u063f'
+ | '\u0641'..'\u064a'
+ | '\u066e'..'\u066f'
+ | '\u0671'..'\u06d3'
+ | '\u06d5'..'\u06ee'
+ | '\u06ef'..'\u06fa'
+ | '\u06fb'..'\u06fc'
+ | '\u06ff'..'\u0710'
+ | '\u0712'..'\u072f'
+ | '\u074d'..'\u07a5'
+ | '\u07b1'..'\u07ca'
+ | '\u07cb'..'\u07ea'
+ | '\u0800'..'\u0815'
+ | '\u0840'..'\u0858'
+ | '\u08a0'..'\u08b2'
+ | '\u0904'..'\u0939'
+ | '\u093d'..'\u0950'
+ | '\u0958'..'\u0961'
+ | '\u0972'..'\u0980'
+ | '\u0985'..'\u098c'
+ | '\u098f'..'\u0990'
+ | '\u0993'..'\u09a8'
+ | '\u09aa'..'\u09b0'
+ | '\u09b2'..'\u09b6'
+ | '\u09b7'..'\u09b9'
+ | '\u09bd'..'\u09ce'
+ | '\u09dc'..'\u09dd'
+ | '\u09df'..'\u09e1'
+ | '\u09f0'..'\u09f1'
+ | '\u0a05'..'\u0a0a'
+ | '\u0a0f'..'\u0a10'
+ | '\u0a13'..'\u0a28'
+ | '\u0a2a'..'\u0a30'
+ | '\u0a32'..'\u0a33'
+ | '\u0a35'..'\u0a36'
+ | '\u0a38'..'\u0a39'
+ | '\u0a59'..'\u0a5c'
+ | '\u0a5e'..'\u0a72'
+ | '\u0a73'..'\u0a74'
+ | '\u0a85'..'\u0a8d'
+ | '\u0a8f'..'\u0a91'
+ | '\u0a93'..'\u0aa8'
+ | '\u0aaa'..'\u0ab0'
+ | '\u0ab2'..'\u0ab3'
+ | '\u0ab5'..'\u0ab9'
+ | '\u0abd'..'\u0ad0'
+ | '\u0ae0'..'\u0ae1'
+ | '\u0b05'..'\u0b0c'
+ | '\u0b0f'..'\u0b10'
+ | '\u0b13'..'\u0b28'
+ | '\u0b2a'..'\u0b30'
+ | '\u0b32'..'\u0b33'
+ | '\u0b35'..'\u0b39'
+ | '\u0b3d'..'\u0b5c'
+ | '\u0b5d'..'\u0b5f'
+ | '\u0b60'..'\u0b61'
+ | '\u0b71'..'\u0b83'
+ | '\u0b85'..'\u0b8a'
+ | '\u0b8e'..'\u0b90'
+ | '\u0b92'..'\u0b95'
+ | '\u0b99'..'\u0b9a'
+ | '\u0b9c'..'\u0b9e'
+ | '\u0b9f'..'\u0ba3'
+ | '\u0ba4'..'\u0ba8'
+ | '\u0ba9'..'\u0baa'
+ | '\u0bae'..'\u0bb9'
+ | '\u0bd0'..'\u0c05'
+ | '\u0c06'..'\u0c0c'
+ | '\u0c0e'..'\u0c10'
+ | '\u0c12'..'\u0c28'
+ | '\u0c2a'..'\u0c39'
+ | '\u0c3d'..'\u0c58'
+ | '\u0c59'..'\u0c60'
+ | '\u0c61'..'\u0c85'
+ | '\u0c86'..'\u0c8c'
+ | '\u0c8e'..'\u0c90'
+ | '\u0c92'..'\u0ca8'
+ | '\u0caa'..'\u0cb3'
+ | '\u0cb5'..'\u0cb9'
+ | '\u0cbd'..'\u0cde'
+ | '\u0ce0'..'\u0ce1'
+ | '\u0cf1'..'\u0cf2'
+ | '\u0d05'..'\u0d0c'
+ | '\u0d0e'..'\u0d10'
+ | '\u0d12'..'\u0d3a'
+ | '\u0d3d'..'\u0d4e'
+ | '\u0d60'..'\u0d61'
+ | '\u0d7a'..'\u0d7f'
+ | '\u0d85'..'\u0d96'
+ | '\u0d9a'..'\u0db1'
+ | '\u0db3'..'\u0dbb'
+ | '\u0dbd'..'\u0dc0'
+ | '\u0dc1'..'\u0dc6'
+ | '\u0e01'..'\u0e30'
+ | '\u0e32'..'\u0e33'
+ | '\u0e40'..'\u0e45'
+ | '\u0e81'..'\u0e82'
+ | '\u0e84'..'\u0e87'
+ | '\u0e88'..'\u0e8a'
+ | '\u0e8d'..'\u0e94'
+ | '\u0e95'..'\u0e97'
+ | '\u0e99'..'\u0e9f'
+ | '\u0ea1'..'\u0ea3'
+ | '\u0ea5'..'\u0ea7'
+ | '\u0eaa'..'\u0eab'
+ | '\u0ead'..'\u0eb0'
+ | '\u0eb2'..'\u0eb3'
+ | '\u0ebd'..'\u0ec0'
+ | '\u0ec1'..'\u0ec4'
+ | '\u0edc'..'\u0edf'
+ | '\u0f00'..'\u0f40'
+ | '\u0f41'..'\u0f47'
+ | '\u0f49'..'\u0f6c'
+ | '\u0f88'..'\u0f8c'
+ | '\u1000'..'\u102a'
+ | '\u103f'..'\u1050'
+ | '\u1051'..'\u1055'
+ | '\u105a'..'\u105d'
+ | '\u1061'..'\u1065'
+ | '\u1066'..'\u106e'
+ | '\u106f'..'\u1070'
+ | '\u1075'..'\u1081'
+ | '\u108e'..'\u10d0'
+ | '\u10d1'..'\u10fa'
+ | '\u10fd'..'\u1248'
+ | '\u124a'..'\u124d'
+ | '\u1250'..'\u1256'
+ | '\u1258'..'\u125a'
+ | '\u125b'..'\u125d'
+ | '\u1260'..'\u1288'
+ | '\u128a'..'\u128d'
+ | '\u1290'..'\u12b0'
+ | '\u12b2'..'\u12b5'
+ | '\u12b8'..'\u12be'
+ | '\u12c0'..'\u12c2'
+ | '\u12c3'..'\u12c5'
+ | '\u12c8'..'\u12d6'
+ | '\u12d8'..'\u1310'
+ | '\u1312'..'\u1315'
+ | '\u1318'..'\u135a'
+ | '\u1380'..'\u138f'
+ | '\u13a0'..'\u13f4'
+ | '\u1401'..'\u166c'
+ | '\u166f'..'\u167f'
+ | '\u1681'..'\u169a'
+ | '\u16a0'..'\u16ea'
+ | '\u16f1'..'\u16f8'
+ | '\u1700'..'\u170c'
+ | '\u170e'..'\u1711'
+ | '\u1720'..'\u1731'
+ | '\u1740'..'\u1751'
+ | '\u1760'..'\u176c'
+ | '\u176e'..'\u1770'
+ | '\u1780'..'\u17b3'
+ | '\u17dc'..'\u1820'
+ | '\u1821'..'\u1842'
+ | '\u1844'..'\u1877'
+ | '\u1880'..'\u18a8'
+ | '\u18aa'..'\u18b0'
+ | '\u18b1'..'\u18f5'
+ | '\u1900'..'\u191e'
+ | '\u1950'..'\u196d'
+ | '\u1970'..'\u1974'
+ | '\u1980'..'\u19ab'
+ | '\u19c1'..'\u19c7'
+ | '\u1a00'..'\u1a16'
+ | '\u1a20'..'\u1a54'
+ | '\u1b05'..'\u1b33'
+ | '\u1b45'..'\u1b4b'
+ | '\u1b83'..'\u1ba0'
+ | '\u1bae'..'\u1baf'
+ | '\u1bba'..'\u1be5'
+ | '\u1c00'..'\u1c23'
+ | '\u1c4d'..'\u1c4f'
+ | '\u1c5a'..'\u1c77'
+ | '\u1ce9'..'\u1cec'
+ | '\u1cee'..'\u1cf1'
+ | '\u1cf5'..'\u1cf6'
+ | '\u2135'..'\u2138'
+ | '\u2d30'..'\u2d67'
+ | '\u2d80'..'\u2d96'
+ | '\u2da0'..'\u2da6'
+ | '\u2da8'..'\u2dae'
+ | '\u2db0'..'\u2db6'
+ | '\u2db8'..'\u2dbe'
+ | '\u2dc0'..'\u2dc6'
+ | '\u2dc8'..'\u2dce'
+ | '\u2dd0'..'\u2dd6'
+ | '\u2dd8'..'\u2dde'
+ | '\u3006'..'\u303c'
+ | '\u3041'..'\u3096'
+ | '\u309f'..'\u30a1'
+ | '\u30a2'..'\u30fa'
+ | '\u30ff'..'\u3105'
+ | '\u3106'..'\u312d'
+ | '\u3131'..'\u318e'
+ | '\u31a0'..'\u31ba'
+ | '\u31f0'..'\u31ff'
+ | '\u3400'..'\u4db5'
+ | '\u4e00'..'\u9fcc'
+ | '\ua000'..'\ua014'
+ | '\ua016'..'\ua48c'
+ | '\ua4d0'..'\ua4f7'
+ | '\ua500'..'\ua60b'
+ | '\ua610'..'\ua61f'
+ | '\ua62a'..'\ua62b'
+ | '\ua66e'..'\ua6a0'
+ | '\ua6a1'..'\ua6e5'
+ | '\ua7f7'..'\ua7fb'
+ | '\ua7fc'..'\ua801'
+ | '\ua803'..'\ua805'
+ | '\ua807'..'\ua80a'
+ | '\ua80c'..'\ua822'
+ | '\ua840'..'\ua873'
+ | '\ua882'..'\ua8b3'
+ | '\ua8f2'..'\ua8f7'
+ | '\ua8fb'..'\ua90a'
+ | '\ua90b'..'\ua925'
+ | '\ua930'..'\ua946'
+ | '\ua960'..'\ua97c'
+ | '\ua984'..'\ua9b2'
+ | '\ua9e0'..'\ua9e4'
+ | '\ua9e7'..'\ua9ef'
+ | '\ua9fa'..'\ua9fe'
+ | '\uaa00'..'\uaa28'
+ | '\uaa40'..'\uaa42'
+ | '\uaa44'..'\uaa4b'
+ | '\uaa60'..'\uaa6f'
+ | '\uaa71'..'\uaa76'
+ | '\uaa7a'..'\uaa7e'
+ | '\uaa7f'..'\uaaaf'
+ | '\uaab1'..'\uaab5'
+ | '\uaab6'..'\uaab9'
+ | '\uaaba'..'\uaabd'
+ | '\uaac0'..'\uaac2'
+ | '\uaadb'..'\uaadc'
+ | '\uaae0'..'\uaaea'
+ | '\uaaf2'..'\uab01'
+ | '\uab02'..'\uab06'
+ | '\uab09'..'\uab0e'
+ | '\uab11'..'\uab16'
+ | '\uab20'..'\uab26'
+ | '\uab28'..'\uab2e'
+ | '\uabc0'..'\uabe2'
+ | '\uac00'..'\ud7a3'
+ | '\ud7b0'..'\ud7c6'
+ | '\ud7cb'..'\ud7fb'
+ | '\uf900'..'\ufa6d'
+ | '\ufa70'..'\ufad9'
+ | '\ufb1d'..'\ufb1f'
+ | '\ufb20'..'\ufb28'
+ | '\ufb2a'..'\ufb36'
+ | '\ufb38'..'\ufb3c'
+ | '\ufb3e'..'\ufb40'
+ | '\ufb41'..'\ufb43'
+ | '\ufb44'..'\ufb46'
+ | '\ufb47'..'\ufbb1'
+ | '\ufbd3'..'\ufd3d'
+ | '\ufd50'..'\ufd8f'
+ | '\ufd92'..'\ufdc7'
+ | '\ufdf0'..'\ufdfb'
+ | '\ufe70'..'\ufe74'
+ | '\ufe76'..'\ufefc'
+ | '\uff66'..'\uff6f'
+ | '\uff71'..'\uff9d'
+ | '\uffa0'..'\uffbe'
+ | '\uffc2'..'\uffc7'
+ | '\uffca'..'\uffcf'
+ | '\uffd2'..'\uffd7'
+ | '\uffda'..'\uffdc'
+ ;
+
+fragment UnicodeDigit // UnicodeClass_ND
+ : '\u0030'..'\u0039'
+ | '\u0660'..'\u0669'
+ | '\u06f0'..'\u06f9'
+ | '\u07c0'..'\u07c9'
+ | '\u0966'..'\u096f'
+ | '\u09e6'..'\u09ef'
+ | '\u0a66'..'\u0a6f'
+ | '\u0ae6'..'\u0aef'
+ | '\u0b66'..'\u0b6f'
+ | '\u0be6'..'\u0bef'
+ | '\u0c66'..'\u0c6f'
+ | '\u0ce6'..'\u0cef'
+ | '\u0d66'..'\u0d6f'
+ | '\u0de6'..'\u0def'
+ | '\u0e50'..'\u0e59'
+ | '\u0ed0'..'\u0ed9'
+ | '\u0f20'..'\u0f29'
+ | '\u1040'..'\u1049'
+ | '\u1090'..'\u1099'
+ | '\u17e0'..'\u17e9'
+ | '\u1810'..'\u1819'
+ | '\u1946'..'\u194f'
+ | '\u19d0'..'\u19d9'
+ | '\u1a80'..'\u1a89'
+ | '\u1a90'..'\u1a99'
+ | '\u1b50'..'\u1b59'
+ | '\u1bb0'..'\u1bb9'
+ | '\u1c40'..'\u1c49'
+ | '\u1c50'..'\u1c59'
+ | '\ua620'..'\ua629'
+ | '\ua8d0'..'\ua8d9'
+ | '\ua900'..'\ua909'
+ | '\ua9d0'..'\ua9d9'
+ | '\ua9f0'..'\ua9f9'
+ | '\uaa50'..'\uaa59'
+ | '\uabf0'..'\uabf9'
+ | '\uff10'..'\uff19'
+ ;
+
\ No newline at end of file
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java
index edec46c074..ec2cd4facb 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java
@@ -70,14 +70,24 @@ public abstract class ANTLRAssistBehavior extends InputAssistBehavior {
}
}
}
+
+ List<InputAssist> assists = new ArrayList<>();
+ List<InputAssist> insertions = getInsertions(expectedRule.get()!=null?expectedRule.get():parseResult,
+ tokensBeforeCaret, input.substring(replaceStart.get(), caret).toLowerCase());
+
+ for (InputAssist insertion: insertions) {
+ String before = input.substring(replaceStart.get());
+ String after = input.substring(replaceEnd);
+ String newInput = before + insertion.getInput() + after;
+ int newCaret = caret - replaceStart.get() + insertion.getCaret();
+ assists.add(new InputAssist(newInput, newCaret));
+ }
- return getAssists(input, caret, expectedRule.get()!=null?expectedRule.get():parseResult,
- tokensBeforeCaret, replaceStart.get(), replaceEnd);
+ return assists;
}
- protected abstract List<InputAssist> getAssists(String input, int caret,
- ParserRuleContext ruleBeforeCaret, List<Token> tokensBeforeCaret,
- int replaceStart, int replaceEnd);
+ protected abstract List<InputAssist> getInsertions(ParserRuleContext ruleBeforeCaret,
+ List<Token> tokensBeforeCaret, String textToMatch);
@Override
protected List<InputError> getErrors(String input) {
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Lexer.g4 b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Lexer.g4
new file mode 100644
index 0000000000..083daa18f3
--- /dev/null
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Lexer.g4
@@ -0,0 +1,343 @@
+/*
+ * [The "BSD license"]
+ * Copyright (c) 2012-2015 Terence Parr
+ * Copyright (c) 2012-2015 Sam Harwell
+ * Copyright (c) 2015 Gerald Rosenberg
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * A grammar for ANTLR v4 implemented using v4 syntax
+ *
+ * Modified 2015.06.16 gbr
+ * -- update for compatibility with Antlr v4.5
+ */
+
+lexer grammar ANTLRv4Lexer;
+
+options {
+ superClass = LexerAdaptor ;
+}
+
+import LexBasic; // Standard set of fragments
+
+tokens {
+ TOKEN_REF,
+ RULE_REF,
+ LEXER_CHAR_SET
+}
+
+channels {
+ OFF_CHANNEL // non-default channel for whitespace and comments
+}
+
+
+// ======================================================
+// Lexer specification
+//
+
+// -------------------------
+// Comments
+
+DOC_COMMENT
+ : DocComment
+ ;
+
+BLOCK_COMMENT
+ : BlockComment -> channel(OFF_CHANNEL)
+ ;
+
+LINE_COMMENT
+ : LineComment -> channel(OFF_CHANNEL)
+ ;
+
+
+// -------------------------
+// Integer
+//
+
+INT : DecimalNumeral
+ ;
+
+
+// -------------------------
+// Literal string
+//
+// ANTLR makes no distinction between a single character literal and a
+// multi-character string. All literals are single quote delimited and
+// may contain unicode escape sequences of the form \uxxxx, where x
+// is a valid hexadecimal number (per Unicode standard).
+
+STRING_LITERAL
+ : SQuoteLiteral
+ ;
+
+UNTERMINATED_STRING_LITERAL
+ : USQuoteLiteral
+ ;
+
+
+// -------------------------
+// Arguments
+//
+// Certain argument lists, such as those specifying call parameters
+// to a rule invocation, or input parameters to a rule specification
+// are contained within square brackets.
+
+BEGIN_ARGUMENT
+ : LBrack { handleBeginArgument(); }
+ ;
+
+
+// -------------------------
+// Actions
+
+BEGIN_ACTION
+ : LBrace -> pushMode(Action)
+ ;
+
+
+// -------------------------
+// Keywords
+//
+// Keywords may not be used as labels for rules or in any other context where
+// they would be ambiguous with the keyword vs some other identifier. OPTIONS,
+// TOKENS, & CHANNELS blocks are handled idiomatically in dedicated lexical modes.
+
+OPTIONS : 'options' -> pushMode(Options) ;
+TOKENS : 'tokens' -> pushMode(Tokens) ;
+CHANNELS : 'channels' -> pushMode(Channels) ;
+
+IMPORT : 'import' ;
+FRAGMENT : 'fragment' ;
+LEXER : 'lexer' ;
+PARSER : 'parser' ;
+GRAMMAR : 'grammar' ;
+PROTECTED : 'protected' ;
+PUBLIC : 'public' ;
+PRIVATE : 'private' ;
+RETURNS : 'returns' ;
+LOCALS : 'locals' ;
+THROWS : 'throws' ;
+CATCH : 'catch' ;
+FINALLY : 'finally' ;
+MODE : 'mode' ;
+
+
+// -------------------------
+// Punctuation
+
+COLON : Colon ;
+COLONCOLON : DColon ;
+COMMA : Comma ;
+SEMI : Semi ;
+LPAREN : LParen ;
+RPAREN : RParen ;
+LBRACE : LBrace ;
+RBRACE : RBrace ;
+RARROW : RArrow ;
+LT : Lt ;
+GT : Gt ;
+ASSIGN : Equal ;
+QUESTION : Question ;
+STAR : Star ;
+PLUS_ASSIGN : PlusAssign ;
+PLUS : Plus ;
+OR : Pipe ;
+DOLLAR : Dollar ;
+RANGE : Range ;
+DOT : Dot ;
+AT : At ;
+POUND : Pound ;
+NOT : Tilde ;
+
+
+// -------------------------
+// Identifiers - allows unicode rule/token names
+
+ID : Id
+ ;
+
+
+// -------------------------
+// Whitespace
+
+WS : ( Hws | Vws )+ -> channel(OFF_CHANNEL) ;
+
+
+// -------------------------
+// Illegal Characters
+//
+// This is an illegal character trap which is always the last rule in the
+// lexer specification. It matches a single character of any value and being
+// the last rule in the file will match when no other rule knows what to do
+// about the character. It is reported as an error but is not passed on to the
+// parser. This means that the parser to deal with the gramamr file anyway
+// but we will not try to analyse or code generate from a file with lexical
+// errors.
+//
+// Comment this rule out to allow the error to be propagated to the parser
+
+ERRCHAR
+ : . -> channel(HIDDEN)
+ ;
+
+
+// ======================================================
+// Lexer modes
+
+// -------------------------
+// Arguments
+
+mode Argument; // E.g., [int x, List<String> a[]]
+
+ NESTED_ARGUMENT : LBrack -> type(ARGUMENT_CONTENT), pushMode(Argument) ;
+
+ ARGUMENT_ESCAPE : EscAny -> type(ARGUMENT_CONTENT) ;
+
+ ARGUMENT_STRING_LITERAL : DQuoteLiteral -> type(ARGUMENT_CONTENT) ;
+ ARGUMENT_CHAR_LITERAL : SQuoteLiteral -> type(ARGUMENT_CONTENT) ;
+
+ END_ARGUMENT : RBrack { handleEndArgument(); } ;
+
+ // added this to return non-EOF token type here. EOF does something weird
+ UNTERMINATED_ARGUMENT : EOF -> popMode ;
+
+ ARGUMENT_CONTENT : . ;
+
+
+// -------------------------
+// Actions
+//
+// Many language targets use {} as block delimiters and so we
+// must recursively match {} delimited blocks to balance the
+// braces. Additionally, we must make some assumptions about
+// literal string representation in the target language. We assume
+// that they are delimited by ' or " and so consume these
+// in their own alts so as not to inadvertantly match {}.
+
+mode Action;
+
+ NESTED_ACTION : LBrace -> type(ACTION_CONTENT), pushMode(Action) ;
+
+ ACTION_ESCAPE : EscAny -> type(ACTION_CONTENT) ;
+
+ ACTION_STRING_LITERAL : DQuoteLiteral -> type(ACTION_CONTENT) ;
+ ACTION_CHAR_LITERAL : SQuoteLiteral -> type(ACTION_CONTENT) ;
+
+ ACTION_DOC_COMMENT : DocComment -> type(ACTION_CONTENT) ;
+ ACTION_BLOCK_COMMENT : BlockComment -> type(ACTION_CONTENT) ;
+ ACTION_LINE_COMMENT : LineComment -> type(ACTION_CONTENT) ;
+
+ END_ACTION : RBrace { handleEndAction(); } ;
+
+ UNTERMINATED_ACTION : EOF -> popMode ;
+
+ ACTION_CONTENT : . ;
+
+
+// -------------------------
+
+mode Options;
+
+ OPT_DOC_COMMENT : DocComment -> type(DOC_COMMENT), channel(OFF_CHANNEL) ;
+ OPT_BLOCK_COMMENT : BlockComment -> type(BLOCK_COMMENT), channel(OFF_CHANNEL) ;
+ OPT_LINE_COMMENT : LineComment -> type(LINE_COMMENT), channel(OFF_CHANNEL) ;
+
+ OPT_LBRACE : LBrace -> type(LBRACE) ;
+ OPT_RBRACE : RBrace -> type(RBRACE), popMode ;
+
+ OPT_ID : Id -> type(ID) ;
+ OPT_DOT : Dot -> type(DOT) ;
+ OPT_ASSIGN : Equal -> type(ASSIGN) ;
+ OPT_STRING_LITERAL : SQuoteLiteral -> type(STRING_LITERAL) ;
+ OPT_INT : Int -> type(INT) ;
+ OPT_STAR : Star -> type(STAR) ;
+ OPT_SEMI : Semi -> type(SEMI) ;
+
+ OPT_WS : ( Hws | Vws )+ -> type(WS), channel(OFF_CHANNEL) ;
+
+
+// -------------------------
+
+mode Tokens;
+
+ TOK_DOC_COMMENT : DocComment -> type(DOC_COMMENT), channel(OFF_CHANNEL) ;
+ TOK_BLOCK_COMMENT : BlockComment -> type(BLOCK_COMMENT), channel(OFF_CHANNEL) ;
+ TOK_LINE_COMMENT : LineComment -> type(LINE_COMMENT), channel(OFF_CHANNEL) ;
+
+ TOK_LBRACE : LBrace -> type(LBRACE) ;
+ TOK_RBRACE : RBrace -> type(RBRACE), popMode ;
+
+ TOK_ID : Id -> type(ID) ;
+ TOK_DOT : Dot -> type(DOT) ;
+ TOK_COMMA : Comma -> type(COMMA) ;
+
+ TOK_WS : ( Hws | Vws )+ -> type(WS), channel(OFF_CHANNEL) ;
+
+
+// -------------------------
+
+mode Channels; // currently same as Tokens mode; distinguished by keyword
+
+ CHN_DOC_COMMENT : DocComment -> type(DOC_COMMENT), channel(OFF_CHANNEL) ;
+ CHN_BLOCK_COMMENT : BlockComment -> type(BLOCK_COMMENT), channel(OFF_CHANNEL) ;
+ CHN_LINE_COMMENT : LineComment -> type(LINE_COMMENT), channel(OFF_CHANNEL) ;
+
+ CHN_LBRACE : LBrace -> type(LBRACE) ;
+ CHN_RBRACE : RBrace -> type(RBRACE), popMode ;
+
+ CHN_ID : Id -> type(ID) ;
+ CHN_DOT : Dot -> type(DOT) ;
+ CHN_COMMA : Comma -> type(COMMA) ;
+
+ CHN_WS : ( Hws | Vws )+ -> type(WS), channel(OFF_CHANNEL) ;
+
+
+// -------------------------
+
+mode LexerCharSet;
+
+ LEXER_CHAR_SET_BODY
+ : ( ~[\]\\]
+ | EscAny
+ )+ -> more
+ ;
+
+ LEXER_CHAR_SET
+ : RBrack -> popMode
+ ;
+
+ UNTERMINATED_CHAR_SET
+ : EOF -> popMode
+ ;
+
+
+// ------------------------------------------------------------------------------
+// Grammar specific Keywords, Punctuation, etc.
+
+fragment Id : NameStartChar NameChar* ;
+
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Parser.g4 b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Parser.g4
new file mode 100644
index 0000000000..6c9966f48f
--- /dev/null
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Parser.g4
@@ -0,0 +1,423 @@
+/*
+ * [The "BSD license"]
+ * Copyright (c) 2012-2014 Terence Parr
+ * Copyright (c) 2012-2014 Sam Harwell
+ * Copyright (c) 2015 Gerald Rosenberg
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* A grammar for ANTLR v4 written in ANTLR v4.
+ *
+ * Modified 2015.06.16 gbr
+ * -- update for compatibility with Antlr v4.5
+ * -- add mode for channels
+ * -- moved members to LexerAdaptor
+ * -- move fragments to imports
+ */
+
+parser grammar ANTLRv4Parser;
+
+options {
+ tokenVocab = ANTLRv4Lexer ;
+}
+
+// The main entry point for parsing a v4 grammar.
+grammarSpec
+ : DOC_COMMENT?
+ grammarType id SEMI
+ prequelConstruct*
+ rules
+ modeSpec*
+ EOF
+ ;
+
+grammarType
+ : ( LEXER GRAMMAR
+ | PARSER GRAMMAR
+ | GRAMMAR
+ )
+ ;
+
+// This is the list of all constructs that can be declared before
+// the set of rules that compose the grammar, and is invoked 0..n
+// times by the grammarPrequel rule.
+prequelConstruct
+ : optionsSpec
+ | delegateGrammars
+ | tokensSpec
+ | channelsSpec
+ | action
+ ;
+
+
+// ------------
+// Options - things that affect analysis and/or code generation
+
+optionsSpec
+ : OPTIONS LBRACE (option SEMI)* RBRACE
+ ;
+
+option
+ : id ASSIGN optionValue
+ ;
+
+optionValue
+ : id (DOT id)*
+ | STRING_LITERAL
+ | actionBlock // TODO: is this valid?
+ | INT
+ ;
+
+// ------------
+// Delegates
+
+delegateGrammars
+ : IMPORT delegateGrammar (COMMA delegateGrammar)* SEMI
+ ;
+
+delegateGrammar
+ : id ASSIGN id
+ | id
+ ;
+
+
+// ------------
+// Tokens & Channels
+
+tokensSpec
+ : TOKENS LBRACE idList? RBRACE
+ ;
+
+channelsSpec
+ : CHANNELS LBRACE idList? RBRACE
+ ;
+
+idList
+ : id ( COMMA id )* COMMA?
+ ;
+
+
+// Match stuff like @parser::members {int i;}
+action
+ : AT (actionScopeName COLONCOLON)? id actionBlock
+ ;
+
+// Scope names could collide with keywords; allow them as ids for action scopes
+actionScopeName
+ : id
+ | LEXER
+ | PARSER
+ ;
+
+actionBlock
+ : BEGIN_ACTION ACTION_CONTENT* END_ACTION
+ ;
+
+argActionBlock
+ : BEGIN_ARGUMENT ARGUMENT_CONTENT* END_ARGUMENT
+ ;
+
+modeSpec
+ : MODE id SEMI lexerRuleSpec*
+ ;
+
+rules
+ : ruleSpec*
+ ;
+
+ruleSpec
+ : parserRuleSpec
+ | lexerRuleSpec
+ ;
+
+parserRuleSpec
+ : DOC_COMMENT?
+ ruleModifiers? RULE_REF argActionBlock? ruleReturns? throwsSpec?
+ localsSpec?
+ rulePrequel*
+ COLON
+ ruleBlock
+ SEMI
+ exceptionGroup
+ ;
+
+exceptionGroup
+ : exceptionHandler* finallyClause?
+ ;
+
+exceptionHandler
+ : CATCH argActionBlock actionBlock
+ ;
+
+finallyClause
+ : FINALLY actionBlock
+ ;
+
+rulePrequel
+ : optionsSpec
+ | ruleAction
+ ;
+
+ruleReturns
+ : RETURNS argActionBlock
+ ;
+
+// --------------
+// Exception spec
+
+throwsSpec
+ : THROWS id (COMMA id)*
+ ;
+
+localsSpec
+ : LOCALS argActionBlock
+ ;
+
+/** Match stuff like @init {int i;} */
+ruleAction
+ : AT id actionBlock
+ ;
+
+ruleModifiers
+ : ruleModifier+
+ ;
+
+// An individual access modifier for a rule. The 'fragment' modifier
+// is an internal indication for lexer rules that they do not match
+// from the input but are like subroutines for other lexer rules to
+// reuse for certain lexical patterns. The other modifiers are passed
+// to the code generation templates and may be ignored by the template
+// if they are of no use in that language.
+ruleModifier
+ : PUBLIC
+ | PRIVATE
+ | PROTECTED
+ | FRAGMENT
+ ;
+
+ruleBlock
+ : ruleAltList
+ ;
+
+ruleAltList
+ : labeledAlt (OR labeledAlt)*
+ ;
+
+labeledAlt
+ : alternative (POUND id)?
+ ;
+
+// --------------------
+// Lexer rules
+
+lexerRuleSpec
+ : DOC_COMMENT? FRAGMENT?
+ TOKEN_REF COLON lexerRuleBlock SEMI
+ ;
+
+lexerRuleBlock
+ : lexerAltList
+ ;
+
+lexerAltList
+ : lexerAlt (OR lexerAlt)*
+ ;
+
+lexerAlt
+ : lexerElements lexerCommands?
+ | // explicitly allow empty alts
+ ;
+
+lexerElements
+ : lexerElement+
+ ;
+
+lexerElement
+ : labeledLexerElement ebnfSuffix?
+ | lexerAtom ebnfSuffix?
+ | lexerBlock ebnfSuffix?
+ | actionBlock QUESTION? // actions only allowed at end of outer alt actually,
+ ; // but preds can be anywhere
+
+labeledLexerElement
+ : id (ASSIGN|PLUS_ASSIGN)
+ ( lexerAtom
+ | block
+ )
+ ;
+
+lexerBlock
+ : LPAREN lexerAltList RPAREN
+ ;
+
+// E.g., channel(HIDDEN), skip, more, mode(INSIDE), push(INSIDE), pop
+lexerCommands
+ : RARROW lexerCommand (COMMA lexerCommand)*
+ ;
+
+lexerCommand
+ : lexerCommandName LPAREN lexerCommandExpr RPAREN
+ | lexerCommandName
+ ;
+
+lexerCommandName
+ : id
+ | MODE
+ ;
+
+lexerCommandExpr
+ : id
+ | INT
+ ;
+
+// --------------------
+// Rule Alts
+
+altList
+ : alternative (OR alternative)*
+ ;
+
+alternative
+ : elementOptions? element+
+ | // explicitly allow empty alts
+ ;
+
+element
+ : labeledElement
+ ( ebnfSuffix
+ |
+ )
+ | atom
+ ( ebnfSuffix
+ |
+ )
+ | ebnf
+ | actionBlock QUESTION? // SEMPRED is actionBlock followed by QUESTION
+ ;
+
+labeledElement
+ : id ( ASSIGN | PLUS_ASSIGN )
+ ( atom
+ | block
+ )
+ ;
+
+// --------------------
+// EBNF and blocks
+
+ebnf
+ : block blockSuffix?
+ ;
+
+blockSuffix
+ : ebnfSuffix // Standard EBNF
+ ;
+
+ebnfSuffix
+ : QUESTION QUESTION?
+ | STAR QUESTION?
+ | PLUS QUESTION?
+ ;
+
+lexerAtom
+ : range
+ | terminal
+ | RULE_REF
+ | notSet
+ | LEXER_CHAR_SET
+ | DOT elementOptions?
+ ;
+
+atom
+ : range // Range x..y - only valid in lexers
+ | terminal
+ | ruleref
+ | notSet
+ | DOT elementOptions?
+ ;
+
+// --------------------
+// Inverted element set
+
+notSet
+ : NOT setElement
+ | NOT blockSet
+ ;
+
+blockSet
+ : LPAREN setElement (OR setElement)* RPAREN
+ ;
+
+setElement
+ : TOKEN_REF elementOptions?
+ | STRING_LITERAL elementOptions?
+ | range
+ | LEXER_CHAR_SET
+ ;
+
+// -------------
+// Grammar Block
+
+block
+ : LPAREN
+ ( optionsSpec? ruleAction* COLON )?
+ altList
+ RPAREN
+ ;
+
+// ----------------
+// Parser rule ref
+
+ruleref
+ : RULE_REF argActionBlock? elementOptions?
+ ;
+
+// ---------------
+// Character Range
+
+range
+ : STRING_LITERAL RANGE STRING_LITERAL
+ ;
+
+terminal
+ : TOKEN_REF elementOptions?
+ | STRING_LITERAL elementOptions?
+ ;
+
+// Terminals may be adorned with certain options when
+// reference in the grammar: TOK<,,,>
+elementOptions
+ : LT elementOption (COMMA elementOption)* GT
+ ;
+
+elementOption
+ : id // default node option
+ | id ASSIGN (id | STRING_LITERAL) // option assignment
+ ;
+
+id : RULE_REF
+ | TOKEN_REF
+ ;
diff --git a/gitplex.product/src/test/java/gitplex/product/Test.java b/gitplex.product/src/test/java/gitplex/product/Test.java
index 101f6463ba..fdef3fabcb 100644
--- a/gitplex.product/src/test/java/gitplex/product/Test.java
+++ b/gitplex.product/src/test/java/gitplex/product/Test.java
@@ -3,16 +3,8 @@ package gitplex.product;
import java.io.IOException;
import org.antlr.v4.runtime.ANTLRInputStream;
-import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.CommonTokenStream;
-import org.antlr.v4.runtime.Parser;
-import org.antlr.v4.runtime.ParserRuleContext;
-import org.antlr.v4.runtime.RecognitionException;
-import org.antlr.v4.runtime.Recognizer;
-import org.antlr.v4.runtime.tree.ErrorNode;
-import org.antlr.v4.runtime.tree.ParseTreeListener;
-import org.antlr.v4.runtime.tree.ParseTreeWalker;
-import org.antlr.v4.runtime.tree.TerminalNode;
+import org.antlr.v4.runtime.tree.ParseTree;
import com.pmease.gitplex.web.page.repository.commit.CommitQueryLexer;
import com.pmease.gitplex.web.page.repository.commit.CommitQueryParser;
@@ -21,22 +13,11 @@ public class Test {
@org.junit.Test
public void test() throws IOException {
- CommitQueryLexer lexer = new CommitQueryLexer(new ANTLRInputStream("rule1"));
+ CommitQueryLexer lexer = new CommitQueryLexer(new ANTLRInputStream("branch()"));
final CommonTokenStream tokens = new CommonTokenStream(lexer);
CommitQueryParser parser = new CommitQueryParser(tokens);
- lexer.removeErrorListeners();
- parser.removeErrorListeners();
- parser.addErrorListener(new BaseErrorListener() {
-
- @Override
- public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
- int charPositionInLine, String msg, RecognitionException e) {
- Parser parser = (Parser) recognizer;
- System.out.println(parser.getRuleContext());
- }
-
- });
- parser.test();
+ ParseTree tree = parser.query();
+ System.out.println(tree);
}
}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/CommitQuery.g4 b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/CommitQuery.g4
index 9b710a3ade..e0939d53f2 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/CommitQuery.g4
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/CommitQuery.g4
@@ -24,14 +24,6 @@ path: PATH Value;
message: MESSAGE Value;
-test: rule1 rule2 rule3;
-
-rule1: 'rule1';
-
-rule2: 'rule2';
-
-rule3: 'rule3';
-
BRANCH: 'branch';
TAG: 'tag';
ID: 'id';
@@ -42,9 +34,11 @@ COMMITTER: 'committer';
AUTHOR: 'author';
PATH: 'path';
EXCLUDE: '^';
+LPAREN: '(';
+RPAREN: ')';
Range: '..' | '...';
-Value: '(' (ESCAPE|~[()\\])+? ')';
+Value: LPAREN (ESCAPE|~[()\\])+? RPAREN;
fragment
ESCAPE: '\\'[()\\];
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/QueryAssistBehavior.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/QueryAssistBehavior.java
index f7e810a252..54bd36494a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/QueryAssistBehavior.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/QueryAssistBehavior.java
@@ -28,10 +28,38 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {
}
@Override
- protected List<InputAssist> getAssists(String input, int caret, ParserRuleContext ruleBeforeCaret,
- List<Token> tokensBeforeCaret, int replaceStart, int replaceEnd) {
- System.out.println(replaceEnd);
- return new ArrayList<>();
+ protected List<InputAssist> getInsertions(ParserRuleContext ruleBeforeCaret,
+ List<Token> tokensBeforeCaret, String textToMatch) {
+ List<InputAssist> insertions = new ArrayList<>();
+
+ if (ruleBeforeCaret.getRuleIndex() == CommitQueryParser.RULE_query && ruleBeforeCaret.getStop() != null) {
+ // previous input is a valid query
+ suggestCriterias(insertions, textToMatch);
+ }
+
+ return insertions;
+ }
+
+ private void suggestCriteria(List<InputAssist> insertions, String criteriaName, String textToMatch) {
+ if (criteriaName.startsWith(textToMatch))
+ insertions.add(new InputAssist(criteriaName + "()", criteriaName.length()+1));
+ }
+
+ private void suggestRevisionCriterias(List<InputAssist> insertions, String textToMatch) {
+ suggestCriteria(insertions, "branch", textToMatch);
+ suggestCriteria(insertions, "tag", textToMatch);
+ suggestCriteria(insertions, "id", textToMatch);
+ }
+
+ private void suggestCriterias(List<InputAssist> insertions, String textToMatch) {
+ suggestRevisionCriterias(insertions, textToMatch);
+ suggestCriteria(insertions, "path", textToMatch);
+ suggestCriteria(insertions, "before", textToMatch);
+ suggestCriteria(insertions, "after", textToMatch);
+ suggestCriteria(insertions, "author", textToMatch);
+ suggestCriteria(insertions, "committer", textToMatch);
+ suggestCriteria(insertions, "message", textToMatch);
+
}
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html
index b47194918b..710b289248 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html
@@ -1,2 +1,6 @@
<wicket:extend>
+ <input class="value" value="&zwnj;"></input>
+ <script type="text/javascript">
+ console.log("$('.value').val()");
+ </script>
</wicket:extend>
\ No newline at end of file
diff --git a/parent.general/pom.xml b/parent.general/pom.xml
index 4a17fd592f..bcf2c345bc 100644
--- a/parent.general/pom.xml
+++ b/parent.general/pom.xml
@@ -241,6 +241,7 @@
</executions>
<configuration>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
+ <libDirectory>${basedir}/src/main/java</libDirectory>
</configuration>
</plugin>
<plugin>