Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-rc] Add integer expressions parsing ability. [7/8]
This allows the ints to be written as integer expressions evaluating to unsigned 16-bit/32-bit integers. All the expressions may use the following operators: + - & | ~, and parentheses. Minus token - can be also unary. There is no precedence of the operators other than the unary operators binding stronger than their binary counterparts. Differential Revision: https://reviews.llvm.org/D37022 llvm-svn: 314477
- Loading branch information
Showing
14 changed files
with
196 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LANGUAGE 0, & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LANGUAGE 3||0, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LANGUAGE 3+-+3, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LANGUAGE 1~1, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LANGUAGE (1+2, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LANGUAGE 1+2)+3+4(, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LANGUAGE (1+2+3)), 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
LANGUAGE 3 + 2, 3 - 2 | ||
LANGUAGE 3 | 2, 3 & 2 | ||
LANGUAGE -3, ~3 | ||
LANGUAGE 1|1&0, 0&0|1 | ||
LANGUAGE 3+4-5, 3-4+5 | ||
LANGUAGE 1+2|3, 3|1+2 | ||
LANGUAGE 6&~5, 6&-8 | ||
LANGUAGE -1, --1 | ||
LANGUAGE ----1, -----1 | ||
LANGUAGE ~1, ~~1 | ||
LANGUAGE ~~~~1, ~~~~~1 | ||
LANGUAGE 5-(1+2), 1|(1&0) | ||
LANGUAGE ~(3-7), -(3+~7) | ||
LANGUAGE 0, (1+3)|(2+11) | ||
LANGUAGE (((((((5))))))), (((((((7))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
; RUN: llvm-rc /V %p/Inputs/parser-expr.rc | FileCheck %s | ||
|
||
; CHECK: Language: 5, Sublanguage: 1 | ||
; CHECK-NEXT: Language: 3, Sublanguage: 2 | ||
; CHECK-NEXT: Language: 4294967293, Sublanguage: 4294967292 | ||
; CHECK-NEXT: Language: 0, Sublanguage: 1 | ||
; CHECK-NEXT: Language: 2, Sublanguage: 4 | ||
; CHECK-NEXT: Language: 3, Sublanguage: 5 | ||
; CHECK-NEXT: Language: 2, Sublanguage: 0 | ||
; CHECK-NEXT: Language: 4294967295, Sublanguage: 1 | ||
; CHECK-NEXT: Language: 1, Sublanguage: 4294967295 | ||
; CHECK-NEXT: Language: 4294967294, Sublanguage: 1 | ||
; CHECK-NEXT: Language: 1, Sublanguage: 4294967294 | ||
; CHECK-NEXT: Language: 2, Sublanguage: 1 | ||
; CHECK-NEXT: Language: 3, Sublanguage: 5 | ||
; CHECK-NEXT: Language: 0, Sublanguage: 13 | ||
; CHECK-NEXT: Language: 5, Sublanguage: 7 | ||
|
||
|
||
; RUN: not llvm-rc /V %p/Inputs/parser-expr-bad-binary-1.rc 2>&1 | FileCheck %s --check-prefix BINARY1 | ||
|
||
; BINARY1: llvm-rc: Error parsing file: expected '-', '~', integer or '(', got & | ||
|
||
|
||
; RUN: not llvm-rc /V %p/Inputs/parser-expr-bad-binary-2.rc 2>&1 | FileCheck %s --check-prefix BINARY2 | ||
|
||
; BINARY2: llvm-rc: Error parsing file: expected '-', '~', integer or '(', got | | ||
|
||
|
||
; RUN: not llvm-rc /V %p/Inputs/parser-expr-bad-binary-3.rc 2>&1 | FileCheck %s --check-prefix BINARY3 | ||
|
||
; BINARY3: llvm-rc: Error parsing file: expected '-', '~', integer or '(', got + | ||
|
||
|
||
; RUN: not llvm-rc /V %p/Inputs/parser-expr-bad-unary.rc 2>&1 | FileCheck %s --check-prefix UNARY | ||
|
||
; UNARY: llvm-rc: Error parsing file: expected ',', got ~ | ||
|
||
|
||
; RUN: not llvm-rc /V %p/Inputs/parser-expr-unbalanced-1.rc 2>&1 | FileCheck %s --check-prefix UNBALANCED1 | ||
|
||
; UNBALANCED1: llvm-rc: Error parsing file: expected ')', got , | ||
|
||
|
||
; RUN: not llvm-rc /V %p/Inputs/parser-expr-unbalanced-2.rc 2>&1 | FileCheck %s --check-prefix UNBALANCED2 | ||
|
||
; UNBALANCED2: llvm-rc: Error parsing file: expected ',', got ) | ||
|
||
|
||
; RUN: not llvm-rc /V %p/Inputs/parser-expr-unbalanced-3.rc 2>&1 | FileCheck %s --check-prefix UNBALANCED3 | ||
|
||
; UNBALANCED3: llvm-rc: Error parsing file: expected ',', got ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters