Skip to content

The calculator accepts expressions with the bitwise AND(&) and XOR(^) operators, as well as parentheses. (Single digit numbers only)

Notifications You must be signed in to change notification settings

alexgian1/Bitwise-Calculator-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Bitwise-Calculator-Parser

The calculator accepts expressions with the bitwise AND(&) and XOR(^) operators, as well as parentheses. (Single digit numbers only)

Initial grammar:

exp -> num | exp op exp | (exp)

op -> ^ | &

num -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

LL(1) grammar with priority:

exp -> term exp2

exp2 -> ^ term exp2 | ε

term -> exp3 term2

term2 -> & exp3 term2 | ε

exp3 -> num | (exp)

num -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

Execution

javac Parser.java
java Parser

Input examples

1&2^2&3

1&2^(2&3^4)

2^3&(2&4^(3&3^(8&4)))^2

About

The calculator accepts expressions with the bitwise AND(&) and XOR(^) operators, as well as parentheses. (Single digit numbers only)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages