zoukankan      html  css  js  c++  java
  • 解决CSharpGL使用CGCompiler时发现的几个问题

    解决CSharpGL使用CGCompiler时发现的几个问题

    为了获取CSharpShadingLanguage的token流,我设计了这样一个文法:

    <Expression> ::= "~" "!" "@" "#" "%" "^" "&" "*" "(" ")" "-" "+" "=" "{" "}" "[" "]" ":" ";" "<" ">" "," "." "?" "/" "~=" "!=" "%=" "^=" "&=" "*=" "-=" "+=" "<=" ">=" "/=" "&&" "++" "<<" ">>" constString identifier number;

    这当然不能进行语法分析,但是足以进行词法分析。

    在使用过程中发现CGCompiler有几个bug,在此记录并fix掉。

    重复的token类型

    文法中有identifier时,TokenType的枚举类型里会出现重复的identifier。

    此问题已解决(大概吧)。只需在ContextfreeGrammarEnumTokenTypeSG.cs中加入如下判定。

    GetCharType()没有判定@符号

    此问题已解决。在ContextfreeGrammarLexicalAnalyzerSG.cs的GenerateLexicalAnalyzerMethodGetCharType()方法中加入3行固定代码即可。出现此问题是因为我以前漏掉了对@这个符号的解析。

    GetDivideOpt()没有判定跳过单行注释

    已解决。只需在ContextfreeGrammarLexicalAnalyzerSG.cs文件中补充如下代码即可。

  • 相关阅读:
    十进制转任意进制
    整型与字符串转换
    最长递增子序列(动态规划)
    睡眠理发师问题
    区间最值问题(RMQ)
    分解质因子
    数字统计
    After all, tomorrow is another day.
    【USB电平】电脑USB电平
    【有源滤波】滤波基础知识
  • 原文地址:https://www.cnblogs.com/bitzhuwei/p/CGCompiler-fix.html
Copyright © 2011-2022 走看看