mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix import path grammar and grammar testing details.
This commit is contained in:
parent
124db22f04
commit
6fdfd8b62b
@ -19,6 +19,7 @@ Compiler Features:
|
|||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
* Antlr Grammar: Fix parsing of import paths involving properly distinguishing between empty and non-empty string literals in general.
|
||||||
* AST Output: Fix ``kind`` field of ``ModifierInvocation`` for base constructor calls.
|
* AST Output: Fix ``kind`` field of ``ModifierInvocation`` for base constructor calls.
|
||||||
* SMTChecker: Fix false positive and false negative on ``push`` as LHS of a compound assignment.
|
* SMTChecker: Fix false positive and false negative on ``push`` as LHS of a compound assignment.
|
||||||
* SMTChecker: Fix false positive in contracts that cannot be deployed.
|
* SMTChecker: Fix false positive in contracts that cannot be deployed.
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
Language Grammar
|
Language Grammar
|
||||||
****************
|
****************
|
||||||
|
|
||||||
.. a4:autogrammar:: Solidity
|
.. a4:autogrammar:: SolidityParser
|
||||||
:only-reachable-from: Solidity.sourceUnit
|
:only-reachable-from: SolidityParser.sourceUnit
|
||||||
:undocumented:
|
:undocumented:
|
||||||
:cc-to-dash:
|
:cc-to-dash:
|
||||||
|
|
||||||
.. a4:autogrammar:: SolidityLexer
|
.. a4:autogrammar:: SolidityLexer
|
||||||
:only-reachable-from: Solidity.sourceUnit
|
:only-reachable-from: SolidityParser.sourceUnit
|
||||||
:fragments:
|
:fragments:
|
||||||
:cc-to-dash:
|
:cc-to-dash:
|
@ -155,15 +155,20 @@ Not: '!';
|
|||||||
BitNot: '~';
|
BitNot: '~';
|
||||||
Inc: '++';
|
Inc: '++';
|
||||||
Dec: '--';
|
Dec: '--';
|
||||||
|
//@doc:inline
|
||||||
|
DoubleQuote: '"';
|
||||||
|
//@doc:inline
|
||||||
|
SingleQuote: '\'';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single quoted string literal restricted to printable characters.
|
* A non-empty quoted string literal restricted to printable characters.
|
||||||
*/
|
|
||||||
StringLiteral: '"' DoubleQuotedStringCharacter* '"' | '\'' SingleQuotedStringCharacter* '\'';
|
|
||||||
/**
|
|
||||||
* A single non-empty quoted string literal.
|
|
||||||
*/
|
*/
|
||||||
NonEmptyStringLiteral: '"' DoubleQuotedStringCharacter+ '"' | '\'' SingleQuotedStringCharacter+ '\'';
|
NonEmptyStringLiteral: '"' DoubleQuotedStringCharacter+ '"' | '\'' SingleQuotedStringCharacter+ '\'';
|
||||||
|
/**
|
||||||
|
* An empty string literal
|
||||||
|
*/
|
||||||
|
EmptyStringLiteral: '"' '"' | '\'' '\'';
|
||||||
|
|
||||||
// Note that this will also be used for Yul string literals.
|
// Note that this will also be used for Yul string literals.
|
||||||
//@doc:inline
|
//@doc:inline
|
||||||
fragment DoubleQuotedStringCharacter: DoubleQuotedPrintable | EscapeSequence;
|
fragment DoubleQuotedStringCharacter: DoubleQuotedPrintable | EscapeSequence;
|
||||||
@ -200,6 +205,7 @@ fragment DoubleQuotedUnicodeStringCharacter: ~["\r\n\\] | EscapeSequence;
|
|||||||
//@doc:inline
|
//@doc:inline
|
||||||
fragment SingleQuotedUnicodeStringCharacter: ~['\r\n\\] | EscapeSequence;
|
fragment SingleQuotedUnicodeStringCharacter: ~['\r\n\\] | EscapeSequence;
|
||||||
|
|
||||||
|
// Note that this will also be used for Yul hex string literals.
|
||||||
/**
|
/**
|
||||||
* Hex strings need to consist of an even number of hex digits that may be grouped using underscores.
|
* Hex strings need to consist of an even number of hex digits that may be grouped using underscores.
|
||||||
*/
|
*/
|
||||||
@ -315,6 +321,7 @@ YulDecimalNumber: '0' | ([1-9] [0-9]*);
|
|||||||
YulStringLiteral:
|
YulStringLiteral:
|
||||||
'"' DoubleQuotedStringCharacter* '"'
|
'"' DoubleQuotedStringCharacter* '"'
|
||||||
| '\'' SingleQuotedStringCharacter* '\'';
|
| '\'' SingleQuotedStringCharacter* '\'';
|
||||||
|
//@doc:inline
|
||||||
YulHexStringLiteral: HexString;
|
YulHexStringLiteral: HexString;
|
||||||
|
|
||||||
YulWS: [ \t\r\n\u000C]+ -> skip ;
|
YulWS: [ \t\r\n\u000C]+ -> skip ;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Solidity is a statically typed, contract-oriented, high-level language for implementing smart contracts on the Ethereum platform.
|
* Solidity is a statically typed, contract-oriented, high-level language for implementing smart contracts on the Ethereum platform.
|
||||||
*/
|
*/
|
||||||
grammar Solidity;
|
parser grammar SolidityParser;
|
||||||
|
|
||||||
options { tokenVocab=SolidityLexer; }
|
options { tokenVocab=SolidityLexer; }
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ booleanLiteral: True | False;
|
|||||||
/**
|
/**
|
||||||
* A full string literal consists of either one or several consecutive quoted strings.
|
* A full string literal consists of either one or several consecutive quoted strings.
|
||||||
*/
|
*/
|
||||||
stringLiteral: StringLiteral+;
|
stringLiteral: (NonEmptyStringLiteral | EmptyStringLiteral)+;
|
||||||
/**
|
/**
|
||||||
* A full hex string literal that consists of either one or several consecutive hex strings.
|
* A full hex string literal that consists of either one or several consecutive hex strings.
|
||||||
*/
|
*/
|
@ -39,19 +39,15 @@ prepare_workdir()
|
|||||||
prepare_workdir
|
prepare_workdir
|
||||||
download_antlr4
|
download_antlr4
|
||||||
|
|
||||||
if [[ ! -f "${WORKDIR}/target/SolidityParser.class" ]] || \
|
echo "Creating parser"
|
||||||
[ "${GRAMMAR_FILE}" -nt "${WORKDIR}/target/SolidityParser.class" ]
|
(
|
||||||
then
|
cd "${ROOT_DIR}"/docs/grammar
|
||||||
echo "Creating parser"
|
# Create lexer/parser from grammar
|
||||||
(
|
java -jar "${ANTLR_JAR}" SolidityParser.g4 SolidityLexer.g4 -o "${WORKDIR}/src/"
|
||||||
cd "${ROOT_DIR}"/docs/grammar
|
|
||||||
# Create lexer/parser from grammar
|
|
||||||
java -jar "${ANTLR_JAR}" Solidity.g4 SolidityLexer.g4 -o "${WORKDIR}/src/"
|
|
||||||
|
|
||||||
# Compile lexer/parser sources
|
# Compile lexer/parser sources
|
||||||
javac -classpath "${ANTLR_JAR}" "${WORKDIR}/src/"*.java -d "${WORKDIR}/target/"
|
javac -classpath "${ANTLR_JAR}" "${WORKDIR}/src/"*.java -d "${WORKDIR}/target/"
|
||||||
)
|
)
|
||||||
fi
|
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
failed_count=0
|
failed_count=0
|
||||||
@ -67,11 +63,11 @@ test_file()
|
|||||||
local output
|
local output
|
||||||
if [[ "${solOrYul}" == "sol" ]]; then
|
if [[ "${solOrYul}" == "sol" ]]; then
|
||||||
output=$(
|
output=$(
|
||||||
java \
|
grep -v "^==== ExternalSource:" "${SOL_FILE}" | java \
|
||||||
-classpath "${ANTLR_JAR}:${WORKDIR}/target/" \
|
-classpath "${ANTLR_JAR}:${WORKDIR}/target/" \
|
||||||
"org.antlr.v4.gui.TestRig" \
|
"org.antlr.v4.gui.TestRig" \
|
||||||
Solidity \
|
Solidity \
|
||||||
sourceUnit <"${SOL_FILE}" 2>&1
|
sourceUnit 2>&1
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
output=$(
|
output=$(
|
||||||
@ -113,7 +109,7 @@ while IFS='' read -r line
|
|||||||
do
|
do
|
||||||
SOL_FILES+=("$line")
|
SOL_FILES+=("$line")
|
||||||
done < <(
|
done < <(
|
||||||
grep -riL -E \
|
grep --include "*.sol" -riL -E \
|
||||||
"^\/\/ (Syntax|Type|Declaration)Error|^\/\/ ParserError (1684|2837|3716|3997|5333|6275|6281|6933|7319)|^==== Source:" \
|
"^\/\/ (Syntax|Type|Declaration)Error|^\/\/ ParserError (1684|2837|3716|3997|5333|6275|6281|6933|7319)|^==== Source:" \
|
||||||
"${ROOT_DIR}/test/libsolidity/syntaxTests" \
|
"${ROOT_DIR}/test/libsolidity/syntaxTests" \
|
||||||
"${ROOT_DIR}/test/libsolidity/semanticTests" |
|
"${ROOT_DIR}/test/libsolidity/semanticTests" |
|
||||||
|
Loading…
Reference in New Issue
Block a user