⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calcscanner.elx

📁 用于词法分析的词法分析器
💻 ELX
字号:
# $Id: CalcScanner.elx,v 1.3 1997/05/18 10:56:46 matt Exp $# An Elex scanner script to scan symbols for a simple calculator# application written in C++.# This is the start of the scanner definition.scanner CalcScannersymbols  # This section tells the code generator to declare these tokens to be  # unique integer constants that will be used to represent each symbol.  SymNumber SymVariable SymMod SymPlus SymMinus SymStar SymSlash  SymLBracket SymRBracketdefines  # This section is used to define symbolic expressions that can be used  # in later regular expressions.  number = "0-9+"begin  # This is the main section, composed of a number of productions that  # each define a symbol.  Each production is of the form  #  #  on [productionName] "regexp"  #  <  #    code to be executed on a match of regexp  #  >  #  #  #  The productionName part is used to give a meaningful name to the  #  production.  If no name is given, the production's position in the  #  script is used as the name (the first production is numbered 1).  # Matches numbers like 1, -1.2, +1.1e10, -10e-2  on Number "<number>(\.<number>)?([eE][\+\-]?<number>)?"  <    // SymNumber, like all the constants used in return statements    // below, appears in the `symbols' section and will be declared by    // the code generator.    return SymNumber;  >  # Matches variable names beginning with a letter, followed by zero  # or more letters or underscores.  on Variable "[a-zA-Z][a-zA-Z_]*"  <    return SymVariable;  >  # This matches 'mod' as a special keyword.  Note that while the  # Variable production above also matches 'mod', this production has  # precedence because it comes later in the script.  on Mod "mod"  <    return SymMod;  >  on Plus "\+"  <    return SymPlus;  >  on Minus "\-"  <    return SymMinus;  >  on Star "\*"  <    return SymStar;  >  on Slash "/"  <    return SymSlash;  >  on LBracket "\("  <    return SymLBracket;  >  on RBracket "\)"  <    return SymRBracket;  >  # This production causes the scanner to ignore whitespace.  on WhiteSpace "[ \t\n]+"  <    return SymNULL;  >  # The error production gets matched when the scanner reads something  # that cannot be matched by any other production.  The default behavior  # if this production does not exist is to raise `invalid symbol' error.  # This default behavior is overridden if this production returns  # SymNULL, but will still happen if the production returns SymERROR.  on error  <    // This production has no effect, since returning SymERROR means    // error is handled as usual.    return SymERROR;  >end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -