我找到了一个简单的语法来开始学习ANTLR.我把它放在myGrammar.g文件中.这是语法:
grammar myGrammar;
/* This will be the entry point of our parser. */
eval
: additionExp
;
/* Addition and subtraction have the lowest precedence. */
additionExp
: multiplyExp
( '+' multiplyExp
| '-' multiplyExp
)*
;
/* Multiplication and division have a higher precedence. */
multiplyExp
: atomExp
( '*' atomExp
| '/' atomExp
)*
;
atomExp
: Number
| '(' additionExp ')'
;
/* A number: can be an integer value, or a decimal value */
Number …Run Code Online (Sandbox Code Playgroud) 我想在Python中创建一个目录.
这是我的代码:
dl_path = "~/Downloads/PDMB"
def main():
if not os.path.exists(dl_path):
print "path doesn't exist. trying to make"
os.makedirs(dl_path)
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud)
我希望pdmb在Download文件夹中$HOME(顺便说一句,我的操作系统是Ubuntu),但它使Home/Downloads/pdmb与我的代码所在的文件夹相同.
我该怎么办?