Skip to content

Commit

Permalink
Merge pull request #167 from SpiceSharp/alpha_&_omega
Browse files Browse the repository at this point in the history
Add support for Alpha_&_Omega const (LTSpice support)
  • Loading branch information
marcin-golebiowski authored Jan 9, 2025
2 parents bf21d75 + b6de01f commit c287954
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/SpiceSharpParser/Lexers/Expressions/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,15 @@ public void Next()
number >= 'A' && number <= 'Z'))
Continue();
break;
case char letter when letter >= 'a' && letter <= 'z' || letter >= 'A' && letter <= 'Z' || letter == '_':
case char letter when letter >= 'a' && letter <= 'z' || letter >= 'A' && letter <= 'Z':
Type = TokenType.Identifier;
Continue();
while ((Index < _expression.Length) && ((
letter = _expression[Index]) >= 'a' && letter <= 'z' ||
letter >= 'A' && letter <= 'Z' ||
letter >= '0' && letter <= '9' ||
letter == '_'))
letter == '_' ||
letter == '&'))
Continue();
break;

Expand Down
2 changes: 1 addition & 1 deletion src/SpiceSharpParser/Lexers/Netlist/Spice/SpiceLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void BuildGrammar()
{
var builder = new LexerGrammarBuilder<SpiceLexerState>();
builder.AddRegexRule(new LexerInternalRule("LETTER", "[a-zA-Zµ]"));
builder.AddRegexRule(new LexerInternalRule("CHARACTER", @"[a-zA-Z0-9\-\+§µ]"));
builder.AddRegexRule(new LexerInternalRule("CHARACTER", @"[a-zA-Z0-9\-\+§µ_&]"));
builder.AddRegexRule(new LexerInternalRule("DIGIT", "[0-9]"));
builder.AddRegexRule(new LexerInternalRule("SPECIAL", @"[\/\\_\.:%!\#\-;\<\>\^\*\[\]]"));
builder.AddRegexRule(new LexerTokenRule<SpiceLexerState>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ private void CreateSpiceParameters()
Parameters.Add("c", new ConstantExpression(299792500));
Parameters.Add("boltz", new ConstantExpression(1.38062e-23));
Parameters.Add("NaN", new ConstantExpression(double.NaN));
Parameters.Add("Alpha_&_Omega", new ConstantExpression(double.PositiveInfinity));
}
}
}

0 comments on commit c287954

Please sign in to comment.