Impl: auto generating of new

This commit is contained in:
Shunsuke Shibayama 2022-09-07 14:48:02 +09:00
parent e021ce71a7
commit 5029d71cbe
13 changed files with 401 additions and 88 deletions

View file

@ -1872,13 +1872,17 @@ impl Identifier {
Self::new(None, VarName::from_str_and_line(name, line))
}
pub fn public_with_line(dot: Token, name: Str, line: usize) -> Self {
Self::new(Some(dot), VarName::from_str_and_line(name, line))
}
pub fn is_const(&self) -> bool {
self.name.is_const()
}
pub const fn vis(&self) -> Visibility {
match &self.dot {
Some(_dot) => Visibility::Public,
Some(_) => Visibility::Public,
None => Visibility::Private,
}
}

View file

@ -376,6 +376,16 @@ impl Token {
Self::from_str(TokenKind::Symbol, cont)
}
#[inline]
pub fn symbol_with_line(cont: &str, line: usize) -> Self {
Token {
kind: TokenKind::Symbol,
content: Str::rc(cont),
lineno: line,
col_begin: 0,
}
}
pub const fn static_symbol(s: &'static str) -> Self {
Token {
kind: TokenKind::Symbol,