Altium designer Sch Compiler: unique identifiers error的原因分析与解决方法

转载:(https://www.cnblogs.com/feitian629/archive/2013/05/06/3062648.html

现象:新设计一份图纸,在原理图界面编译后,在massage页面出现大量警告信息,基本上都是Compiler: unique identifiers error......等警告。

 

原因分析:当新建一个Sch文件,所有元器件的设计电路从一个页面复制到另一个页面时,就会出现这个问题。因为,新建一个Sch并编译后,在编译的页面的元器件的unique identifiers是确定的,当再次新建一个SCH文件,并将原来的电路图复制到这个新建的sch页面时,则元器件的unique identifiers属性将会保持,这样在不同的Sch页面便会出现相同的unique identifiers,Altium Designer 在后期导入PCB文件时,会验证unique identifiers,一对一进行,而一个unique identifiers对应两个元器件,则会导致导入PCB出现元器件丢失等问题。

 

解决方法:Unique ID如果大量发生重复,SCH界面中的Tools » Convert » Reset Component Unique IDs能解决这个问题。(查了一下AD的帮助文件找到的方法)

 

AD好像在6.9之后建议采用Unique ID来实现SCH符号和PCB封装的对应,这样做可能是为了保证设计重用时候的正确性(这个还没有试过)。如果AD发现SCH和现有PCB出现Unique ID不对应的情况,会询问是否采用Designators对应的方式。

  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Sure, I can help you with that! Here's a sample code for a lexical analyzer/scanner for the decaf language in Java: ``` import java.io.*; import java.util.*; public class Scanner { private BufferedReader br; private char currentChar; private int currentLineNum; private String currentTokenValue; // reserved words private static final Map<String, Token.Kind> reservedWords = new HashMap<>(); static { reservedWords.put("class", Token.Kind.CLASS); reservedWords.put("extends", Token.Kind.EXTENDS); reservedWords.put("static", Token.Kind.STATIC); reservedWords.put("void", Token.Kind.VOID); reservedWords.put("main", Token.Kind.MAIN); reservedWords.put("public", Token.Kind.PUBLIC); reservedWords.put("private", Token.Kind.PRIVATE); reservedWords.put("int", Token.Kind.INT); reservedWords.put("boolean", Token.Kind.BOOLEAN); reservedWords.put("if", Token.Kind.IF); reservedWords.put("else", Token.Kind.ELSE); reservedWords.put("while", Token.Kind.WHILE); reservedWords.put("return", Token.Kind.RETURN); reservedWords.put("true", Token.Kind.TRUE); reservedWords.put("false", Token.Kind.FALSE); reservedWords.put("this", Token.Kind.THIS); reservedWords.put("new", Token.Kind.NEW); } // special symbols private static final Map<String, Token.Kind> specialSymbols = new HashMap<>(); static { specialSymbols.put("(", Token.Kind.LPAREN); specialSymbols.put(")", Token.Kind.RPAREN); specialSymbols.put("{", Token.Kind.LBRACE); specialSymbols.put("}", Token.Kind.RBRACE); specialSymbols.put("[", Token.Kind.LBRACKET); specialSymbols.put("]", Token.Kind.RBRACKET); specialSymbols.put(".", Token.Kind.DOT); specialSymbols.put(",", Token.Kind.COMMA); specialSymbols.put(";", Token.Kind.SEMICOLON); specialSymbols.put("=", Token.Kind.ASSIGN); specialSymbols.put("!", Token.Kind.NOT); specialSymbols.put("&", Token.Kind.AND); specialSymbols.put("|", Token.Kind.OR); specialSymbols.put("<", Token.Kind.LT); specialSymbols.put(">", Token.Kind.GT); specialSymbols.put("==", Token.Kind.EQUAL); specialSymbols.put("!=", Token.Kind.NOTEQUAL); specialSymbols.put("<=", Token.Kind.LE); specialSymbols.put(">=", Token.Kind.GE); specialSymbols.put("+", Token.Kind.ADD); specialSymbols.put("-", Token.Kind.SUB); specialSymbols.put("*", Token.Kind.MUL); specialSymbols.put("/", Token.Kind.DIV); specialSymbols.put("%", Token.Kind.MOD); } public Scanner(String filename) throws IOException { br = new BufferedReader(new FileReader(filename)); currentLineNum = 1; currentChar = (char) br.read(); } private void getNextChar() throws IOException { if (currentChar == '\n') { currentLineNum++; } currentChar = (char) br.read(); } private boolean isWhitespace(char c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } private boolean isDigit(char c) { return c >= '0' && c <= '9'; } private boolean isLetter(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } private boolean isLegalCharacter(char c) { return isWhitespace(c) || isDigit(c) || isLetter(c) || specialSymbols.containsKey(Character.toString(c)); } private void skipWhitespace() throws IOException { while (isWhitespace(currentChar)) { getNextChar(); } } private Token scanIdentifierOrKeyword() throws IOException { StringBuilder sb = new StringBuilder(); while (isLetter(currentChar) || isDigit(currentChar) || currentChar == '_') { sb.append(currentChar); getNextChar(); } String tokenValue = sb.toString(); Token.Kind kind = reservedWords.getOrDefault(tokenValue, Token.Kind.ID); return new Token(kind, tokenValue, currentLineNum); } private Token scanNumber() throws IOException { StringBuilder sb = new StringBuilder(); while (isDigit(currentChar)) { sb.append(currentChar); getNextChar(); } String tokenValue = sb.toString(); return new Token(Token.Kind.NUM, tokenValue, currentLineNum); } private Token scanString() throws IOException { StringBuilder sb = new StringBuilder(); getNextChar(); while (currentChar != '"') { if (currentChar == '\n' || currentChar == -1) { throw new LexicalException("Unterminated string", currentLineNum); } sb.append(currentChar); getNextChar(); } getNextChar(); return new Token(Token.Kind.STR, sb.toString(), currentLineNum); } private Token scanComment() throws IOException { getNextChar(); getNextChar(); while (!(currentChar == '*' && br.read() == '/')) { if (currentChar == '\n') { currentLineNum++; } getNextChar(); } getNextChar(); return getNextToken(); } private Token scanSpecialSymbol() throws IOException { StringBuilder sb = new StringBuilder(); while (specialSymbols.containsKey(sb.toString() + currentChar)) { sb.append(currentChar); getNextChar(); } String tokenValue = sb.toString(); Token.Kind kind = specialSymbols.get(tokenValue); if (kind == null) { throw new LexicalException("Illegal character: " + tokenValue, currentLineNum); } return new Token(kind, tokenValue, currentLineNum); } public Token getNextToken() throws IOException { while (isWhitespace(currentChar)) { skipWhitespace(); } if (currentChar == -1) { return new Token(Token.Kind.EOF, "", currentLineNum); } if (!isLegalCharacter(currentChar)) { throw new LexicalException("Illegal character: " + currentChar, currentLineNum); } if (currentChar == '/') { getNextChar(); if (currentChar == '/') { while (currentChar != '\n' && currentChar != -1) { getNextChar(); } return getNextToken(); } else if (currentChar == '*') { return scanComment(); } else { return new Token(Token.Kind.DIV, "/", currentLineNum); } } if (isLetter(currentChar)) { return scanIdentifierOrKeyword(); } if (isDigit(currentChar)) { return scanNumber(); } if (currentChar == '"') { return scanString(); } if (specialSymbols.containsKey(Character.toString(currentChar))) { return scanSpecialSymbol(); } throw new LexicalException("Illegal character: " + currentChar, currentLineNum); } public static class LexicalException extends RuntimeException { private int lineNum; public LexicalException(String message, int lineNum) { super(message); this.lineNum = lineNum; } public int getLineNum() { return lineNum; } } } ``` This code reads in a source code file and returns a stream of tokens. It uses a map to store the reserved words and special symbols, and uses a series of `if` statements to determine what kind of token it is dealing with. It also handles lexical errors by throwing a `LexicalException` with a meaningful error message and the line number where the error occurred.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值