import { Token , TokenType } from '../lexer' ; import { mapPositionToString , Position } from '../shared' ; import { DefinitionNode , IdentNode , SequenceNode } from '../parser/ast' ; export class MismatchTypeError extends Error { constructor ( base , expected ) { super ( `${ mapPositionToString ( base ) } Expected token of type ${ expected }, received ${ base . type } instead.` ) ; } } export class IllegalToken extends Error { constructor ( position , char ) { super ( `${ mapPositionToString ( position ) } Illegal character detected: '${ char }'` ) ; } } export class UndefinedFragment extends Error { constructor ( usage ) { super ( `${ mapPositionToString ( usage . identifier . token ) } Could not find fragment with name ${ usage . identifier . token . literal }.` ) ; } } export class UndefinedDefinition extends Error { constructor ( definitionNode , ident ) { super ( `${ mapPositionToString ( ident ) } Could not find ${ definitionNode . definitionType . literal } with name ${ ident . literal } in file "${ definitionNode . path . literal }".` ) ; } } export class UndefinedIdent extends Error { constructor ( type , ident ) { super ( `${ mapPositionToString ( ident . base ) } Could not find ${ type } function "${ ident . base . literal }" defined.` ) ; } }