Skip to content

Commit

Permalink
Some minor cleanups
Browse files Browse the repository at this point in the history
Summary: Rename some helper functions for constructing single quoted strings, and remove unused lines

Reviewed By: robertoaloi

Differential Revision: D59105239

fbshipit-source-id: 641fcf162035583fee4d08655d85083cceff3536
  • Loading branch information
alanz authored and facebook-github-bot committed Jun 27, 2024
1 parent 960f6e4 commit da275db
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ const atom_const = (x) => choice(x, alias('\'' + x + '\'', x));
//
///////////////////////////////////////////////////////////////////////////////

// const sq_string_base = /([^"\\]|\\([^x\^]|[0-7]{1,3}|x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\}|\^.))*"/;
const sq_string_base = /([^"\\]|\\([^x\^]|[0-7]{1,3}|x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\}|\^.))*/;
const sq_string_base2 = /\\([^x\^]|[0-7]{1,3}|x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\}|\^.)/;
const sq_string_q_base = /([^"\\]|\\([^x\^]|[0-7]{1,3}|x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\}|\^.))*/;
const sq_string_base = /\\([^x\^]|[0-7]{1,3}|x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\}|\^.)/;

// https://www.erlang.org/eeps/eep-0066#string-delimiters
// () [] {} <>
Expand All @@ -88,17 +87,17 @@ const make_verbatim_sigil_string = (sigil) => choice(
);

const make_quoted_sigil_string = (sigil) => choice(
seq(sigil, /\(/, repeat(choice(/[^\)]/, sq_string_base2)), /\)/),
seq(sigil, /\[/, repeat(choice(/[^\]]/, sq_string_base2)), /\]/),
seq(sigil, /\{/, repeat(choice(/[^\}]/, sq_string_base2)), /\}/),
seq(sigil, /</, repeat(choice(/[^>]/, sq_string_base2)), />/),

seq(sigil, /\//, repeat(choice(/[^\/]/, sq_string_base2)), /\//),
seq(sigil, /\|/, repeat(choice(/[^\|]/, sq_string_base2)), /\|/),
seq(sigil, /\'/, repeat(choice(/[^\']/, sq_string_base2)), /\'/),
seq(sigil, /\"/, repeat(choice(/[^\"]/, sq_string_base2)), /\"/),
seq(sigil, /\`/, repeat(choice(/[^\`]/, sq_string_base2)), /\`/),
seq(sigil, /\#/, repeat(choice(/[^\#]/, sq_string_base2)), /\#/),
seq(sigil, /\(/, repeat(choice(/[^\)]/, sq_string_base)), /\)/),
seq(sigil, /\[/, repeat(choice(/[^\]]/, sq_string_base)), /\]/),
seq(sigil, /\{/, repeat(choice(/[^\}]/, sq_string_base)), /\}/),
seq(sigil, /</, repeat(choice(/[^>]/, sq_string_base)), />/),

seq(sigil, /\//, repeat(choice(/[^\/]/, sq_string_base)), /\//),
seq(sigil, /\|/, repeat(choice(/[^\|]/, sq_string_base)), /\|/),
seq(sigil, /\'/, repeat(choice(/[^\']/, sq_string_base)), /\'/),
seq(sigil, /\"/, repeat(choice(/[^\"]/, sq_string_base)), /\"/),
seq(sigil, /\`/, repeat(choice(/[^\`]/, sq_string_base)), /\`/),
seq(sigil, /\#/, repeat(choice(/[^\#]/, sq_string_base)), /\#/),
);

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1100,7 +1099,7 @@ module.exports = grammar({

_sq_string: $ => token(seq(
/"/,
sq_string_base,
sq_string_q_base,
/"/
)),

Expand Down

0 comments on commit da275db

Please sign in to comment.